Static, dynamic, and extension attributes

Three types of attributes exist in Maya: static, extension and dynamic.

Static attributes are built into the code or are members of plug-in nodes, and cannot be modified or removed.

Dynamic attributes allow you to add or delete attributes on a particular node. Dynamic attributes are different from static attributes in that they are only married to a specific instance of a node type.

Extension attributes allow you to add or delete attributes, at run time, on all nodes of a given type. For example, you can add an attribute to a transform type instead of an instance of a transform. All nodes of type transform that currently exist or that will be created will contain the extension attribute, until that extension attribute is deleted.

Note: Adding an extension attribute to a DAG object will add the attribute to all of its inherited node types. In other words, both the transform and shape nodes, including all types of shapes: meshes, NURBS, and subdivs, will have the extension attribute.

See the Nodes reference documentation for the parent of each node. For example, surfaceShape is the parent of mesh; therefore, all attributes that exist in surfaceShape, both static and extension, also exist in mesh.

Adding and deleting extension attributes

Add extension attributes using the addExtension command. The API equivalent of this command can be found in MDGModifier.

The addExtension command has the same parameters as the addAttr command with one exception. When using the addAttr command, you must specify the name of the node to which you are adding the dynamic attribute. However, when using the addExtension command, you use the -nodeType flag to specify the type of node to which you are adding the extension attribute.

Delete extension attributes using the deleteExtension command. The API equivalent of this command can be found in MDGModifier.

Serialization

There is no addition of an addExtension command to the Maya ASCII file, nor the addition of the binary equivalent to the Maya Binary file.

Extension attributes created by a plug-in rely on the plug-in requirements in the file in which they are used, including any referenced files. If the plug-in fails to load, or fails to add the extension attributes, they will not be available and the file may be missing that information.

Similarly, any extension attributes created via script or user command do not have any information in the files regarding the definition of those attributes, only their connections and values set. Extension attribute values saved in this way rely on the user to run the same script that created them initially before any file using them is loaded. It is good coding practice to confirm that extensions don't already exist before adding them in again; this way, multiple runs of the setup script will succeed every time.