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.
returns an empty list when the result is None
returns wrapped classes
fullPath is forced on to ensure that all returned node paths are unique
rtype: | DependNode list |
---|
Long name (short name) | Argument Types | Properties | |
---|---|---|---|
allDescendents (ad) | bool | ||
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. |
|||
allParents (ap) | bool | ||
|
|||
children (c) | bool | ||
|
|||
fullPath (f) | bool | ||
|
|||
noIntermediate (ni) | bool | ||
|
|||
parent (p) | bool | ||
|
|||
path (pa) | bool | ||
|
|||
shapes (s) | bool | ||
|
|||
type (typ) | unicode | ||
|
Derived from mel command maya.cmds.listRelatives
Example:
import pymel.core as pm
import maya.cmds as cmds
# create an object and an instance for queries
pm.sphere( n='nexus' )
# Result: [nt.Transform(u'nexus'), nt.MakeNurbSphere(u'makeNurbSphere1')] #
pm.instance( n='ball' )
# Result: [nt.Transform(u'ball')] #
# List the name of the shape below the transform node.
shapes = pm.listRelatives('nexus')
# list all parents of shape
# (The result of the command is shown)
pm.listRelatives( shapes[0], allParents=True )
# Result: [nt.Transform(u'nexus'), nt.Transform(u'ball')] #