pymel.core.general.reorder

reorder(*args, **kwargs)

This command reorders (moves) objects relative to their siblings. For relative moves, both positive and negative numbers may be specified. Positive numbers move the object forward and negative numbers move the object backward amoung its siblings. When an object is at the end (beginning) of the list of siblings, a relative move of 1 (-1) will put the object at the beginning (end) of the list of siblings. That is, relative moves will wrap if necessary. If a shape is specified and it is the only child then its parent will be reordered.

Flags:

Long Name / Short Name Argument Types Properties
back / b bool ../../../_images/create.gif
  Move object(s) to back of sibling list.
front / f bool ../../../_images/create.gif
  Move object(s) to front of sibling list.
relative / r int ../../../_images/create.gif
  Move object(s) relative to other siblings. Flag can have multiple arguments, passed either as a tuple or a list.

Derived from mel command maya.cmds.reorder

Example:

import pymel.core as pm

# create a hierarchy
pm.sphere( n='sphere1' )
# Result: [nt.Transform(u'sphere1'), nt.MakeNurbSphere(u'makeNurbSphere1')] #
pm.sphere( n='sphere2' )
# Result: [nt.Transform(u'sphere2'), nt.MakeNurbSphere(u'makeNurbSphere2')] #
pm.sphere( n='sphere3' )
# Result: [nt.Transform(u'sphere3'), nt.MakeNurbSphere(u'makeNurbSphere3')] #
pm.sphere( n='sphere4' )
# Result: [nt.Transform(u'sphere4'), nt.MakeNurbSphere(u'makeNurbSphere4')] #
pm.group( 'sphere1', 'sphere2', 'sphere3', 'sphere4', n='group1' )
# Result: nt.Transform(u'group1') #

# The hierarchy group1 contains sphere1, sphere2, sphere3 and sphere4.
# The command below moves sphere2 before sphere1.
pm.reorder( 'sphere2', r=-1 )

# make sphere1 the first sibling
pm.reorder( 'sphere1', front=True )

# move sphere3 forward 2 siblings. Moving it forward one
# sibling would put it at the end. Moving it forward again
# puts it at the beginning.
pm.reorder( 'sphere3', r=2 )