Skip to content
On this page

Rename objects using custom attributes

The Simplygon Maya plug-in adds custom attributes to all processed objects, such as LOD switch- and naming attributes. This topic describes how name attributes can be used to rename imported objects.

The Simplygon plug-in does not allow writeback of multiple objects with the same name due to how the import / export pipeline are constructed. Some mapping and internal scripts are dependent on the name of objects and to avoid unexpected behavior we are choosing unique names for all objects. Maya does, however, allow multiple objects with the same name in some specific cases. One of the cases is if the objects are located in different groups, as in our scene below where we have two groups with one mesh each, both meshes share the same name (pCube1).

Original scene hierarchy:

Multiple cubes with same name
Multiple cubes with same name

If we now were to process this scene (a single reduction) we would get two LOD meshes back, each inserted under the same parent as the original mesh. The first LOD mesh would get the name pCube1_LOD1 which makes sense, and the second one would get the name pCube1_LOD1_001 (as the intended name is already occupied).

Scene hierarchy including LODs:

Second LOD gets indexed
Second LOD gets indexed

To counter this issue we can use custom attributes to rename imported nodes, these attributes can be found under Extra Attributes under a processed object's transform node. In the image below there are three attributes related to the node name, the Original Node Name as it was when exported from Maya, the Intended Node Name (including name formatting and index, if any) at import and the actual Imported Node Name. As the intended name of the cube in the second group is clashing with the name of the cube in group one it will get indexed.

Custom attributes:

Second LOD gets indexed
Second LOD gets indexed

These attributes can be used to restore imported object names to their original- or intended name. Keep in mind that Maya does not support multiple objects with the same name on the same level in the hierarchy. If we want to rename pCube_LOD1_001 in the second group to its intended name, simply fetch the intended name and rename as in the script below.

MEL
$currentName = "pCube1_LOD1_001";
$intendedName = `getAttr ($currentName + ".IntendedNodeName")`;

rename $currentName $intendedName;
python
import maya.cmds as cmds

currentName = 'pCube1_LOD1_001'
intendedName = cmds.getAttr (currentName + ".IntendedNodeName")

cmds.rename( currentName, intendedName)

The LOD under the second group now has its intended name: After rename