Maya dataType and attributeType differences?

It may be a stupid question,but can someone please tell me the differences between dataType and attributeType in maya cmds?

I’m still confused after reading maya’s focusless docs and searching for similar threads.
e.g. I can get the origin attribute after
mc.addAttr(longName="origin",dt="double3"),
but not with
mc.addAttr(longName="origin",at="double3").

And is there any way to show the attribute’s value in maya’s attribute editor correctly?Cus maya only display the attribute name followed by a long dash after creating by datatype.
Huge Thanks.

Hopefully this makes sense,

TL; DR - Use DataType when either the type is non trivial (matrix for example) i.e. if it can’t be assumed or if you only want access to the attribute in its entirety and not to its sub-components i.e. x, y, z.

From the docs:

addAttr is undoable, queryable, and editable.

This command is used to add a dynamic attribute to a node or nodes. Either the longName or the shortName or both must be specified. If neither a dataType nor an attributeType is specified, a double attribute will be added. The dataType flag can be specified more than once indicating that any of the supplied types will be accepted (logical-or).

To add a non-double attribute the following criteria can be used to determine whether the dataType or the attributeType flag is appropriate. Some types, such as double3 can use either. In these cases the -dt flag should be used when you only wish to access the data as an atomic entity (eg. you never want to access the three individual values that make up a double3). In general it is best to use the -at in these cases for maximum flexibility. In most cases the -dt version will not display in the attribute editor as it is an atomic type and you are not allowed to change individual parts of it.

1 Like

Thanks for your reply,chalk.
I know that dataType attribute won’t show in Maya UI normally,that is the reason I tried to use the -at flag in the first place.

I got the solution after reading the python example and doing several testes.
I tried to add a double3 attributeType named ‘origin’ with addAttr() and directly give it a 3-element tuple or 3 floats with a single setAttr() command.Which leads me to Runtime Error.

Now I understand that I have to create the three individual float channels manually,with ‘origin’ being their parent,before using setAttr().
屏幕截图 2021-05-13 215910

Again,thanks for your help.