Remove namespaces

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

When removing namespaces, you have the option to merge referenced or imported object namespaces with a namespace that exists in the parent scene. When duplicate namespaces occur, the namespaces are merged and duplicate object names are incrementally suffixed with a number.

You can remove namespaces using the Namespace Editor or by using MEL commands.

Remove namespaces using the Namespace Editor

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

    The namespace for the object/node appears highlighted in the Channel Box and Outliner. For example, an object’s name with an assigned namespace can appear as follows:

    spaceJunk:pSphere1
    
  2. In the Namespace Editor, select the namespace you want to remove.
  3. Click Delete.

    If the namespace you want to remove contains nodes, the Delete: namespace window appears.

  4. In the Delete: namespace window, click one of the following:
    • Merge with Root to merge the namespace and move the nodes contained by the deleted namespace to the root namespace.
    • Merge with Parent to merge the namespace and move the nodes contained by the deleted namespace to an immediate parent namespace.
    • Delete to delete the namespace and the nodes contained by the namespace.

Remove namespaces using MEL commands

The next two procedures show you how to remove nodes from an existing namespace in a scene using the namespace MEL command. You can remove the namespace and its contents, or remove that namespace and merge its contents with a root or parent namespace.

Note: For this, and all other commands, consult the commands list in the Maya Technical Documentation.

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:

    spaceJunk:pSphere1
    

    In this example, the namespace is called spaceJunk.

  2. In the Command Line, do the following:
    • To remove the spaceJunk namespace and merge any nodes that reside within the spaceJunk namespace with the root namespace, type:
      namespace -mergeNamespaceWithRoot -removeNamespace "spaceJunk";
    • To remove the spaceJunk namespace and merge any nodes that reside within the spaceJunk namespace with a parent namespace, type:
      namespace -mergeNamespaceWithParent -removeNamespace "spaceJunk";
    • To move any nodes that reside within the spaceJunk namespace so they reside in the default namespace.
      namespace -mv “spaceJunk” “:” -f
      

      Any nodes that had the spaceJunk 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 from a file

    Note: 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.
  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 namespace MEL command. In this example, the namespace to be removed is called spaceJunk.
  2. In the Command Line, type the following text string to remove the reserved spaceJunk namespace from the scene.
    namespace -rm “spaceJunk”
    
    Note:

    Namespaces cannot be named so they conflict with any existing namespaces currently in use within the scene.

Related topics