algorithmic modeling for Rhino
Hello,
I want to compare the centroids of two polyline curves, and then delete one of the centroids equal one another (i.e. a duplicate curve). However, when I attempt to do so, the python script component is not recognizing two identical points as equal (attached).
I would appreciate some direction on this error, if anyone has a clue!
Thank you,
Tracy H.
Tags:
Trying to troubleshoot without the file is kind of tricky.
The attached works. Have a look and compare it to your file.
ta,
M.
Hello Marios,
Thank you for your advice and sharing the file! I have discovered my error. I was comparing two points created with python script (First creating a polyline from a set of points via "rs.AddPolyline()" and then finding the Centroid of the polyline curve via "rs.CurveAreaCentroid()").
I noticed that if the same polyline was drawn in a different points order, that the centroid points wouldn't be equal. I solved that issue by sorting the points each time before a polyline was drawn. I also noticed that rs.CurveAreaCentroid returns two outputs, a Point3d fat Index[0] and an error bound at Index[1]. The comparison that would return identical points as equal is by only comparing the Point3d output of rs.CurveAreaCentroid.
Thought I would share that in case someone else runs into the same issue! I've included snippets of my code.
# -- Sorting points to draw polyline curves
Points1 = [p0,p1,p2]
Points2 = rs.SortPoints(Points1,True,0)
Points2.append(Points2[0])
Faces.append(rs.AddPolyline(Points2))# -- Deleting the same polyline curves
objs = rs.AllObjects()
Curves = []
Centroid = []for i in objs:
Type = rs.ObjectType(i)
if Type == 4:
if rs.IsCurveClosed(i):
C = rs.CurveAreaCentroid(i)
if C[0] not in Centroid:
Curves.append(i)
Centroid.append(C[0])
else:
rs.DeleteObject(i)
Cheers,
TH
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by