Home Website Youtube GitHub

Problem retargeting with HIK and Mgear mocap tools

I’m trying to automate the retargeting of mocap using maya HIK with mgear. It almost works except for when I try and set the current character with the hik tools:
from mgear.shifter import mocap_tools

#import fbx

#get start and end frames
start_frame = cmds.playbackOptions(q=1, min=1)
end_frame = cmds.playbackOptions(q=1, max=1)
zero_frame = start_frame-10

#set a tpose on the mocap source
for jnt in anim_jnts:
cmds.setAttr(‘MOCAP:%s.rotate’%jnt, 0,0,0,type=‘double3’)
cmds.setAttr(‘MOCAP:%s.translate’%anim_jnts[0], 0,0,0, type=‘double3’)

#make hik for mocap skeleton
set_HumanIK(‘Mocap_HIK’, hik_info)
hikSetSource(‘Mocap_HIK’, 1)

#set current character
hikSetSource(‘mGear_Mocap_interface’, 2)

When I run the above code I get the error “Item not found: mGear_Mocap_interface” at the ‘set current character’ line. If I step through and run the code one line at a time it works fine.
This must have something to do with ui not updating. I’m not sure how to solve this or if I’m going about this the wrong way. Ultimately I’d like to run a batch script that will export several retargeted fbx files at once. This is the only step that doesn’t work.

Any ideas?


First of all, please put your code between triple backticks like this, and we’ll be able to read it properly:


You can try the cmds.refresh() command to update the UI before running SetCurrentCharacter(), if that is actually the problem.