Work with namespaces
 
 
 

A name space is a virtual space in which all objects must have unique names. This gives you a way of handling multiple objects with the same name, by putting each in a distinct namespace.

Related topics

To create a namespace during file referencing

  1. In the parent file, select File > Create Reference > .

    The Reference Options window appears.

  2. In the Name Clash Options, turn on Use namespaces.
  3. Click Reference.

    A File Browser appears.

  4. Navigate to the file you want to reference and then click Reference.

    The file is referenced into the parent scene. If you open the Outliner, you can see that the object names for the referenced objects are all prefixed with the file’s name.

To create a namespace manually

  1. Open the Namespace Editor ( Window > General Editors > Namespace Editor).
  2. Click the New button.

    Maya creates a new namespace.

Editing a namespace

You can edit namespaces with the Namespace Editor ( Window > General Editors > Namespace Editor) or from within the Reference Editor. For more information see Reference Editor overview and Work with file references.

In addition to options available in the above windows, you can also use the command line to set the current namespace.

To set the current namespace

  1. In the command line, enter namespace -set “<your namespace>”;
  2. Press enter.

Displaying namespaces

Turn namespaces on and off

You can turn the display of namespaces on or off in the Outliner, Channel Box, and Layer Editor.

When using namespaces, object names can sometimes get very long. This can make it difficult to differentiate objects by name. Turning off the display of namespaces replaces the namespace portion of a node’s name (if any) with “...:”. The shortened name makes it easier to distinguish between different objects in your scene.

To turn on/off the display of namespaces in the Outliner

  1. With the Outliner opened, click Display > Show Namespace.

    When this menu item is turned on, the display of namespaces is turned on for the Outliner. Turn this item off to turn the display of namespaces off for the Outliner.

To turn on/off the display of namespaces in the Channel Box

  1. With the Channel Box opened, do one of the following:
    • Click Channels > Settings > Show Namespace.
    • Right-click in the Channel Box and select Settings > Show Namespace from the pop-up menu that appears.

When this menu item is turned on, the display of namespaces is turned on in the Channel Box. Turn off this item to turn the display of namespaces off for the Channel Box.

To turn on/off the display of namespaces in the Layer Editor

  1. In the Layer Editor, click Options > Show Namespace.

    When this menu item is turned on, the display of namespaces is turned on in the Outliner. Turn off this item to turn the display of namespaces off for the Layer Editor.

Set relative namespace mode

You can refer to namespaces relative to the current namespace. This can help streamline the Outliner and allows you to simplify MEL commands by eliminating the need to constantly include the namespace.

For example, if you had a cube in a namespace named cube_space and set the current namespaces to cube_space, you could use the command setAttr pCube1.translateX rather than having to specify setAttr cube_space:pCube1.translateX.

To display namespaces relative to a particular namespace

  1. In the MEL command line, type the following command:
    namespace -set "cube_space"

    Replace cube_space with the namespace you want to set to current.

  2. In the MEL command line, type the following command:
    namespace -rel on

    Maya displays all the namespaces in the Outliner relative to the namespace set in step 1. If a node is not within that namespace, its name is preceded with “:” followed by its own namespace.

  3. Change the current namespace at any time witht he command namespace -set followed by the namespace’s name in quotes (as in step 1). Maya updates the display of all namespaces in the Outliner relative to the new current namespace.
  4. Turn off relative namespaces at any time with the command namespace -rel off.

Removing a namespace

There may be situations where you need to remove nodes from a particular namespace and subsequently remove the reserved namespace altogether from the scene. These situations might be as follows:

You can do this using the namespace MEL command or the Namespace Editor ( Window > General Editors > Namespace Editor).

Example:

The next two procedures show you how to remove nodes from an existing namespace in a scene, and then remove the reserved namespace from the scene using the namespace MEL command.

To remove a specified namespace for all nodes in a scene

  1. Determine the namespace for a node by selecting any object/node that uses the namespace.

    The namespace for the object/node appears in the Channel Box, Outliner, or other editor when it is selected. An object’s name with an assigned namespace would appear as follows:

    lowRes:pSphere

    In this example, the namespace is called lowRes.

  2. In the Command Line, type the following text string to move any nodes that reside within the lowRes namespace so they reside in the default namespace.
    namespace -mv “lowRes” “:” -f

    Any nodes that had the lowRes namespace now have no namespace specified. That is, the : specifies the default namespace and the -f flag forces the command even if it produces naming conflicts. As a result, nodes with identical names will be assigned an incremental number.

To remove a reserved namespace, you must first ensure that no nodes in the scene currently reside within that namespace. For more information, see the above procedure.

To remove a reserved namespace from a file

  1. You should know the name of the reserved namespace prior to removing it. For more information on determining the namespaces in the scene, see namespaceInfo in the Maya Help. In this example, the namespace to be removed is called lowRes.
  2. In the Command Line, type the following text string to remove the reserved lowRes namespace from the scene.
    namespace -rm “lowRes”
    NoteNamespaces cannot be named so they conflict with any existing namespaces currently in use within the scene.