Home Website Youtube GitHub

Ik/fk matching not working

The ik/fk matching of both the arms & the spine is not working for me. At first I thought this was due to the synoptic not being updated anymore. So went and used the default animpicker, still no joy.

the error I get when trying it with arms is:

*Can’t find object : arm_L0_ikRot_ctl
*Can’t find object : arm_L0_ikRot_ctl
*# Traceback (most recent call last):
*# File “C:\Users\egohe\Documents\maya\modules\scripts\mgear\synoptic\widgets.py”, line 123, in mousePressEvent
*# utils.ikFkMatch(model, ikfk_attr, uiHost_name, fks, ik, upv, ikRot)
*# File “C:\Users\egohe\Documents\maya\modules\scripts\mgear\core\anim_utils.py”, line 1086, in ikFkMatch
*# ikFkMatch_with_namespace(
*# File “C:\Users\egohe\Documents\maya\modules\scripts\mgear\core\anim_utils.py”, line 943, in ikFkMatch_with_namespace
*# ik_rot_target = _get_mth(ik_rot)
*# File “C:\Users\egohe\Documents\maya\modules\scripts\mgear\core\anim_utils.py”, line 925, in _get_mth
*# if node.hasAttr(“match_ref”):
*# AttributeError: ‘NoneType’ object has no attribute ‘hasAttr’

When trying to match the spine I get:

# File “C:\Users\egohe\Documents\maya\modules\scripts\mgear\core\anim_utils.py”, line 2197, in doItByUI
# self.bakeAnimation(
# File “C:\Users\egohe\Documents\maya\modules\scripts\mgear\core\utils.py”, line 214, in wrap
# raise e
# File “C:\Users\egohe\Documents\maya\modules\scripts\mgear\core\utils.py”, line 211, in wrap
*# return func(*args, *kwargs)
# File “C:\Users\egohe\Documents\maya\modules\scripts\mgear\core\utils.py”, line 191, in wrap
# raise e
# File “C:\Users\egohe\Documents\maya\modules\scripts\mgear\core\utils.py”, line 188, in wrap
*# return func(*args, *kwargs)
# File “C:\Users\egohe\Documents\maya\modules\scripts\mgear\core\anim_utils.py”, line 2308, in bakeAnimation
# set(pm.keyframe(allAnimNodes, at=[“t”, “r”, “s”], q=True))
# File “C:\Program Files\Autodesk\Maya2023\Python\lib\site-packages\pymel\core\animation.py”, line 633, in keyframe
*# res = _keyframe(*args, *kwargs)
# File “C:\Program Files\Autodesk\Maya2023\Python\lib\site-packages\pymel\core\animation.py”, line 56, in keyframe
*# res = _util.listForNone(cmds.keyframe(*args, *kwargs))
# File “C:\Program Files\Autodesk\Maya2023\Python\lib\site-packages\pymel\internal\pmcmds.py”, line 224, in keyframe_wrapped
# raise pymel.core.general._objectError(obj)
# pymel.core.general.MayaNodeError: Maya Node does not exist (or is not unique):: ‘spine_C0_fk4_ctl’

I’m guessing perhaps this is something I’m doing wrong in the component setup? Worth noting that if I try with the biped template file, the arm match works but the spine still has the same issue. This is the same story when using the anim picker (biped picker template file).

Any help would be HUGE as it’s a real blocker at the mo for finalising my rig.

For the arms, you turned off separated rot/trans right? And the error is saying it can’t find “arm_L0_ikRot_ctl”.

The Anim Picker template is just an example that is designed to work with the biped template. They are examples to get you started creating your own Picker. You have to edit the scripts to fit your own rig. The scripts for the spines and arms are hard-coded with control names.

  • You can edit the script to remove the reference to the Rot control.
  • In the mGear menu make sure “mGear Viewport Menu” is turned on. You can try to use the right-click menu to do your space-switching, instead of the Picker. Those right-click scripts should actually work with the component you choose, because they get the names from attributes stored on the host. And if they don’t work, that should be reported as a bug. (Room for improvement: The Picker scripts could be improved to be dynamic too.)
  • And a hack workaround for the arms, is you could just add that node. Just make an empty transform, and call it arm_L0_ikRot_ctl and arm_R0_ikRot_ctl, and parent it somewhere similar in the hand hierarchy. The script will interact with it, but the animators will never touch it.

For the spine, did you make modifications to the spine? Again, the picker template is a template. So if you change the names of the controls, or change the component, or the number of divisions, you’ll likely have to edit the script to include the names of your rig.

separated rot/trans is off & that’s the error yeah.

Thanks for the info regarding the anim picker. I should aim to learn more about them & make my own for this rig but it’s a time investment I don’t have at the mo, and so annoying when the synoptic literally does 99% of what I need already.

I have the viewport menu already on. Space switching on the arms works fine there so that may be the solution in the short term. Agreed on dynamic scripts as it would be nicer if the match was on the wrist control instead of the host ui.

As for the spine, yes I made changes here & so now I know why I’m having trouble :slight_smile:
Any reason why the spine matching doesn’t exist on the spine UI, like arm matching ? If everything was available from the r/click menu I’d be sorted.

Also, are there any vids or guides on learning the ins & outs of the anim picker? Seems a bit trial by fire at the moment. I’m assuming the action scripts are in python ? Might have to put my low level MEL knowledge to one side & learn some python if I get some downtime :slight_smile:

looking at the spine…
I had removed an fk control, that’s about it. So the controls are just:

spine_C0_fk0_ctl
spine_C0_fk1_ctl
spine_C0_fk2_ctl
spine_C0_fk3_ctl
spine_C0_ik0_ctl
spine_C0_ik1_ctl
spine_C0_spinePosition_ctl
spine_C0_tan0_ctl
spine_C0_tan_ctl
spine_C0_tan1_ctl

Editing the anim picker, I have removed the 5th control from the selection in the action script (for spine matching)

so the action script looks like this:

from mgear.anim_picker.handlers import action_handlers

if not INIT:

  • fkControls = [“spine_C0_fk0_ctl”, “spine_C0_fk1_ctl”, “spine_C0_fk2_ctl”, “spine_C0_fk3_ctl”]*
  • ikControls = [“spine_C0_ik0_ctl”, “spine_C0_ik1_ctl”, “spine_C0_spinePosition_ctl”, “spine_C0_tan0_ctl”, “spine_C0_tan_ctl”, “spine_C0_tan1_ctl”]*
  • action_handlers.spine_ik_fk_transfer(NAMESPACE, fkControls, ikControls)*

I now get this error when running:

#   File "C:\Users\egohe\Documents\maya\modules\scripts\mgear\core\anim_utils.py", line 2197, in doItByUI*
#     self.bakeAnimation(*
#   File "C:\Users\egohe\Documents\maya\modules\scripts\mgear\core\utils.py", line 214, in wrap*
#     raise e*
#   File "C:\Users\egohe\Documents\maya\modules\scripts\mgear\core\utils.py", line 211, in wrap*
#     return func(*args, **kwargs)*
#   File "C:\Users\egohe\Documents\maya\modules\scripts\mgear\core\utils.py", line 191, in wrap*
#     raise e*
#   File "C:\Users\egohe\Documents\maya\modules\scripts\mgear\core\utils.py", line 188, in wrap*
#     return func(*args, **kwargs)*
#   File "C:\Users\egohe\Documents\maya\modules\scripts\mgear\core\anim_utils.py", line 2329, in bakeAnimation*
#     for frame, matchDict in matchMatrix_dict.iteritems():*
# AttributeError: 'dict' object has no attribute 'iteritems'*

I’m well out of my depth to understand the error though.

Surround your code with triple backticks, so it pastes properly. ```

And put the backticks before you paste. This got auto-formatted, so it’s very hard to spot any problems.

Although the error might be a Python 2 vs 3 problem.

What version of mGear? What version of Maya?

It looks like anim_utils.py will have to be updated to use dict.items() instead of dict.iteritems()

If you are feeling brave,

  • Close Maya.
  • open up the script C:\Users\egohe\Documents\maya\modules\scripts\mgear\core\anim_utils.py
  • Go to line 2329, near the bottom.
  • Change matchMatrix_dict.iteritems() to matchMatrix_dict.items()
  • Relaunch Maya and that one particular error should be solved. There may be more.

mgear/core/utils.py already has a check for which version. It’s just in anim_utils.py

I’ve opened an issue here: https://github.com/mgear-dev/mgear4/issues/203

1 Like

thanks, will do :slight_smile:
I’m on Maya 2023, mGear 4.0.9.

Yeah. on a quick search online I did see reference of dict.items() but wasn’t sure what file it would be stored in.

sweet, updating the anim_utils.py file worked a treat !

Guess I’ll have to either setup an anim picker in future or just use it for spine matching situations.

Would be great if it was just in the r click menu like the arms & leg though.

Thankyou for raising the error. Would not have done so myself as my issues are usually an error on my part.

Yeah that would be good to have it on the spine menu. I use spine_ik_01 which doesn’t have any switch. The FK control is always just available, layered.

1 Like

ah ok, that makes sense.

It’s been a while since the initial setup, but I think I went with spine_ik_02 instead was because it gives me an fk control for every joint in the spine. I also got better retargeting results with mocap by mapping it to the fk spine controls instead of just hooking up the top ik control & letting human ik try to figure it out.

1 Like