creating knots on position points for cmds.curve

307 views
Skip to first unread message

s...@weacceptyou.com

unread,
Feb 9, 2015, 12:17:12 PM2/9/15
to python_in...@googlegroups.com
Hi there,

i am trying to create a curve of degree=3 from 4 points in space. So if i use the following command i will create a curve which goes through the points, but there will only be an edit point at either end of the curve.

cmds.curve(d=3, p=[(0, 0, 0), (3, 5, 6), (5, 6, 7), (9, 9, 9)] )

if i make the degree=1 then it will be a linear curve and there will be an edit point on each of the position points specified in the p= flag.

What i need is to keep it a d=3 curvy curve but to have the points i have specified as editable points on the curve.

I this possible within this command?

thanks for your time,
Sam

johan Borgström

unread,
Feb 9, 2015, 4:58:03 PM2/9/15
to python_in...@googlegroups.com
Hi sam,

instead of p=[(...
use ep=[(...

/Johan

e955...@gmail.com

unread,
Feb 9, 2015, 7:27:11 PM2/9/15
to python_in...@googlegroups.com
ha yep, i literally just figured this out ha. thankyou very much.

Incidentally i dont suppose you know how to change the parameterisation of a curve. i need it to be going from 0 to 1 between each of these edit points. So i can add more points at specific positions in between with the insert knot curve command.

The only problem is when i try and fix the parameterisation with:

cmds.rebuildCurve('curve1',kcp=True)

The points of the curve in world space change slightly. I need them to remain exactly where they are, but i need the parameter values to change.
do you know how this can be done?

thankyou very much for your time,
Sam

Justin Israel

unread,
Feb 9, 2015, 8:04:21 PM2/9/15
to python_in...@googlegroups.com
Maybe something like this is what you want?

cmds.rebuildCurve(kr=0, kcp=True, s=0, d=3) 



--
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_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/f80f3364-f21f-4af8-80e4-6b7cc5de6959%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

sam williams

unread,
Feb 10, 2015, 3:10:07 PM2/10/15
to python_in...@googlegroups.com
Hey Justin, 

i tried your suggestion, but it doesn't seem to work. The original edit points shift out of place. I've been trying alot of different flag options to see if i can fix this, but nothing seems to work. Im a bit lost ha.





--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/X2JdYV_4p1Q/unsubscribe.
To unsubscribe from this group and all its topics, 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/CAPGFgA39-VoouTcjopRK2fOPmNTQrDENvj-dnv9Baa%2Bwv3detg%40mail.gmail.com.

Anthony Tan

unread,
Feb 10, 2015, 7:12:25 PM2/10/15
to python_in...@googlegroups.com
It's a hack, but you probably want to duplicate the curve and tell it to match knots. I know, i know..
 
c1 = mc.curve(d=3, ep=[(0,0,0), (1,0,0), (2,1,0), (3,-1,0), (4,1,0),(5,-1,0),(6,0,0)])   # base curve
c2 = mc.duplicate()
 
mc.select ([c1] + c2)    # ignore the voodoo, duplicate returns a list, while mc.curve doesn't.
 
mc.rebuildCurve(rebuildType=2, keepControlPoints=True, degree=3, keepRange=0, replaceOriginal = False, constructionHistory = False) # rebuild.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

Anthony Tan

unread,
Feb 10, 2015, 7:22:58 PM2/10/15
to python_in...@googlegroups.com
Noting of course, in practice you probably want to *not* keep the construction history so you can blow away the duplicate curve etc etc. If you wanted to keep history etc, you may want to instead create the rebuildCurve node directly and plug the curveShape into both the inputCurve and matchCurve slots - i don't *think* that'd set up a DAG loop..

sam williams

unread,
Feb 11, 2015, 5:03:14 PM2/11/15
to python_in...@googlegroups.com
thanks alot Anthony. This is great. the points dont move!, however between the first two points on the curve, the parameter 'u[]' value goes from 0 to 1 (which is great), but then the spaces along the curve after that start getting longer. so between edit points 2 and 3 on the curve is u[1] to u[2.4] roughly and then edit points 3 to 4 ranges from u[2.4] to u[4.6]. 

I'm gonna test a few things out. Thankyou for your help, 
Sam

Anthony Tan

unread,
Feb 11, 2015, 7:30:16 PM2/11/15
to python_in...@googlegroups.com
That's weird, let me know what you get on that side, I've just checked by running the code here and I'm getting uniform parametization on the resulting curve as best as i can tell? On the original example I posted, my curve had 6 spans, and a min/max of 0-10.537 and the rebuilt was 0-1. I just tried with a straight line (all EPs on the x axis), and everything *looks* uniform and 0-1 as far as i can tell, but yes, let me know how you go - would be curious to know what's happening.

sam williams

unread,
Feb 11, 2015, 8:32:12 PM2/11/15
to python_in...@googlegroups.com
hmmm,
ye i tried again, and it seems the same. I think maybe theres a miscommunication. ill try and explain exactly what im doing.

I need to create a wavy cubic curve that goes through a set of points, and then using the path of that curve i want to be able to add further knots evenly inbetween the edit points that i plotted originally. - I am using the u[] parameter values with the 'insertKnotCurve' command to tell it to place the knots half way between each point on the curve. eg:

cmds.insertKnotCurve(('curve1.u[0.5]'),('curve1.u[1.5]'),('curve1.u[2.5]'), ch=True, add=False, rpo=True )

so i need there to be a range of 0 to 1 between each point on the curve so ep1 to ep2: u[0.0] to u[1.0]  , ep2 to ep3: u[1.0] to u[2.0] etc. Rather than the whole curve spanning 0 to 1. You see what i mean?

Sam



e955...@gmail.com

unread,
Feb 15, 2015, 8:54:09 AM2/15/15
to python_in...@googlegroups.com, antho...@greenworm.net
ok, my solution is just to move the points back into position after the rebuild with xform.

not ideal, but works.

Sam
Reply all
Reply to author
Forward
0 new messages