Home Website Youtube GitHub

mgear_curveCns connect the curve, the curve will disappear

My English is poor, I hope these translations are correct.
Call the mgear_curveCns node, connect the curve, the curve disappears, the value of the curve will become 0, if I don’t want this, do I need to have additional settings?

are you connecting it manually?
Check these functions from the curve.py module from mgear.core

def addCnsCurve(parent, name, centers, degree=1):
    """Create a curve attached to given centers. One point per center

        parent (dagNode): Parent object.
        name (str): Name
        centers (list of dagNode): Object that will drive the curve.
        degree (int): 1 for linear curve, 3 for Cubic.

        dagNode: The newly created curve.
    # rebuild list to avoid input list modification
    centers = centers[:]
    if degree == 3:
        if len(centers) == 2:
            centers.insert(0, centers[0])
        elif len(centers) == 3:

    points = [datatypes.Vector() for center in centers]

    node = addCurve(parent, name, points, False, degree)

    applyop.gear_curvecns_op(node, centers)

    return node

def addCurve(parent,
    """Create a NurbsCurve with a single subcurve.

        parent (dagNode): Parent object.
        name (str): Name
        positions (list of float): points of the curve in a one dimension array
            [point0X, point0Y, point0Z, 1, point1X, point1Y, point1Z, 1, ...].
        close (bool): True to close the curve.
        degree (bool): 1 for linear curve, 3 for Cubic.
        m (matrix): Global transform.

        dagNode: The newly created curve.
    if close:
        knots = range(len(points) + degree - 1)
        node = pm.curve(n=name, d=degree, p=points, per=close, k=knots)
        node = pm.curve(n=name, d=degree, p=points)

    if m is not None:

    if parent is not None:

    return node
1 Like

Yes, I connected manually. I want to use this mgear_curveCns node alone, or what method can be used to replace this node?

If you want to do it manually and make your own curve and controllers, this is the function that will need to be run:

import mgear
import pymel.core as pm
mgear.core.applyop.gear_curvecns_op(node, centers)

node is the curve. If you already have the curve, you can do:
node = pm.PyNode('Your_Curve')

centers is the list of PyNode objects that will be the controllers for the curve. If they already exist, then you can use pm.ls('obj1', 'obj2', 'obj3', 'obj4') for example.

If you do it manually, the number of CVs and the number of controllers will need to match.

Connecting the node manually does not seem to work. Something in the mgear_curveCns seems to need to be updated by the function. As far as I can tell.

And you can use the function Miquel showed above, and it will automatically create the curve for you.

mgear.core.curve.addCnsCurve(parent, name, centers, degree=1)

parent = the group that the curve will be parented under. Use None for no parent.
name = the name of the curve that gets created.
centers = the list of PyNode controllers to use.
degree = the degree of the curve that gets created. 1 = linear. 3 = cubic.

import pymel.core as pm
import mgear

# First you list the controls you want to use, in whatever way you want.
# For example, this will use all the locators in the scene:
controllers = pm.ls('locator*', type='transform')

# Create the curve and the constraint:
mgear.core.curve.addCnsCurve(None, 'testName', controllers, degree=3)

Thank you very much for the help of @miquel and @chrislesage, it can be used normally now