File referencing tips
 
 
 

File referencing allows you to manage complex scene hierarchies. To gain the most benefit from file referencing, use the following tips to ensure a more efficient workflow. As well, a basic understanding of namespaces will help your workflow. For more information, see Namespaces.

File and node naming for file referencing

Pre-planning the file and node naming conventions for the parent scenes and referenced files is important and will greatly add to the success of the implementation of file referencing in your production environment. In particular plan to ensure that:

File formats for file referencing

Saving files in the Maya ascii file format (.ma) is preferred when using file referencing. Maya ascii files can be opened and edited in your favorite text editor, and are easier to troubleshoot if the file or some components of the file do not load as expected.

Note

It is not recommended that you reference files in other file formats (for example, dxf, obj, wire, and so on) when using file referencing. When possible convert files to a native Maya format by loading and resaving files in the .ma format.

File paths for file referencing

File referencing only supports absolute paths and paths with environment variables. Relative path names are not supported when using file referencing. An environment variable can be used as a superior alternative to a relative path as it is explicit and customizable to each user's file structure.

Relative path (not supported):

scenes/street.ma

Absolute path (supported): C:/projects/cityscene/scenes/street.ma

Environment variable path (supported): $myProject/scenes/street.ma

For more information on environment variables see Setting environment variables using Maya.env.

For more information, see Edit reference paths in the Reference Editor.

File hierarchy assembly

When planning to use file referencing in your production environment, consider your team’s workflow practices (modelers, riggers, animators, materials and so on), as well as the overall requirements for the project before you determine your scene’s hierarchy.

In general, you should reference files in a bottom up manner (that is, reference small items into bigger items). This bottom up structure allows you to easily load or unload any segments of the scene that are not required by the user. For example, when creating a city parent scene, a door and other related components should first be referenced into a building file. Then reference the building into the street file, and then reference the street file into the city parent scene.

When building a character, reference the model into the rigged file. Then reference the rigged file into the environment where the character will be animated. This ensures that a change to the rig is correctly propagated to all environment files that may use the character.

Data filtering

When referencing many files into a scene, the amount of data can rapidly become complex to manage. The Outliner and Hypergraph overview editors have filtering options that allow you to limit the amount of data that gets displayed.

The Display Layer editor allows for sorting of layers alphabetically which will help with organization.

Exporting file references

You can extract segments of a normal scene as a referenced file if it becomes more complex than originally anticipated. Specific components of the scene can be selected and then exported as a separate referenced child scene file using the Export Selection as a Reference command. Exported referenced child scene files are automatically referenced and loaded into the currently open scene. It is not possible to use the Export Selection as a Reference command using a file reference.

A nice benefit of creating file references in this manner is that each region of the scene is in the correct worldspace position and does not need to be repositioned when referenced into the parent scene.

Instancing file references

Instancing of objects can be used to aid scene management by further reducing the amount of data in a scene. For example, if a street scene is to be filled with streetlights, the streetlight file can be referenced in once and then the remaining streetlights instanced. If the streetlight file is unloaded, all the streetlights in the scene will disappear because of their instancing relationship to the original streetlight file.

If you have a reference file and instance an object within it and then later remove the reference file, both versions of the objects will be removed in the parent scene. A transform node will be left behind in the parent scene for the instance. This node remains in case other changes have been applied to the instance by the user in the parent scene.

Do not rename a node or change a hierarchy in a referenced file if the parent scene contains objects that are instanced. Such a change will make the instance disappear; Maya will be looking for an object that no longer exists. Maya’s instancing is name-based. By renaming the object in the reference file, you make the original go away such that the parent scene can no longer find it.

Note

Proxies will only instance the active file reference. If a file reference is instanced and the proxy is switched, the instances will not display.

File reference locator

The file reference locator option is useful when you need to move a file reference in the scene view via its group node. The locator also acts as a visual cue for the reference whenever the reference is unloaded. The locator option is only available in the Reference Options window when the Group option is selected. The locator option groups the contents of the referenced file under a locator, annotated with the reference node name. You can load or unload a reference within the scene by right-clicking on the locator and selecting from the context sensitive menu.

For more information, see File > Create Reference.

Editing referenced files

A parent scene file can be adversely affected by edits that are made at the referenced child scene file level of the hierarchy. That is, an edit made at the parent scene level could become unresolvable if node names and connections are changed at the child scene file level. For some examples of other adverse affects, see Modify a file reference.

Removing unwanted reference node edits

There may be situations where you want to remove unwanted edits from the reference node. For example, you have been applying and removing animation from a file reference while working within the parent scene. You’ve finalized the animation, but now want to ensure there are no unwanted setAttr edits on attributes that should not animated in the final version.

In order to remove unwanted edits you must:

Example: Removing all edits of a particular type

This example shows you how to determine the name of the reference node associated with a file referenced into your currently open scene.

  1. In the scene view, select an object from the referenced file whose reference node name you want to determine.
  2. From the Channel Box, determine the object name for the selected object. In this example, the name of the object is world:planet. Planet is the name of the object, and world is the namespace assigned to it.
  3. In the Command Line, type the following string to determine the reference file name associated with that object:
    reference -q -f world:planet
    

    Maya displays the directory path and name of the reference file. In this example, the reference file name is world.

  4. Next, type the following string to determine the reference node name for the world reference file within the parent scene:
    file -q -rfn world.ma
    

    Maya displays the name of the reference node as follows:

    worldRN
    

Once you have determined the name of the reference node, you must unload the reference file in order to remove the reference edits.

  1. Unload the reference file in the scene, using the reference editor, or by typing the following string:
    file -unloadReference worldRN
    
  2. Query all setAttr edits on the reference node so you know what modifications have been made to the reference.
    reference -editCommand “setAttr” -rfn worldRN -q
    
  3. Type the following string to remove all setAttr edits from the reference node.
    file -cleanReference worldRN -editCommand “setAttr”
    

    The setAttr edits are removed from the reference node worldRN.

  4. You can reload the reference file using the reference editor, or by typing the following string:
    file -loadReference worldRN
    
    Note

    Subsequent references of a file that is already referenced in the parent scene get differentiated from the first reference by the addition of a unique copy number on their filename. For example, the file named world.ma would get named world.ma{1}, world.ma{2}, and so on, in the parent scene each time it was subsequently referenced.

Avoiding use of the default shader

If you reference a file in which you’ve altered the default shader (lambert1), these changes are superseded by the default shader of the parent file. To avoid this situation, create a new shader in the child file and assign that rather than using the default shader.

Shared shader networks

If you reference a file into your current scene with shared shading networks enabled, the shading networks from the referenced scene are combined with those in the current scene (including those of any references). This avoids creating duplicate shading networks when you want the same ones used throughout your scene, including the reference.

Shading networks can only be shared if the shading networks are identical. Maya considers two shading networks to be identical only if all the nodes included in it have both the same name and type while traveling upstream from the shading group.

While the name and type of each node in the shading network must be identical in order for the shading network to be shared, the actual values in each node are not considered. So, a node in a child scene with one value (for example, blue) is considered identical to a node in the parent scene with a different value (for example, red) as long as its name and type match.

However, certain shading networks cannot be shared. They are:

If any of these items appear in the shading network, the network is not shared when the file is referenced with shared shading networks enabled.

Any items that exist downstream of the shading network are also not shared. The only items shared are those items upstream of the shading network.

Note

All edits to referenced nodes that are shared are stored on one common shared reference node. Shared references can only be deleted from the Reference Editor using the Remove Reference menu item. The shared reference node remains for any references that were shared and is only removed when the last shared reference is removed.

Dynamic attributes that are added to a shading network that is subsequently shared may be lost unless the same attributes are created on each of the shading networks to be shared prior to sharing.

Shared display layers

If you reference a file into your current scene with shared display layers enabled, the display layers from the referenced scene are combined with those in the current scene (including those of any references). This avoids creating duplicate display layers when you want the same ones used throughout your scene, including the reference.

Maya uses the display layer name to determine how the referenced display layer is added to the current scene. If a display layer name already exists in the parent scene, any objects assigned to an identically-named display layer in a child scene are added to the original parent display layer when they are referenced.

If a child scene contains a display layer that does not exist in the parent scene, the display layer from the child scene appears in the Display Layer editor of the parent scene when the child scene is referenced. If these child scenes are later removed from the parent scene, their associated display layers are removed from the Display Layer editor as well.

Shared display layers are automatically placed in the default namespace.

Note

All edits to referenced nodes that are shared are stored on one common shared reference node. Shared references can only be deleted from the Reference Editor using the Remove Reference menu item. The shared reference node remains for any references that were shared and is only removed when the last shared reference is removed.

Unknown reference nodes

When a pre-Maya 6.5 file that contains references is converted to a later version Maya file, a reference node named "_UNKNOWN_REF_NODE_" may be created and/or a special "_UNKNOWN_REF_NODE_" entry may be added to existing reference nodes.

This node type was used to store any edits that were made prior to 6.5 until those edits could be applied.

Once all references in the scene have been loaded, all edits should be applied and the _UNKNOWN_REF_NODE_ areas and nodes should disappear. If there are any edits which can not be applied (for example, nodes in the original reference file that were renamed or deleted), the _UNKNOWN_REF_NODE_ will remain in the file.

If you need to remove these reference nodes, you can do so by querying for the _UNKNOWN_REF_NODE_ and deleting it. That is, this specific node type cannot be deleted using the Reference Editor. In the Script Editor:

delete “_UNKNOWN_REF_NODE_”

File reference optimization and errors

By default, if you reference the same file twice, on file open Maya copies the existing nodes instead of re-reading them from disk. Occasionally, using this built-in multiple reference optimization feature of file referencing can cause errors. The MAYA_FORCE_REF_READ environment variable turns off the file referencing optimization and forces reference files to be explicitly read in all cases. This fixes Maya's behavior in some situations that would otherwise be evaluated incorrectly.

For more information, see General variables.

File referencing helper scripts

A number of file referencing helper scripts are available as part of the Maya Bonus Tools. Bonus Tools is a free collection of useful Maya scripts and plug-ins that are available from the Autodesk Web site (www.autodesk.com/maya-bonustools).

To download the Bonus Tools from the Autodesk web site

  1. In Maya, select Help > Download Bonus Tools from the Web.

    You will need to register in order to obtain access to some areas of the Autodesk Web site. Once installed, the Bonus Tools appear within Maya in their own drop-down menu.

Illegal character handling for namespaces

Previously, for Maya versions 2010 and below, the characters '<' and '>' would get converted to '_' if encoutered in a node name or namespace name. Any leading invalid characters are removed, and all others are converted to underscore.

For example, in Maya 2009:

namespace -add "<foo>"
// Result: foo_
createNode transform -n "<bar>"
// Result: bar_
namespace -add "foo<bar>"
//Result: foo_bar_

For Maya 2011 and above, the characters '<' and '>' will still be removed and converted to '_' for node names. However, for namespace names, Maya will consider everything in between those characters as a placeholder namespace. Therefore, you should update your code if you are using these characters and relying on Maya to correct them. For example, in Maya 2012:

namespace -add "<foo>"
// Result: <foo>
createNode transform -n "<bar>"
// Result: bar_
namespace -add "foo<bar>"
//Result: foo_bar_

File referencing and render layers

When using file references in a scene with render layers, ensure that the current layer is the masterLayer when you import the file reference and save the scene file. Render layers and file referencing and saving are more stable if the selected layer is the masterLayer.

Related topics