Website Youtube GitHub

mGear Framework Forum

How to use SpaceTransfer without UI

Hello

After baked motion caputuer data to mGear rig, I tried to use SpaceTransfer without UI.
I wrote script like below and excused.

from mgear.synoptic import utils
import pymel.core as pm

model = pm.PyNode(':rig')
ikfk_attr = 'arm_blend'
uihost = 'armUI_L0_ctl'
fks = ['arm_L0_fk0_ctl', 'arm_L0_fk1_ctl', 'arm_L0_fk2_ctl']
ik = 'arm_L0_ik_ctl'
upv = 'arm_L0_upv_ctl'

trans = utils.IkFkTransfer()
trans.execute(model,ikfk_attr,uihost,fks,ik,upv,ikRot='arm_L0_ikRot_ctl',switchTo='ik')

It seemd worked, but result was different from created by UI.
‘arm_L0_ikRot_ctl’ was not baked.

I investigated mgear/synoptic/utils.py
In utils line 1556

ui.transfer(startFrame, endFrame, onlyKeyframes, ikRot, switchTo="fk")

I thought ‘switchTo=“fk”’ may overwite my script’s ‘switchTo=‘ik’’.
So I changed ‘fk’ to ‘ik’, then it worked and I got the same result to UI.

Is it correct??

Hi @yohei ,

O.o, that should be ui.transfer(startFrame, endFrame, onlyKeyframes, ikRot, switchTo=switchTo).
I think there around here are lot of space to refactor and it seems the development going on. It is reasonable to move these features to respective shifter components.

2 Likes

Thank you @yamahigashi.

I reliefed to know changing that line is not wrong.
How about change like this?

ui.transfer(startFrame, endFrame, onlyKeyframes, ikRot, switchTo)

Hi @yohei an @yamahigashi
For debugging and testing this spaceswitching-script without ui is very handy. I assume you run it from the script editor or the shelf.
When I try to execute your script (modified for my controls) it gives within Maya a ‘syntax error’, without specification what is wrong. Not very strong in Python myself I do see that your formatting above might have been lost. Could you guys help me out how to invoke the spacetransfer UI window with a script-command?

Hello @mackerB
This script will call spacetransfer.

from mgear.synoptic import utils
import pymel.core as pm

model = pm.PyNode(':rig')
ikfk_attr = 'arm_blend'
uihost = 'armUI_L0_ctl'
fks = ['arm_L0_fk0_ctl', 'arm_L0_fk1_ctl', 'arm_L0_fk2_ctl']
ik = 'arm_L0_ik_ctl'
upv = 'arm_L0_upv_ctl'
ikRot = 'arm_L0_ikRot_ctl'

trans = utils.IkFkTransfer()
trans.showUI(model, ikfk_attr, uihost, fks, ik, upv, ikRot)

If you do not need ikRot, set None.

I have interesting your error.
Could you tell me your modified script?

Hi @yohei

Thank you. I altered it for the leg and indeed I still get the error:


Is my formatting maybe wrong?

from mgear.synoptic import utils
import pymel.core as pm
model = pm.PyNode(’:rig’)
ikfk_attr = ‘leg_blend’
uihost = ‘legUI_L0_ctl’
fks = [‘leg_L0_fk0_ctl’, ‘leg_L0_fk1_ctl’, ‘leg_L0_fk2_ctl’]
ik = ‘leg_L0_ik_ctl’
upv = ‘leg_L0_upv_ctl’
ikRot = None
trans = utils.IkFkTransfer()
trans.showUI(model, ikfk_attr, uihost, fks, ik, upv, ikRot)

Thank you @mackerB

I copied and pasted your script to my script editor.
image
All arguments which should be string are not string.
I changed " ‘ " and " ’ " to " ’ ".
image
Arguments turned yellow, then it works.

I am sorry. When I pasted my scripts on the forum, the marks(how do you say in English) are automatically changed.

Does anyone know how to past scrips or code here accurately?

There is indeed a formatting issue at hand, it seems… Strange that this gets lost this way, but great to see there is a method to fix it. Also I was searching how to insert code-snippets the proper way. Did not find that (yet).
Thanks anyway!

Everyone in this thread, you can format code using backticks. You are getting syntax errors because copying from this forum is adding “smart quotes”.

image

You can also use code tags like this:

[code]
Your Python code here.
[/code]
2 Likes

Cheers, Chris! That is handy

1 Like

Thank you so much @chrislesage

1 Like