Skip to content

Instantly share code, notes, and snippets.

@BigRoy
Created November 27, 2025 14:28
Show Gist options
  • Select an option

  • Save BigRoy/d398ee94f45ea1a53b896414a4108a4a to your computer and use it in GitHub Desktop.

Select an option

Save BigRoy/d398ee94f45ea1a53b896414a4108a4a to your computer and use it in GitHub Desktop.
Create duplicates of selected nodes, and for
# Create a copy of selection, parent it to root and connect the `worldMesh` of the source to the `inMesh` of the target.
from maya import cmds
selection = cmds.ls(selection=True, long=True)
duplicates = []
for node in selection:
# Create a duplicate
dup = cmds.duplicate(node, renameChildren=True)[0]
# Parent it to root just so it's easily available
if cmds.listRelatives(dup, parent=True):
dup = cmds.parent(dup, world=True)[0]
# Connect meshes
src_meshes = cmds.listRelatives(node, shapes=True, fullPath=True, noIntermediate=True, type="mesh") or []
tgt_meshes = cmds.listRelatives(dup, shapes=True, fullPath=True, noIntermediate=True, type="mesh") or []
for src, tgt in zip(src_meshes, tgt_meshes):
# Connect original `worldMesh[0]` to `inMesh`
cmds.connectAttr(src + ".worldMesh[0]", tgt + ".inMesh")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment