I bring python code to sort the point accord the distance:
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import Geometry
pts = IN[0]
margin = IN[1]
dist1 = Geometry.DistanceTo
Groups, Queue = [ ], [ ]
while pts:
group = [ ]
Queue.append(pts.pop() )
while Queue:
p1 = Queue.pop()
group.append(p1)
for i in xrange(len(pts)-1,-1,-1):
if dist1(p1, pts[i]) <= margin:
Queue.append(pts.pop(i) )
Groups.append(group)
OUT = [sublist[::-1] for sublist in Groups[::-1]]
the problem is when the input have more than one list level the code will not give right result as the pic :
how i can work with level lists in python
thanks
I can’t deal with python yet, also if i can’t make flatten for list because that will ruin the last sorting
1 Like
Daan
July 27, 2021, 11:03am
4
Hi @Mkq_1993 ,
Like paris said, you could put this python script inside a custom node, then list levels and such should work as intended
3 Likes
paris
July 27, 2021, 2:29pm
5
Hi @Mkq_1993 can you share a simple RVT file with your dyn?
Cheers
1 Like
Cable Tray Support3s.dyn (709.3 KB)
i want to move the script after vector direction sorting
https://easyupload.io/yru782
Just to add to the topic, if you are willing to put your Python block into a custom node this will enable levels to be used on its inputs. If you list the input to the node in the format…
name: var[]..[]
this will instruct the node to treat the input exactly as is, but enable you to also instruct it to work @L1 , L2 etc.
1 Like