Home Website Youtube GitHub

Space Switching for IK Legs

Hi everyone,

I’ve been using and loving mGear, super animator friendly rigs! Though couldn’t figure out something so I thought I’d try my chances here.

The attach controls are great for constraining the hands to objects and then the space switch drop down is a life saver as it matches the position but changes the space. I wanted to do the same for legs, but couldn’t figure out if there’s any solution for that. In synoptic, there’s only the IK Pos one which affects the hands.

Would anyone be able to help me out on this? Perhaps it’s running a single line of code which can be edited to fit the legs, but I couldn’t find the code either.

Thanks in advance,
Best
Aziz

1 Like

Anyone have any ideas as to how this could work? :pray::pray:

Anyone? No ideas? I’d really appreciate a solution as i feel like it would work since it does for the hand IK’s space switching.

Thank you

Hello @azizk

Sorry for the late reply I’ve been pretty offline lately.
Switches depends on what your guides have in the Ik Array table thingy. You need to take into consideration as well that the Synoptic picker if you are doing anything custom you might need to to it on your side (I mean the picker itself). Anyway here is a snip of code you can use for the IK/FK switch/snap and another for the space switching with snap.

IK/FK SWITCH with SNAP

from mgear.synoptic.utils import ikFkMatch

character_root = "rig_grp"
switch_control = "armUI_L0_ctl"
switch_attribute = "arm_L0_blend"
fk_conbtrols = ("arm_L0_fk0_ctl", "arm_L0_fk1_ctl", "arm_L0_fk2_ctl")
ik_control = "arm_L0_ik_ctl"
ik_upvector_control = "arm_L0_upv_ctl"

ikFkMatch(character_root,
          switch_attribute,
          switch_control,
          fk_conbtrols,
          ik_control,
          ik_upvector_control)

SPACE SWITCH with SNAP

from mgear.synoptic.utils import changeSpace

rig_root = "rig_C_001_GRUP"
switch_control = "armUI_L0_ctl" # the control that has the switch
switch_attribute = "arm_ikref" # the attribute to switch
switch_to = 2 # the index of where you want to go
ctl_name = "arm_L0_ik_ctl" # the controls to snap

changeSpace(rig_root, switch_control, switch_attribute, switch_to, ctl_name)

Try it out and let me know.

Cheers

7 Likes

Hi Jerome,

Thanks so much for taking the time to reply. It’s perfect, exactly what I needed & works very well.

Cheers,
Aziz

Hi @Jerome,

Thank you for posting those snippets. Super useful.

Is there a similar code to summon those handy space transfer windows that allow for IK/FK matching or space transfers along the entire timeline?

Thanks!

Gu

Hello @GuG

Sorry for the late reply.

What you are asking is a tiny bit more complex because the Class object that handles this relies on the Synoptic Picker BUT that been said it is still possible

from PySide2 import QtWidgets
from mgear.synoptic.utils import ParentSpaceTransfer


rig_root = "rig_C_001_GRUP"
switch_control = "armUI_L0_ctl" # the control that has the switch
switch_attribute = "arm_ikref" # the attribute to switch
ctl_name = "arm_L0_ik_ctl" # the controls to snap
combo_switch = QtWidgets.QComboBox()
[combo_switch.addItem(x) for x in cmds.addAttr("{}.{}"
 .format(switch_control, switch_attribute), query=True, enumName=True)
 .split(":")]
combo_switch.addItem("") 

transfer = ParentSpaceTransfer()
transfer.showUI(combo=combo_switch, model=rig_root, uihost=switch_control, switchedAttrShortName= switch_attribute, ctrl_name=ctl_name)

So becuase the ParentSpaceTransfer showUI method is expecting the QtWidget.QComboBox object you have to create a temp object what will contain this elements.

Cheers

1 Like

Thanks @Jerome.

Exactly what I needed.