Thanks for sharing!
On 15 April 2016 at 19:18, Paxton <[email protected]> wrote:
> Ok, I figured it out..
> You need to create a 2d transform (with surface as parent)
>
> heres how:
>
> import maya.OpenMaya as om
>
> #transform!
> t = om.MFnDagNode().create('transform', 'i_am_a_3d_thing')
>
> #Plane!
> point_array = om.MPointArray()
> point_array.append(om.MPoint(*[-1.0,0.0,-1.0]))
> point_array.append(om.MPoint(*[1.0,0.0,-1.0]))
> point_array.append(om.MPoint(*[-1.0,0.0,1.0]))
> point_array.append(om.MPoint(*[1.0,0.0,1.0]))
>
> knot_aray_u = om.MDoubleArray()
> knot_aray_u.append(0)
> knot_aray_u.append(1)
> knot_aray_v = om.MDoubleArray()
> knot_aray_v.append(0)
> knot_aray_v.append(1)
> degree_u = 1
> degree_v = 1
> form_u = 1
> form_v = 1
> rational = False
>
> s = om.MFnNurbsSurface().create(point_array, knot_aray_u, knot_aray_v,
> degree_u, degree_v, form_u, form_v, rational, t)
>
>
> #Curve!
>
> point_array = om.MPointArray()
> point_array.append(om.MPoint(*[0.0, 0.0]))
> point_array.append(om.MPoint(*[1.0, 1.0]))
>
> knot_aray = om.MDoubleArray()
> knot_aray.append(0)
> knot_aray.append(1)
>
>
> #2d Transform!
> t2 = om.MFnDagNode().create('transform', 'i_am_a_2d_thing', s)
>
>
>
> curve = om.MFnNurbsCurve().create(point_array, knot_aray, degree_u,
> form_u, True, False, t2)
>
> On Thursday, 14 April 2016 23:14:58 UTC-7, Paxton wrote:
>>
>> Hey Guys, I am updating my rigging modules so that all (or most) of the
>> "maya.cmds" are replaced with "maya.OpenMaya" functions.
>>
>> So far so good...
>>
>> Though I find myself stuck on 2d nurbsCurves
>>
>> All of my bendyArms, Muscles and faces involve using the command
>> "DuplicateSurfaceCurve"
>> <https://knowledge.autodesk.com/support/maya-lt/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/MayaLT/files/Edit-Curves--Duplicate-Surface-Curves-htm.html>
>> to
>> create curves that live permanently within the 2d space of a nurbs surface
>> This has worked wonderfully up until now, but I would really like to
>> learn how to build 2d "surface space" curves without resorting to the
>> maya.cmds module..
>>
>> Heres is my exploration of this topic un until now..
>>
>>
>> import maya.OpenMaya as om
>>
>> #transform!
>> t = om.MFnDagNode().create('transform', 'i_am_a_thing')
>>
>> #Plane!
>> point_array = om.MPointArray()
>> point_array.append(om.MPoint(*[-1.0,0.0,-1.0]))
>> point_array.append(om.MPoint(*[1.0,0.0,-1.0]))
>> point_array.append(om.MPoint(*[-1.0,0.0,1.0]))
>> point_array.append(om.MPoint(*[1.0,0.0,1.0]))
>>
>> knot_aray_u = om.MDoubleArray()
>> knot_aray_u.append(0)
>> knot_aray_u.append(1)
>> knot_aray_v = om.MDoubleArray()
>> knot_aray_v.append(0)
>> knot_aray_v.append(1)
>> degree_u = 1
>> degree_v = 1
>> form_u = 1
>> form_v = 1
>> rational = False
>>
>> s = om.MFnNurbsSurface().create(point_array, knot_aray_u, knot_aray_v,
>> degree_u, degree_v, form_u, form_v, rational, t)
>>
>>
>> #Curve!
>>
>> point_array = om.MPointArray()
>> point_array.append(om.MPoint(*[0.0, 1.0]))
>> point_array.append(om.MPoint(*[1.0, 1.0]))
>>
>> knot_aray = om.MDoubleArray()
>> knot_aray.append(0)
>> knot_aray.append(1)
>>
>> #Next line is where problems happen.
>> #I assume I should pass the MObject of the shape node as the parent
>> #and set "create2D" to True..
>> #Yet, no luck.... Parent seems to be invalid :(
>>
>> curve = om.MFnNurbsCurve().create(point_array, knot_aray, degree_u,
>> form_u, True, False, s)
>>
>> Any insight would be valuable as f*&%K
>> thanks,
>> -Paxton
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/f5444ad1-dd73-4349-a583-9feee66cdd5e%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/f5444ad1-dd73-4349-a583-9feee66cdd5e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
--
*Marcus Ottosson*
[email protected]
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCXfv5iSjET1%2Bq026wO%3Dnq7WQts8r9-6kFEaLtTJ0nDjA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.