Skip to content

Instantly share code, notes, and snippets.

@yamahigashi
Created May 12, 2020 12:52
Show Gist options
  • Save yamahigashi/afbaaeedf4cf2a111e2627b72a41a002 to your computer and use it in GitHub Desktop.
Save yamahigashi/afbaaeedf4cf2a111e2627b72a41a002 to your computer and use it in GitHub Desktop.
from maya import cmds
def __swap_selection_for_ikrot_job():
sel = cmds.ls(sl=True) or []
for i, s in enumerate(sel):
ctx = cmds.currentCtx()
new = None
if "move" in ctx.lower() and s.endswith("_ikRot_ctl"):
new = s.replace("_ikRot_ctl", "_ik_ctl")
if "rotate" in ctx.lower() and s.endswith("_ik_ctl"):
new = s.replace("_ik_ctl", "_ikRot_ctl")
if new and cmds.ls(new):
sel[i] = new
cmds.select(sel)
_ = cmds.scriptJob(event=("ToolChanged", __swap_selection_for_ikrot_job))
_ = cmds.scriptJob(event=("SelectionChanged", __swap_selection_for_ikrot_job))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment