Obtain the transform, shape, and history nodes

When you create an object, a transform node, a shape node, and a history node are created, among others. Select the object, and you will see that the tabs across the top of the Attribute Editor display these nodes.

If you create an object using MEL; for example:

string $plane[] = `polyPlane`;

The Script Editor top tab displays the results:

// Result: pPlane1 polyPlane1 // 

In other words, $plane[0] points to pPlane1 (transform node), and $plane[1] points to polyPlane1 (history node).

Shape nodes are child nodes of transform nodes. In this case, the shape node would be pPlaneShape1.

To obtain a shape node from its transform node, use the listRelatives command:

{
//Lists the transform nodes of all selected objects in the scene
string $nodes[] = `ls -selection`;

for ($node in $nodes)
{
//From each transform node, obtain its shape node and print its name
string $shapes[] = `listRelatives -shapes $node`;
print $shapes;
}
}

Related topics