Home Website Youtube GitHub

How to apply FK/IK match?

Hi again Miquel

Another simple question for you. How does the animator apply FK/IK match. I only see FK/IK blend under the arm and leg controls.

Thanks
Gavin

is in the synoptic view :wink:

Is it? I don’t see it. Excuse my ignorance but this is my first time animating an mGear character rig, and it’s the first time my colleague rigged in mGear (and in a rush), so everything is new, and things have possibly not been set up correctly?

If it’s the buttons “IK/FK Arm left” etc, then when I left click these
Can’t find object : arm_L0_fk0_mth
Can’t find object : arm_L0_fk1_mth
Can’t find object : arm_L0_fk2_mth
Can’t find object : arm_L0_ik_mth
Can’t find object : arm_L0_upv_mth
Can’t find object : arm_L0_ikRot_mth
// Error: root : Uncaught exception
Traceback (most recent call last):
File “C:\Users\gavinm\Documents\maya\2017\modules\scripts\mgear\maya\synoptic\widgets.py”, line 121, in mousePressEvent
utils.ikFkMatch(model, ikfk_attr, uiHost_name, fks, ik, upv, ikRot)
File “C:\Users\gavinm\Documents\maya\2017\modules\scripts\mgear\maya\synoptic\utils.py”, line 600, in ikFkMatch
transform.matchWorldTransform(ikTarget, ikCtrl)
File “C:\Users\gavinm\Documents\maya\2017\modules\scripts\mgear\maya\transform.py”, line 537, in matchWorldTransform
sWM = source.getMatrix(worldSpace=True)
AttributeError: ‘NoneType’ object has no attribute ‘getMatrix’ //

Looks like the rig is missing the nodes to help match the IK FK. Or can’t find it for some reason

Hard to say without checking the rig.

Check if rig have objects with the _mth suffix

I hope this helps

Hello, Miquel.

I have the same issue with ik/fk match. It does not work only when i build rig with check-box “IK separated Trans and Rot ctl” in arm`s module settings is disabled.

I get this in script editor:

Can’t find object : arm_L0_ikRot_ctl
Can’t find object : arm_L0_ikRot_mth
# Traceback (most recent call last):
# File “C:\mgear\scripts\mgear\maya\synoptic\widgets.py”, line 121, in mousePressEvent
# utils.ikFkMatch(model, ikfk_attr, uiHost_name, fks, ik, upv, ikRot)
# File “C:\mgear\scripts\mgear\maya\synoptic\utils.py”, line 665, in ikFkMatch
# transform.matchWorldTransform(ikRotTarget, ikRotNode)
# File “C:\mgear\scripts\mgear\maya\transform.py”, line 537, in matchWorldTransform
# sWM = source.getMatrix(worldSpace=True)
# AttributeError: ‘NoneType’ object has no attribute 'getMatrix’

Thanks

@Vasilii Sorry for the late reply.

yes the default configuration is for separated Trans and rotation controls.

You need to edit the template with qtdesigner and recompile again the .ui file

Just change the ikRot Value to None.

here is also a capture in from the python modules synoptic/widgets.py

sorry for the lack of documentation in this area.
I hope it helps. Please let me know if you need more help

cheers,
Miquel

a quick workaround for this is also to navigate to the fk hand controller and under it you can duplicate the _ref group twice and rename it to the missing _mth and _ctl for each side.
then it works again.

with a bit af python knowledge, the mgear code could br modified so it can be implemented on creation time…

2 Likes

Thanks @Miquel !
Everything works fine.

@soulcage thank you for your quick workaround. Its very usefull.

Hi @Miquel.

First of all, Happy 2019!

I’m having a similar issue. I’m getting the following error when using the Synoptic to transfer the animation from FK to IK (and vice versa):
# Traceback (most recent call last):
# File “V:\Maya_Animation_Tools\scripts\mGear\release\scripts\mgear\maya\synoptic\utils.py”, line 1084, in doItByUI
# self.transfer(startFrame, endFrame, onlyKeyframes, self.hasIkRot)
# File “V:\Maya_Animation_Tools\scripts\mGear\release\scripts\mgear\maya\synoptic\utils.py”, line 1067, in transfer
# pm.cutKey(roll_att, time=(startFrame, endFrame))
# File “C:\Program Files\Autodesk\Maya2016\Python\lib\site-packages\pymel\internal\factories.py”, line 945, in newFuncWithTimeRangeFlags
# return beforeTimeRangeFunc(*args, **kwargs)
# File “C:\Program Files\Autodesk\Maya2016\Python\lib\site-packages\pymel\internal\pmcmds.py”, line 139, in wrappedCmd
# raise pymel.core.general._objectError(obj)
# pymel.core.general.MayaAttributeError: Maya Attribute does not exist (or is not unique):: u’FootBallPlayer_Rig_v001:armUI_L0_ctl.arm_roll’

I have taken over the rig from the previous guy that was working at this studio and it seems like the way he set the rig up was to have all the arm UI attributes be on a different controller. For the left arm it can be located on a controller named FootBallPlayer_Rig_v001:shoulder_L0_ctl
They use mGear 2.2.1 and I don’t want to rock the boat halfway through a production by trying to upgrade to 2.6.1. Any ideas as to what I can do to fix this issue? The animators are referencing the rig into their scenes so it would be a matter of fixing the rig once and everyone SHOULD be happy. :joy:

I noticed in the Synoptic view that there’s a section below the IK/FK switching buttons for specifying the shoulder, IK Pos and UpV Pos. Those values stays blank, and I’m assuming that it is part of the problem.

Thanks in advance.

Hi @FMaree

the error is complaining about u’FootBallPlayer_Rig_v001:armUI_L0_ctl.arm_roll’ like if it is not in the scene or duplicated name.
if the attributes are in other control you need to edit the synoptic and compile it again like in the other image

Also this video may help: https://youtu.be/EOiQ5lY1PPY

the menu will update when you pass the mouse over, that was a limitation on how the UI is loaded. is not any issue

Cheers,
Miquel

Hi @Miquel

Apologies for only getting back to you now. I’ve been swamped with other higher priority stuff.

Thank you very much! This worked like a charm on mGear 2.2.1! :tada:

I noticed that mGear version 3 is now out. Will this sort of issue be solved in that version? If so I’ll be looking at making the transition as soon as we’re done with this project.

Wow, didnt know you could fk/ik switch so seamlessly. NICE! Mgear really is awesome.

Just wanted to mention that the technology that does the snapping is available as well outside the picker itself. The picker is just an UI calling the snapping code. Here is an example of how you can do the Ik/Fk snap on a specific control. You can of course do you own Picker or UI for this.

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)

2 Likes

I didn’t want to make a new thread for this, thought I could continue on from here.

Problem: mgear FK IK Matching does not respect the scale attribute that builds on the UI host. If the scale is anything other than 1.0 the FK does not match the IK correctly.

@Miquel is there a work around solution for this. We are currently stranded on mGear 3.0.4 so not sure if this has been solved in future mGear versions?

sorry for digging out old thread again.

I got namespace problem using ikFkMatch function.
The ikFkMatch code runs fine if the rig contains no namespace.

Here is my code: (sorry for my little knowledge about python)


from mgear.synoptic.utils import ikFkMatch

#get the namespace of current picker file.
import maya.mel as mel
Namespace = mel.eval('MGP_GetCurrentPickerNamespace') 

character_root = Namespace + ":" + "rig"
switch_control = Namespace + ":" + "armUI_R0_ctl"
switch_attribute = Namespace + ":" + "arm_R0_blend"
ik_control = Namespace + ":" + "arm_R0_ik_ctl"
ik_upvector_control = Namespace + ":" + "arm_R0_upv_ctl"
fk_controls = (Namespace + ":" + "arm_R0_fk0_ctl", Namespace + ":" + 
"arm_R0_fk1_ctl", Namespace + ":" + "arm_R0_fk2_ctl")

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

And the error message in script editor:

Can’t find object : test:arm_R0_fk0_ctl
Can’t find object : test:arm_R0_fk1_ctl
Can’t find object : test:arm_R0_fk2_ctl
Can’t find object : test:arm_R0_fk0_mth
Can’t find object : test:arm_R0_fk1_mth
Can’t find object : test:arm_R0_fk2_mth
Can’t find object : test:arm_R0_ik_ctl
Can’t find object : test:arm_R0_ik_mth
Can’t find object : test:arm_R0_upv_ctl
Can’t find object : test:arm_R0_upv_mth
Can’t find object : test:armUI_R0_ctl

Error: AttributeError: file D:\Software\CG\Maya\scripts_plugins\mgear_3.2\scripts\mgear\synoptic\utils.py line 649: ‘NoneType’ object has no attribute ‘attr’

Objects that can’t be found when executing the function actually exist in scene.

Thanks in advanced!

Hi @Arthur.C

Try this

from mgear.synoptic.utils import ikFkMatch

#get the namespace of current picker file.
import maya.mel as mel
Namespace = mel.eval('MGP_GetCurrentPickerNamespace') 

character_root = Namespace + ":" + "rig"
switch_control = "armUI_R0_ctl"
switch_attribute = "arm_R0_blend"
ik_control = "arm_R0_ik_ctl"
ik_upvector_control = "arm_R0_upv_ctl"
fk_controls = ("arm_R0_fk0_ctl", "arm_R0_fk1_ctl", "arm_R0_fk2_ctl")

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

Normally just character_root (model argument on the utils.py) needs to have the namespace. From that string the function cast the namespace to the others.
Let me know.

Cheers

2 Likes

Hi @Jerome,
It worked. You save my day . Thanks!

Arthur