Group curves
Design script definition that groups a list of shuffled curves into loops…
1
def grpCrvs(crv:var[]..[])
2
{
3
dis1 = (crv.StartPoint)<1>.DistanceTo(crv<2>)==0
4
||(crv.EndPoint)<1>.DistanceTo(crv<2>)==0;
5
ind1 = List.AllIndicesOf(dis1<1>,true);
6
bln1 = true;
7
ind2 = [Imperative]
8
{
9
while (bln1)
10
{
11
cnt1 = List.Count(ind1);
12
ind1 = grpIndx(ind1);
13
cnt2 = List.Count(ind1);
14
bln1 = cnt2!=cnt1;
15
}
16
return = ind1;
17
}
18
crv1 = List.GetItemAtIndex(crv,ind2);
19
return = crv1;
20
};
21
22
def grpIndx(ind:var[]..[])
23
{
24
ind1 = List.SetIntersection(ind<1>,ind<2>);
25
cnt1 = List.Count(ind1<1><2>)>0;
26
ind2 = List.FilterByBoolMask(ind,cnt1<1>)["in"];
27
ind3 = List.UniqueItems(List.Flatten(ind2<1>,-1)<1>);
28
ind4 = List.UniqueItems(List.Sort(ind3<1>));
29
return = ind4;
30
};
Copied!
Last modified 1yr ago
Copy link