Holo
October 19, 2016, 1:56pm
1
Hi, I need to remove an item from a list of points, but I get the error that ‘Array[Point3d]’ object doesn’t support item deletion.
So what should I do?
(I am going to trace some points in a pointcloud)
import rhinoscriptsyntax as rs
cloud=rs.GetObject("get pointcloud",filter=2)
point=rs.GetPoint("Get point")
ptList=rs.PointCloudPoints(cloud)
index = rs.PointArrayClosestPoint(ptList, point)
rs.AddLine(point,ptList[index])
print str(index) + " : " + str(ptList[index])
ptList.pop(index)
You can either convert a point3dlist into a normal list using list(your_point3d_list)
or use the Point3dList.RemoveAt(index)
method…
http://developer.rhino3d.com/api/RhinoCommonWin/html/T_Rhino_Collections_Point3dList.htm
–Mitch
Holo
October 19, 2016, 4:09pm
3
Thanks Mitch, I didn’t think of the option to just put the list in another list. Clever.
So the list(3dpointlist) solution worked. List.RemveAt(index) didn’t, it threw something like a “list is fixed length” error.