Maya provides MEL procedures that you can use to exclude attributes from the Lock option on referenced files. For example, you can exclude specific, individual attributes, or all attributes of a specified node type. If more control over your exclusions is required, you can even exclude individual attributes on only particular nodes, or exclude all attributes of specific nodes.
These MEL procedures can be found in the scripts\others folder of your Maya installation directory. The follows sections demonstrate how to use these procedures.
For more information on sourcing MEL scripts and working with MEL procedures in general, see MEL and Expressions.
This example shows you how to create your own MEL procedure to specify which attributes to exclude from the file referencing lock operation. The MEL procedure provided in this example is the same procedure that is distributed with Maya.
global proc string[] getLockReferenceExcludedAttributes() { // Return a string array containing a list of attributes // to be skipped during locking of a referenced file. The // listed attributes locked state will remain the same as // in the referenced file. string $lockReferenceExcludedAttributes[]; $lockReferenceExcludedAttributes[0] = "visibility"; return $lockReferenceExcludedAttributes; }
Add or remove any $lockReferenceExcludedAttributes[n] lines as necessary to specify the attributes to exclude using the same syntax as in the above example. Ensure that the array indices [n] are consecutive.
If you named the MEL file exactly the same as the default one that is distributed with Maya, the Lock option uses this new customized script for locking file references the next time Maya starts.
To exclude individual attributes on a particular node from the lock operation, two MEL procedures wantContextualLockReferencedAttribute and shouldLockReferencedAttribute must be created.
Set wantContextualLockReferencedAttribute to return 1, and specify the exclusion logic in shouldLockReferencedAttribute and set it to return 0.
These exclusions work on top of the attribute type exclusions specified in getLockReferenceExcludedAttributes() above. In other words, the attributes specified in getLockReferenceExcludedAttributes() are first excluded, then the ones specified in shouldLockReferencedAttribute are excluded.
Full path for the node is required, and must include the namespace and full dag path if it is a DAG node.
An example is as follows. In this example, there are 3 scenes: A.ma, B.ma, C.ma, and C.ma references B.ma, and B.ma references A.ma.
global proc int wantContextualLockReferencedAttribute() { // By default, only attribute type lock operations are excluded. // Return 1 if you want Maya to call the shouldLockReferencedAttribute procedure return 1; } global proc int shouldLockReferencedAttribute(string $node, string $attr) { // Exclude transform node |C:B:A:A 's translateY and visibility attribute from being locked // Return 0 to indicate that these attributes should be unlocked if(($node == "|C:B:A:A") && ($attr == "translateY" || $attr == "translate" || $attr == "visibility")) { return 0; } else { return 1; } }
If you named the MEL file the same as the default one that is shipped with Maya, the Lock option uses this new customized script for locking file references the next time Maya starts.
This example shows you how to create your own MEL procedure to specify which attributes get excluded by node type. The MEL procedure provided in this example is the same procedure that is distributed with Maya.
global proc string[] getLockReferenceExcludedNodeTypes() { // Return a string array containing a list of node types // whose attributes should be skipped during locking of a referenced file. string $lockReferenceExcludedNodeTypes[]; $lockReferenceExcludedNodeTypes[0] = "lightLinker"; $lockReferenceExcludedNodeTypes[1] = "displayLayerManager"; $lockReferenceExcludedNodeTypes[2] = "displayLayer"; $lockReferenceExcludedNodeTypes[3] = "renderLayerManager"; $lockReferenceExcludedNodeTypes[4] = "renderLayer"; return $lockReferenceExcludedNodeTypes; }
Add or remove any $lockReferenceExcludedNodeTypes[n] lines as necessary to specify the attributes by node type using the same syntax as in the above example. Ensure that the array indices [n] are consecutive.
If you named the MEL file the same as the default one that is shipped with Maya, the Lock option uses this new customized script for locking file references the next time Maya starts.
In addition to excluding attributes for a general node type, you can also add custom logic to specify the specific node(s) that should be excluded from lock operations. For example, you may only want to unlock the transform and shape nodes of a subset of your referenced nodes.
To exclude all attributes of these specific nodes, two MEL procedures wantContextualLockReferencedNode and shouldLockReferencedNode should be created.
These exclusions work on top of the node type exclusions specified in getLockReferenceExcludedNodeTypes() above. In other words, the attributes specified in getLockReferenceExcludedNodeTypes() are first excluded, then the ones specified in shouldLockReferencedNode are excluded.
Full path for the node is required, and must include the namespace and full dag path if it is a DAG node.
An example is as follows. In this example, there are 3 scenes: A.ma, B.ma, C.ma, and C.ma references B.ma, and B.ma references A.ma.
global proc int wantContextualLockReferencedNode() { // By default, only node type lock operations are excluded. // Return 1 if you want Maya to call the shouldLockReferencedNode procedure return 1; } global proc int shouldLockReferencedNode(string $node) { // Exclude transform node "|C:B:B" and its shape node "|C:B:B|C:B:BShape" from being locked // Exclude shape node "|C:C|C:CShape" from being locked // Return 0 to indicate that these attributes should be unlocked if ($node == "|C:B:B" || $node == "|C:B:B|C:B:BShape" || $node == "|C:C|C:CShape") { return 0; } else { return 1; } }
If you named the MEL file the same as the default one that is shipped with Maya, the Lock option uses this new customized script for locking file references the next time Maya starts.