Parameter list from DivideCurveLength

newbie question here
I am dividing a curve by length 20mm
It is returning a list of parameters into params.
I then want to remove the last parameter in the list.
I have tried several things… pop and del to remove
the last parameter from the list. I get an error.
example below…Can someone explain to me what is wrong with the simple code?
Much Thanks

import rhinoscriptsyntax as rs

crv = rs.GetObject("Select curve", rs.filter.curve)
params = rs.DivideCurveLength(crv,20.0,False,False)
i = len(params)
print(i)
lastone = params.pop()

Hi Newton,

DivideCurveLength returns a .NET array . If you convert it into a list you can use .pop as epected:

import rhinoscriptsyntax as rs

crv = rs.GetObject("Select curve", rs.filter.curve)
params = rs.DivideCurveLength(crv,20.0,False,False) #returns a .NET array
params_list = list(params) #convert into a python list
i = len(params_list)
print(i)
lastone = params_list.pop()

@stevebaer is this an oversight in rs.DivideCurveLength() ?

-Willem

thanks for the explanation Willem!

It’s actually coming from the RhinoCommon Rhino.Geometry.Curve.DivideByLength method… I don’t know if it’s being done on purpose, but I think it would be better if it returned a normal list - at least for the rs. encapsulated method if not for the RhinoCommon method.

A System.Double array is a very specific kind of array in the CLR, it is a “vector array” which has its first element at index 0. These kind of arrays are heavily optimized in the CLR.

Indeed this is an array returned from the RhinoCommon method.
However thinking about it, it would probably be best to always return python lists to prevent this type of confusion.
For examle if the rhinoscript method would be set to return points, it does return a list (outputpoints)

image

-Willem

I’m inclined to leave the return type as it is so we don’t break anything. The docs do state that an array is returned in this case. It may have been a design error when putting rhinoscriptsyntax together, but I don’t want to break things or reduce performance due to a change like this.