Len() error joining curve & polyline python


#1

I am doing a test to join a curve and polyline in python. I would also like to know how I can get those 2 components into a list for a dictionary.

First the error …

the simple code;

import rhinoscriptsyntax as rs

curvePoints1 = (-5.09372,0,0), (-5.574682,0,0.59102), (-6.21176,0,1.51327), (-6.70684,0,2.70848), (-6.93052,0,3.96635), (-7.00,0,5.08339), (-7.00,0,5.86)
curve1 = rs.AddCurve(curvePoints1)

linePoints1 = (-7.00,0,5.86), (-6.00,0,5.86), (-6.00,0,4.02), (-3.84,0,4.02), (-3.84,0,3.03), (-4.234,0,3.03), (-4.234,0,0), (-5.09372,0,0)

curve2 = rs.AddPolyline(linePoints1)

rs.JoinCurves(curve1, curve2)

Here is what I eventually want, I will revolve these curve. The first 5 are straight polylines and work fine.

«Randy


#2

The script runs OK here and the profile is produced in Rhino for Windows - however I do get the error message at the end… hang on, will have a look.

Ahh, rs.JoinCurves() wants a list, not just two curves, should have seen that right away.

rs.JoinCurves([curve1, curve2])

However, it seems it shouldn’t throw an error like that… should just return Null or maybe even try to join them…

Here is the line that does it:

if len(object_ids)<2: raise ValueError("object_ids must contain at least 2 items")

–Mitch


#3

I do also but they are not joined, :disappointed:


#4

Thanks Mitch, A list for the 2 curves may work better getting it into my dictionary !

Give that a try now, works!

curveList1 = [(curve1), (curve2)]

rs.JoinCurves(curveList1, delete_input=True)

«Randy