Home Website Youtube GitHub

Curve.export_curve() method but for NURBS surfaces

I’m using this snippet to extract ctls from the facial rigger (brow, lips, eyes):

#### code to run in maya with controllers selected to export them
from mgear.core import curve
import pymel.core as pm
path = r"mypath\curve_shapes.crv"
curve.export_curve(path, pm.selected())

For rig design purposes I would like to use NURBS surfaces instead of NURBS curves but the snippet above is wrote to handle curves and not surfaces: is there a way to store NURBS surfaces in file ?

When I Extract Controls from body ctl there’s no problem because they are stored in the controller_buffer of the root guide but the workflow is different with the facial.

Well, I don’t know. I didn’t know about curve.export_curve.

But I can offer you an alternative, and this is what I do. I’ve never exported curves to a file. I extract the curves from my face rig into the controller_buffer group.

And then after rigging the lips and eyes, I run this script. It replaces the curves with the controllers_org version. And this works perfectly well with nurbsSurface shapes as well. This is basically what any Shifter component does when it searches controller_buffer for matching shapes. It just doesn’t do it automatically in the face rigging tools (yet).

Depending on your rig, you may have to adjust these lists of names.

import pymel.core as pm
from mgear import rigbits

### fix missing buffer controls for the face. It doesn't do it automatically!
### For any beginners reading this, {} is referring to string formatting. {} gets replaced later in the script.
eyeControls = [
lipControls = [
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])

for lipControl in lipControls:
    if pm.objExists(lipControl + '_controlBuffer'):
        oTarget = pm.PyNode(lipControl)
        oSource = pm.PyNode(lipControl + '_controlBuffer')
        rigbits.replaceShape(oSource, [oTarget])
1 Like