Go to: Synopsis. Flags. Return value. MEL examples.

Synopsis

listRelatives [-allDescendents] [-allParents] [-children] [-fullPath] [-noIntermediate] [-parent] [-path] [-shapes] [-type string] [objects]

listRelatives is undoable, queryable, and editable.

This command lists parents and children of DAG objects. The flags -c/children, -ad/allDescendents, -s/shapes, -p/parent and -ap/allParents are mutually exclusive. Only one can be used in a command.

When listing parents of objects directly under the world, the command will return an empty parent list. Listing parents of objects directly under a shape (underworld objects) will return their containing shape node in the list of parents. Listing parents of components of objects will return the object.

When listing children, shape nodes will return their underworld objects in the list of children. Listing children of components of objects returns nothing.

The -ni/noIntermediate flag works with the -s/shapes flag. It causes any intermediate shapes among the descendents to be ignored.

Flags

allDescendents, allParents, children, fullPath, noIntermediate, parent, path, shapes, type
Long name (short name) [argument types] Properties
-children(-c)
List all the children of this dag node (default).
-allDescendents(-ad)
Returns all the children, grand-children etc. of this dag node. If a descendent is instanced, it will appear only once on the list returned. Note that it lists grand-children before children.
-shapes(-s)
List all the children of this dag node that are shapes (ie, not transforms)
-parent(-p)
Returns the parent of this dag node
-allParents(-ap)
Returns all the parents of this dag node. Normally, this command only returns the parent corresponding to the first instance of the object
-path(-pa)
Return a proper object name that can be passed to other commands.
-fullPath(-f)
Return full pathnames instead of object names.
-noIntermediate(-ni)
No intermediate objects
-type(-typ) string
List all relatives of the specified type. This flag may appear on the command line multiple times.

Flag can appear in Create mode of command Flag can appear in Edit mode of command
Flag can appear in Query mode of command Flag can be used more than once in a command

Return value


string array

MEL examples

  // create an object and an instance for queries
sphere -n "nexus"; instance -n "ball";

// List the name of the shape below the transform node.
  // (The result of the command is shown)
string $shapes[] = `listRelatives -s -path "nexus"`;
  // Result: nexus|nexusShape //

  // list all parents of shape
  listRelatives -allParents $shapes[0];
  // Result: nexus ball //