Last active
November 12, 2021 22:12
-
-
Save RedForty/99fb0a73687e7c2da6c7d093973ce7a7 to your computer and use it in GitHub Desktop.
Select Source of Constrained Object
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
# 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