This command duplicates the given objects. If no objects are given, then the selected list is duplicated. The smart transform feature allows duplicate to transform newly duplicated objects based on previous transformations between duplications. Example: Duplicate an object and move it to a new location. Duplicate it again with the smart duplicate flag. It should have moved once again the distance you had previously moved it. Note: changing the selected list between smart duplications will cause the transform information to be deleted The upstream Nodes option forces duplication of all upstream nodes leading upto the selected objects.. Upstream nodes are defined as all nodes feeding into selected nodes. During traversal of Dependency graph, if another dagObject is encountered, then that node and all it’s parent transforms are also duplicated. The inputConnections option forces the duplication of input connections to the nodes that are to be duplicated. This is very useful especially in cases where two nodes that are connected to each other are specified as nodes to be duplicated. In that situation, the connection between the nodes is also duplicated. See also:instance
If addShape evaluates to True, then all arguments fed in must be shapes, and each will be duplicated and added under the existing parent transform, instead of duplicating the parent transform. The following arguments are incompatible with addShape, and will raise a ValueError if enabled along with addShape:
renameChildren (rc), instanceLeaf (ilf), parentOnly (po), smartTransform (st)
returns wrapped classes
returnRootsOnly is forced on for dag objects. This is because the duplicate command does not use full paths when returning the names of duplicated objects and will fail if the name is not unique.
Long name (short name) | Argument Types | Properties | |
---|---|---|---|
inputConnections (ic) | bool | ||
Input connections to the node to be duplicated, are also duplicated. This would result in a fan-out scenario as the nodes at the input side are not duplicated (unlike the -un option). |
|||
instanceLeaf (ilf) | bool | ||
|
|||
name (n) | unicode | ||
|
|||
parentOnly (po) | bool | ||
|
|||
renameChildren (rc) | bool | ||
|
|||
returnRootsOnly (rr) | bool | ||
return only the root nodes of the new hierarchy. When used with upstreamNodes flag, the upstream nodes will be omitted in the result. This flag controls only what is returned in the output string[], and it does NOT change the behaviour of the duplicate command. |
|||
smartTransform (st) | bool | ||
|
|||
upstreamNodes (un) | bool | ||
|
Derived from mel command maya.cmds.duplicate
Example:
import pymel.core as pm
# Create a hierarchy of two spheres;
pm.sphere( n='sphere1' )
# Result: [nt.Transform(u'sphere1'), nt.MakeNurbSphere(u'makeNurbSphere1')] #
pm.move( 3, 0, 0 )
pm.sphere( n='sphere2' )
# Result: [nt.Transform(u'sphere2'), nt.MakeNurbSphere(u'makeNurbSphere2')] #
pm.move( -3, 0, 0 )
pm.group( 'sphere1', 'sphere2', n='group1' )
# Result: nt.Transform(u'group1') #
pm.circle( n='circle1' )
# Result: [nt.Transform(u'circle1'), nt.MakeNurbCircle(u'makeNurbCircle1')] #
# Create a duplicate of the group
pm.duplicate( 'group1' )
# Result: [nt.Transform(u'group2')] #
pm.undo()
pm.duplicate( 'group1', rr=True )
# Result: [nt.Transform(u'group2')] #
# Create a row of 4 circles equally spaced using
# the -smartTransform flag.
pm.duplicate( 'circle1' )
# Result: [nt.Transform(u'circle2')] #
pm.move( 3, 0, 0 )
pm.duplicate( st=True )
# Result: [nt.Transform(u'circle3')] #
pm.duplicate( st=True )
# Result: [nt.Transform(u'circle4')] #
# Duplicate a sphere along with its input connections.
# If animCurves were feeding into original transforms of the
# sphere, they will feed into the duplicated ones also.
# If the sphere has history (in this case it does),
# then the history is connected to the duplicate. Note that
# changing the radius for the makeNurbSphere for the sphere1
# affects the duplicated sphere.
#
pm.duplicate( 'group1|sphere1', ic=True )
# Result: [nt.Transform(u'sphere3')] #
pm.move( 0, 0, 0 )
pm.setAttr( 'makeNurbSphere1.radius', 2 )
# Duplicate selected objects along with their upstream nodes
# and connections. This will duplicate the history.
pm.select( 'group1|sphere2' )
pm.duplicate( un=True )
# Result: [nt.Transform(u'sphere4')] #