Evaluate Curve not returning point object

Hello I am not good at programming, but I am just learning.
Anyway I am trying to get the ‘evalute curve’ function to work like it does in grasshopper. Here is my code thank you in advance:

import rhinoscriptsyntax as rs

plane = rs.WorldXYPlane()
rectangle = rs.AddRectangle( plane, 10, 10 )
explodeCurves = rs.ExplodeCurves(rectangle, [0] )

crv1 = explodeCurves[0]

#curves = crv1,crv2,crv3,crv4

domain = rs.CurveDomain( crv1 )
print “curve domain:”, domain[0], “to”, domain[1]
#domain is 0 to 10 but I would like to reparamaterize it or unitize it.

pointOnCurve = rs.EvaluateCurve( crv1 , 3, )

ALso, I am not sure why I cannot evaluate multiple curves at the same time?
This should be:

curves = explodeCurves[0,1,2,3]
rs.EvaluateCurve(curves, .33)

to avoid to unitize the curve(s), you might use

``````rs.CurveParameter(curve, 0.33)
``````

see if below code helps:

``````import rhinoscriptsyntax as rs

def DoSomething():
plane = rs.WorldXYPlane()
rectangle = rs.AddRectangle( plane, 10.0, 10.0 )
explodedCurves = rs.ExplodeCurves([rectangle], True)

for i, curve in enumerate(explodedCurves):
domain = rs.CurveDomain(curve)
print "curve {} domain: {} to {}".format(i, domain[0], domain[1])

parameter = rs.CurveParameter(curve, 0.33)
point_on_curve = rs.EvaluateCurve(curve, parameter)

if __name__=="__main__":
DoSomething()

``````

c.

Your code does what I wish to achieve and more as I don’t understand the ‘enumerate’ concept. I know its like a king in a card deck, but that is where I am lost.

My question is how can I reference the points created from ‘rs.Addpoint(point_on_curve)’ without using a ‘GetObject()’ function so that I can draw a polyline etc…

Thank you very much for your response.

Erik

Hi @brobes05, it is just a counter which enumerates the curves with a number, in the above example it is the variable named i… Here is one example without it, it appends points to an empty list, to create a polyline:

``````import rhinoscriptsyntax as rs

def DoSomething():
plane = rs.WorldXYPlane()
rectangle = rs.AddRectangle( plane, 10.0, 10.0 )
explodedCurves = rs.ExplodeCurves([rectangle], True)

pts = []
for curve in explodedCurves:
parameter = rs.CurveParameter(curve, 0.33)
point_on_curve = rs.EvaluateCurve(curve, parameter)
pts.append(point_on_curve)

# for a closed polyline, add first point to end of pts list
pts.append(pts[0])

if __name__=="__main__":
DoSomething()

``````

c.

Thanks for the reply. This is much closer to the level I am currently on. I am trying to force python into grasshopper which is not working out so well. Anyway, I coming up with the error ’ unable to draw polyline’. I believe I have written down the proper text. Thanks again for all your help. I understand much better now. The 2nd through 5th lines are indented in python, but I cannot get them to cooperate here.

``````def EmbeddedQuad():
plane = rs.WorldXYPlane()
rectangle = rs.AddRectangle( plane, 10,10 )
explodedCurves = rs.ExplodeCurves([rectangle], True)

pts = []
for curve in explodedCurves:
parameter = rs.CurveParameter(curve,.33)
point_on_curve = rs.EvaluateCurve(curve, parameter)
pts.append(point_on_curve)
``````

Yes, the forum sometimes has probs with indents and empty lines. Below should work from within the Python editor. You can open it using `_EditPythonScript` command and paste. Note that i have indents even in the blank lines.

``````import rhinoscriptsyntax as rs

plane = rs.WorldXYPlane()
rectangle = rs.AddRectangle( plane, 10,10 )
explodedCurves = rs.ExplodeCurves([rectangle], True)

pts = []
for curve in explodedCurves:
parameter = rs.CurveParameter(curve,0.33)
point_on_curve = rs.EvaluateCurve(curve, parameter)
pts.append(point_on_curve)

if polyline: rs.SelectObject(polyline)

``````

Ps: to post python code on discourse, check for blank lines first than start the code block like this:

`````````Python
``````

then paste your python code and end the code block like this:

`````````
``````

Everything between should display with code style font and a few colors.

c.

Wonderful. You have been very helpful to me. I have much to learn and must try and stop forcing the language to work like grasshopper.

Thanks again,
Erik

1 Like