pymel.core.general.ungroup¶
- ungroup(*args, **kwargs)¶
This command ungroups the specified objects. The objects will be placed at the same level in the hierarchy the group node occupied unless the -w flag is specified, in which case they will be placed under the world. If an object is ungrouped and there is an object in the new group with the same name then this command will rename the ungrouped object. See also:group, parent, instance, duplicate
Flags:
Long Name / Short Name Argument Types Properties absolute / a bool preserve existing world object transformations (overall object transformation is preserved by modifying the objects local transformation) [default] parent / p unicode put the ungrouped objects under the given parent relative / r bool preserve existing local object transformations (don’t modify local transformation) world / w bool put the ungrouped objects under the world Flag can have multiple arguments, passed either as a tuple or a list. Derived from mel command maya.cmds.ungroup
Example:
import pymel.core as pm # Create a simple hierarchy pm.sphere( n='sphere1' ) # Result: [nt.Transform(u'sphere1'), nt.MakeNurbSphere(u'makeNurbSphere1')] # pm.move( 2, 0, 0 ) pm.sphere( n='sphere2' ) # Result: [nt.Transform(u'sphere2'), nt.MakeNurbSphere(u'makeNurbSphere2')] # pm.move( -2, 0, 0 ) pm.group( 'sphere1', 'sphere2', n='group1' ) # Result: nt.Transform(u'group1') # pm.move( 0, 2, 0 ) pm.sphere( n='sphere3' ) # Result: [nt.Transform(u'sphere3'), nt.MakeNurbSphere(u'makeNurbSphere3')] # pm.move( 0, 0, 2 ) pm.group( 'group1', 'sphere3', n='group2' ) # Result: nt.Transform(u'group2') # pm.group( em=True, n='group3' ) # Result: nt.Transform(u'group3') # # Remove group1 from the hierarchy. What should remain # is group2 with sphere3, sphere1, and sphere2 as children. # Note that the objects don't move since the absolute flag # is implied. # pm.ungroup( 'group1' ) # Try the same ungroup with the -relative flag. # Now sphere1 and sphere2 will move down 2 units in Y. # pm.undo() pm.ungroup( 'group1', relative=True ) # Now try the same ungroup operation with the -parent flag. # This will move the children of group1 under group3. pm.undo() pm.ungroup( 'group1', parent='group3' )