ep curves, why parameterisation is different when i draw manually?

449 views
Skip to first unread message

s...@weacceptyou.com

unread,
Dec 2, 2015, 7:56:08 PM12/2/15
to Python Programming for Autodesk Maya
Hi, this is my last question about curve parameterisation so dont worry

i have this line in python that creates an ep curve:

cmds.curve(d=3,n='curve11', ep=[posList[0],posList[1],posList[2],posList[3],posList[4],posList[5]])

this creates a curve of 6 edit points of degree 3, which is what i want. When you right click the curve and go to curve point and then drag between any of the points, you will get a parameteristion that is the chord length of the curve, rather than 0 to 1, 1 to 2, 2 to 3 between each edit point.

in the past i have been using rebuild curve to correct the parameterisation afterwards,

but then recently i just created an ep curve by hand in maya manually, and the parameterisation is uniform 0 to 1, 1 to 2 between points like i wanted all along.

i checked the options of the ep curve tool in maya and it had a 'uniform' knot spacing option checked. however in python cmds there is not a flag for knot spacing to make the curve uniform.

Does anyone know how to select this 'uniform' option for the ep curve command in python?
because this will solve all my problems,

thanks,
Sam

Justin Israel

unread,
Dec 3, 2015, 12:04:55 AM12/3/15
to Python Programming for Autodesk Maya
Someone can probably give a more correct answer than me, but it seems to me that even when you use the EP curve tool, it still calls the curve command using points and knots. And if you want to run the curve command with edit points, then maybe you can just rebuild it right afterwards?

Something like... ?
deg = 3
pointsList = [...]
c = cmds.curve(d=deg, n='curve11', ep=pointsList)
cmds.rebuildCurve(c, d=deg, s=len(pointsList)-1, kr=2, kcp=True, rpo=True)

Justin


--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/b98e39f5-d5e2-4e94-80e7-98a8ae747d7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

s...@weacceptyou.com

unread,
Dec 3, 2015, 5:13:42 AM12/3/15
to Python Programming for Autodesk Maya
thanks Justin, this would be ok. its just the problem with the rebuild curve thing is the problem i had at the beginning, the points shift their position slightly when the curve is rebuilt.

I dont get it that there is a difference when drawing to calling with python. Its like there is a flag not included in curve cmd docs

Justin Israel

unread,
Dec 3, 2015, 1:37:09 PM12/3/15
to Python Programming for Autodesk Maya


On Thu, 3 Dec 2015 11:13 PM  <s...@weacceptyou.com> wrote:

thanks Justin, this would be ok. its just the problem with the rebuild curve thing is the problem i had at the beginning, the points shift their position slightly when the curve is rebuilt.

I dont get it that there is a difference when drawing to calling with python. Its like there is a flag not included in curve cmd docs

Like I said though, when you use the ep curve tool Maya is still calling the curve command for you with CV points and knots. It isn't using the ep param with a hidden flag. Check out the script editor output when you do it via the tool.

--
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 python_inside_m...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/0bd93f88-2b77-46b4-8661-67e3522d038b%40googlegroups.com.

s...@weacceptyou.com

unread,
Dec 3, 2015, 5:11:33 PM12/3/15
to Python Programming for Autodesk Maya
hmm ok yeah i see.

this is so weird, so i plot out the edit points and then maya cleverly converts these points into cv points with knots, but places them correctly to match the position of the original edit points. But it can't do it straight away with python command. im a bit slow, is that correct?

Justin Israel

unread,
Dec 3, 2015, 5:40:46 PM12/3/15
to Python Programming for Autodesk Maya
That's as far as I know, yea. 

On Fri, Dec 4, 2015 at 11:11 AM <s...@weacceptyou.com> wrote:
hmm ok yeah i see.

this is so weird, so i plot out the edit points and then maya cleverly converts these points into cv points with knots, but places them correctly to match the position of the original edit points. But it can't do it straight away with python command. im a bit slow, is that correct?

--
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 python_inside_m...@googlegroups.com.

s...@weacceptyou.com

unread,
Dec 3, 2015, 5:48:57 PM12/3/15
to Python Programming for Autodesk Maya
ok thanks, i will try and solve this eventually

Sam

Justin Israel

unread,
Dec 3, 2015, 5:56:51 PM12/3/15
to Python Programming for Autodesk Maya
What about using the Maya API instead?
import maya.OpenMaya as om

curveFn = om.MFnNurbsCurve()
arr = om.MPointArray()
arr.append(0,0,0)
arr.append(...)

obj = curveFn.createWithEditPoints(arr, 3, om.MFnNurbsCurve.kOpen, False, False, True)


That has the option you were asking about.



On Fri, Dec 4, 2015 at 11:48 AM <s...@weacceptyou.com> wrote:
ok thanks, i will try and solve this eventually

Sam

--
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 python_inside_m...@googlegroups.com.

s...@weacceptyou.com

unread,
Dec 4, 2015, 3:37:28 PM12/4/15
to Python Programming for Autodesk Maya
boom, thats it! finally there is a solution. thanks a super lot Justin

i am still a bit fearful if api, the guide blows my mind, but i guess there will always be an api way of doing things and will always be fast than python.

i was unsure how to add all the points i wanted in one go but i appended that list like this:

#########
import maya.OpenMaya as om

positions=[(1,2,3),(0,2,3),(2,3,4),(5,2,4)]

curveFn = om.MFnNurbsCurve()
arr = om.MPointArray()

for pos in positions:
arr.append(*pos)

obj = curveFn.createWithEditPoints(
arr,
3,
om.MFnNurbsCurve.kOpen,
False,
False,
True
)
########

i guess i can shove this in a function and call it with the points i need every time;) - its good because for ages i have been creating ep curves, storing point positions ,rebuilding , then moving points back into stored positions to get the uniform spans. geez this is alot tighter

thanks alot!
Sam

Justin Israel

unread,
Dec 4, 2015, 3:41:57 PM12/4/15
to Python Programming for Autodesk Maya

Awesome. Glad it does what you needed.
The Maya API is just very C++ -  like. So you are using it fine. It definitely has a lot deeper functionality, so the docs are more intense. The commands module is more like a super simple collection of high level functions that work with strings.


--
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 python_inside_m...@googlegroups.com.

s...@weacceptyou.com

unread,
Dec 4, 2015, 6:53:18 PM12/4/15
to Python Programming for Autodesk Maya
sorry Justin, one last thing. i can't figure out how to name the curve you have created through maya api. Is this a simple thing?

thanks,
Sam

Aton Lerin

unread,
Dec 28, 2015, 5:55:36 AM12/28/15
to Python Programming for Autodesk Maya
The rebuild curve command has a flag call keeprange (see doc) in addition with the flag keepcvs=true, should work fine.

s...@weacceptyou.com

unread,
Jan 10, 2016, 6:35:01 AM1/10/16
to Python Programming for Autodesk Maya
hey Aton,

im not sure if you meant a different flag for the keepcvs? its not in the python commands. im not sure if you meant 'keepControlPoints'. If so this will rebuild the curve to the correct params i want but there is a side effect of the curve position changing slightly. Whereas the api route seems to be able to do it without changing the curves path.

If there is a cmds way to do this it would be prefered though because im still stuck on implementing this api thing into my script

thanks,
Sam
Reply all
Reply to author
Forward
0 new messages