예제 #1
0
def get_nurb_obj_knot_data_old(curve_obj=None):
    """
    get the knot information from nurbsCurves.
    Maya returns 2 knots less than it should.
    :param curve_obj: <OpenMaya.MObject> nurbsCurve object.
    :return: <tuple> array of curve knot data.
    """
    curve_fn = object_utils.get_fn(curve_obj)
    number_of_knots = curve_fn.numKnots()
    knots = ()

    # invent the first knot value for a clamped or periodic curve
    if curve_fn.knot(1) - curve_fn.knot(0) < 0.01:
        knots += curve_fn.knot(0),
    else:
        knots += curve_fn.knot(0) - 1,

    # write the rest of the knots
    for i in xrange(number_of_knots):
        knots += curve_fn.knot(i),

    # invent the last knot value
    if curve_fn.knot(1) - curve_fn.knot(0) < 0.01:
        knots += curve_fn.knot(number_of_knots - 1),
    else:
        knots += curve_fn.knot(number_of_knots - 1) + 1,
    return knots
예제 #2
0
def get_nurb_obj_curve_order(curve_obj=None):
    """
    get the curve information: degree.
    :param curve_obj: <OpenMaya.MObject> nurbsCurve object.
    :return: <int> form.
    """
    curve_fn = object_utils.get_fn(curve_obj)
    return curve_fn.degree() + 1
예제 #3
0
def get_nurb_obj_knot_data(curve_obj=None):
    """
    get the knot information from nurbsCurves.
    Maya returns 2 knots less than it should.
    :param curve_obj: <OpenMaya.MObject> nurbsCurve object.
    :return: <tuple> array of curve knot data.
    """
    curve_fn = object_utils.get_fn(curve_obj)
    knot_array = OpenMaya.MDoubleArray()
    curve_fn.getKnots(knot_array)
    return list(knot_array)
예제 #4
0
def get_nurb_obj_cv_data(curve_obj=None):
    """
    get all points associated with the nurbs curve.
    :param curve_obj: <OpenMaya.MObject> nurbsCurve object.
    :return: <tuple> array of curve CV's.
    """
    curve_fn = object_utils.get_fn(curve_obj)
    cvs = OpenMaya.MPointArray()
    curve_fn.getCVs(cvs)
    return_data = ()
    for i in range(cvs.length()):
        return_data += (i, cvs[i].x, cvs[i].y, cvs[i].z),
    return return_data
예제 #5
0
def get_nurb_obj_curve_form(curve_obj=None):
    """
    get the curve information: form.
    kOpen :: the curve end and start CVs do not meet.
    kClosed :: the curve end and start CVs meet but is not continuous.
    kPeriodic :: the end points of the CVs meet and continuity is maintained.
    :param curve_obj: <OpenMaya.MObject> nurbsCurve object.
    :return: <dict> {<int>: <str>}.
    """
    curve_fn = object_utils.get_fn(curve_obj)
    form_int = curve_fn.form()
    if form_int == 1:
        return {form_int: 'kOpen'}
    if form_int == 2:
        return {form_int: 'kClosed'}
    if form_int == 3:
        return {form_int: 'kPeriodic'}
예제 #6
0
def get_nurb_obj_edit_points(curve_obj=None):
    """
    gets the data on nurbs objects' edit points.
    :param curve_obj: <OpenMaya.MObject>
    :return: <tuple> edit point data.
    """
    curve_fn = object_utils.get_fn(curve_obj)
    knots = get_nurb_obj_knot_data(curve_obj)

    edit_pts_data = ()
    edit_pnt = OpenMaya.MPoint()
    for u in knots:
        try:
            curve_fn.getPointAtParam(u, edit_pnt, OpenMaya.MFn.kWorld)
            edit_pts_data += (edit_pnt.x, edit_pnt.y, edit_pnt.z),
        except RuntimeError:
            continue
    return edit_pts_data