Created
November 27, 2025 14:28
-
-
Save BigRoy/d398ee94f45ea1a53b896414a4108a4a to your computer and use it in GitHub Desktop.
Create duplicates of selected nodes, and for
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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