Go to: Synopsis. Return value. Flags. Python examples.
duplicate(
[objects...]
, [fullPath=boolean], [inputConnections=boolean], [instanceLeaf=boolean], [name=string], [parentOnly=boolean], [renameChildren=boolean], [returnRootsOnly=boolean], [smartTransform=boolean], [transformsOnly=boolean], [upstreamNodes=boolean])
Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.
duplicate is undoable, NOT queryable, and NOT editable.
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
string[] | : names of the objects created |
fullPath, inputConnections, instanceLeaf, name, parentOnly, renameChildren, returnRootsOnly, smartTransform, transformsOnly, upstreamNodes
Long name (short name) |
Argument types |
Properties |
|
fullPath(f)
|
boolean
|
|
|
ADDED 2022
Return full pathnames instead of object names.
|
|
inputConnections(ic)
|
boolean
|
|
|
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)
|
boolean
|
|
|
instead of duplicating leaf DAG nodes, instance them.
|
|
name(n)
|
string
|
|
|
name to give duplicated object(s)
|
|
parentOnly(po)
|
boolean
|
|
|
Duplicate only the specified DAG node and not any of its
children.
|
|
renameChildren(rc)
|
boolean
|
|
|
rename the child nodes of the hierarchy, to make them
unique.
|
|
returnRootsOnly(rr)
|
boolean
|
|
|
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)
|
boolean
|
|
|
remembers last transformation and applies
it to duplicated object(s)
|
|
transformsOnly(to)
|
boolean
|
|
|
Duplicate only transform nodes and not any shapes.
|
|
upstreamNodes(un)
|
boolean
|
|
|
the upstream nodes leading upto the selected nodes
(along with their connections) are also duplicated.
|
|
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 have multiple arguments, passed either as a tuple or a list.
|
import maya.cmds as cmds
# Create a hierarchy of two spheres;
cmds.sphere( n='sphere1' )
cmds.move( 3, 0, 0 )
cmds.sphere( n='sphere2' )
cmds.move( -3, 0, 0 )
cmds.group( 'sphere1', 'sphere2', n='group1' )
cmds.circle( n='circle1' )
# Create a duplicate of the group
cmds.duplicate( 'group1' )
# Result: group2 sphere1 sphere2 #
cmds.undo()
cmds.duplicate( 'group1', rr=True )
# Result: group2 #
# Create a row of 4 circles equally spaced using
# the -smartTransform flag.
cmds.duplicate( 'circle1' )
cmds.move( 3, 0, 0 )
cmds.duplicate( st=True )
cmds.duplicate( st=True )
# 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.
#
cmds.duplicate( 'group1|sphere1', ic=True )
cmds.move( 0, 0, 0 )
cmds.setAttr( 'makeNurbSphere1.radius', 2 )
# Duplicate selected objects along with their upstream nodes
# and connections. This will duplicate the history.
cmds.select( 'group1|sphere2' )
cmds.duplicate( un=True )