Home Website Youtube GitHub

Extract facial rig controls

Hi there

I have been working through your data centric videos to make a rig and i am almost done but I have hit a speedbump which i try to extract the controls for the eyes and lips.

I have corrected the ctl shapes and extracted them into the controllers_org group, but they are not extracting in the same world space as the rig controllers. Then, when i rebuild from the guides, the controls just build in their default positions and ignore the extracted control positions.

I ran into the same problem! But instead of filing a bug, I just wrote a POST script to fix it.

I put each of these snippets after I import my eye rig and lip rig files.

import pymel.core as pm
from mgear import rigbits

### fix missing buffer controls. It doesn't do it automatically!
lipControls = [
    'lips_L_lowOuter_ctl',
    'lips_L_lowInner_ctl',
    'lips_C_lower_ctl',
    'lips_R_lowInner_ctl',
    'lips_R_lowOuter_ctl',
    'lips_L_corner_ctl',
    'lips_L_upOuter_ctl',
    'lips_L_upInner_ctl',
    'lips_C_upper_ctl',
    'lips_R_upInner_ctl',
    'lips_R_upOuter_ctl',
    'lips_R_corner_ctl',
    ]
for lipControl in lipControls:
    if pm.objExists(lipControl + '_controlBuffer'):
        oTarget = pm.PyNode(lipControl)
        oSource = pm.PyNode(lipControl + '_controlBuffer')
        rigbits.replaceShape(oSource, [oTarget])

# The {} is for string formatting the L and R sides.
eyeControls = [
    'eye_{}_aim_ctl',
    'eye_{}_inCorner_ctl',
    'eye_{}_lowInMid_ctl',
    'eye_{}_lowMid_ctl',
    'eye_{}_lowOutMid_ctl',
    'eye_{}_outCorner_ctl',
    'eye_{}_over_ctl',
    'eye_{}_upInMid_ctl',
    'eye_{}_upMid_ctl',
    'eye_{}_upOutMid_ctl',
    ]
for side in 'LR':
    for eyeControl in eyeControls:
        if pm.objExists(eyeControl.format(side) + '_controlBuffer'):
            oTarget = pm.PyNode(eyeControl.format(side))
            oSource = pm.PyNode(eyeControl.format(side) + '_controlBuffer')
            rigbits.replaceShape(oSource, [oTarget])
5 Likes

Hello

yep that is how it works.
The reason for that is that is that the ctl update is done before the post custom steps are executed.

TIP: If you export the guide as a template and build from file. This will work, because the controls shapes are updated at the end. so will take in account the controls created in custom steps

Long explanation: The initial design was expecting that the control buffer already exist in the scene before create the component. So the component can pick the right shape at build time.
When the guide is exported because the control shape buffer doesn’t exist in the scene it will import all controls shapes at the end of all the custom steps.
I should have updated the old logic to do the same. but I didn’t because was not a priority and invested the time in other areas :stuck_out_tongue:

I hope this helps :wink:

Cheers for both your help, works perfectly :grin:

I tried to run this post script. It listed as successful in the log, but it didn’t apply the extracted shapes.
Any chance you can understand why?

Here’s the workflow I used:
After creating the face controls, I adjust them and extract them to controllers_org, in the usual way.
I see them there!
I added the above post script as is to the post steps, after the facial rig script and before the skin pack script.
I exported the guide template.
Open a new scene.
Import guides from template. Select guide.
When I take a look inside the controllers_org, I don’t see the face rig’s controlBuffer shapes there!
Build from selection.
Eventually everything builds but the face controls don’t get they’re adjusted shapes.

*** UPDATE ***
If I export the face control buffers manually to another file, then import them to a file with the guides, and place them under controllers_org, then the script works and builds them with the correct shapes.


Why don’t the face controlBuffer shapes get imported with the guide template? Do I need to export and save them separately?

Thanks.

I exported the guide template.

I’ve never exported any guide templates, so no sorry I don’t know anything about this. It sounds like maybe the shapes are not exporting to the template properly? (Rather than the problem being importing.)

That makes sense. But I don’t know how to fix it, other than adding them manually.
I could try to come up with a script the imports them and parents them under controllers_org.
I’m assuming parenting can be done simply through the Python script…