Skip to content

Instantly share code, notes, and snippets.

@RedForty
Last active November 12, 2021 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RedForty/99fb0a73687e7c2da6c7d093973ce7a7 to your computer and use it in GitHub Desktop.
Save RedForty/99fb0a73687e7c2da6c7d093973ce7a7 to your computer and use it in GitHub Desktop.
Select Source of Constrained Object
# Select source of selected constrained object
from maya import cmds
selection = cmds.ls(sl=1)
new_selection = []
for item in selection:
constraint = cmds.listConnections( item + '.parentInverseMatrix[0]', destination=1, source=0, type='constraint')
if constraint:
src = cmds.listConnections(constraint[0] + '.target[0].targetParentMatrix', destination=0, source=1)
if src:
new_selection.extend(src)
if new_selection:
cmds.select(new_selection)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment