You can lock file references to prevent them from being accidentally modified when they are referenced in your scene. You can lock a new file reference by turning on the Lock option in the Create Reference Options window when you first create the file reference. You lock an existing file reference from within the Reference Editor. The Lock option locks all of the nodes and attributes for a file reference.
Locking file references is useful in collaborative work environments when its important to have the nodes and attributes of files locked to avoid accidental modifications by the users that reference the files. When a file reference is locked, a special lock icon appears beside the listed reference within the Reference Editor.
If you reference a file without turning on the Lock option, any pre-existing attributes that were locked in a referenced file remain unchanged. That is, if the file being referenced has pre-existing locked attributes when it gets referenced, they remain locked.
You can load and unload a locked reference file and the locked attributes will remain unchanged. If you need to modify any nodes or attributes on a locked reference file you can unlock and later re-lock the reference file using the Reference Editor.
To lock or unlock an existing file reference
With the exception of a few specific attributes and node types, all nodes and attributes for a file reference are locked by default. The attributes and node types that are excluded by the Lock option are specified by two MEL procedures. Each procedure outputs a string array that is used by the Lock option to specify the attributes to be excluded. The first procedure specifies which individual attributes to exclude. The second procedure specifies which attributes, by node type, to exclude. That is, the entire set of attributes for a given node type are excluded from locking by simply declaring the node type in the array.
Regardless of which attributes are excluded, the Lock option always locks all of the nodes for the referenced file.
You can override the MEL procedures that ship with Maya by creating your own customized MEL procedures. Your MEL procedures must be named exactly the same as the ones that ship with Maya. You must additionally ensure the files are placed in the Maya script path.
For more information on working with MEL procedures in Maya, see the MEL and Expressions guide. For more information on customizing the lock settings in your particular production environment see below.
Customizing lock settings for file references
The following examples describe the MEL procedures for excluding attributes and attributes by node type that were shipped with Maya. They can be used as the basis for creating your own customized MEL procedures.
Example 1: MEL procedure for excluding attributes
This example shows you how to create your own MEL procedure to specify which attributes get excluded by 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;
}
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.
For more information on sourcing MEL scripts and working with MEL procedures in general, see the MEL and Expressions guide.
Example 2: MEL procedure for excluding node types
This example shows you how to create your own MEL procedure to specify which attributes, by node type, get excluded by the file referencing lock operation. 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;
}
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.
For more information on sourcing MEL scripts and working with MEL procedures in general, see the MEL and Expressions guide.