# Grouping of Curves with Design Script

#1

Design script definition that groups a list of shuffled curves into loops…

On the package manager search for tstngwtrs-GroupCurves

However the node doesn’t need to be downloaded, paste the below code in a code block and call grpCrvs(crv)

``````    def grpCrvs(crv:var[]..[])
{
dis1 = (crv.StartPoint)<1>.DistanceTo(crv<2>)==0
||(crv.EndPoint)<1>.DistanceTo(crv<2>)==0;
ind1 = List.AllIndicesOf(dis1<1>,true);
bln1 = true;
ind2 = [Imperative]
{
while (bln1)
{
cnt1 = List.Count(ind1);
ind1 = grpIndx(ind1);
cnt2 = List.Count(ind1);
bln1 = cnt2!=cnt1;
}
return = ind1;
}
crv1 = List.GetItemAtIndex(crv,ind2);
return = crv1;
};

def grpIndx(ind:var[]..[])
{
ind1 = SetIntersection(ind<1>,ind<2>);
cnt1 = List.Count(ind1<1><2>)>0;
ind3 = List.FirstItem(ind2<1>);
ind4 = List.UniqueItems(Flatten(ind3<1>)<1>);
ind5 = List.UniqueItems(List.Sort(ind4<1>));
return = ind5;
};
``````

Join List<Curves> to PolyCurve regardless if they are joinable
Joining lines and arcs to polycurve
Sorting curves
Building Areas to surface in Dynamo
How to locate the Indexes of arcs in a polycurve
Split the curves exactly at Plane
Polycurve from DWG file
Grouping the list
Merge Lines with same direction and points in common
#2

That has made my day @Vikram_Subbaiah super stuff!

#3

Update for Dynamo 2

``````def grpCrvs(crv:var[]..[])
{
dis1 = (crv.StartPoint)<1>.DistanceTo(crv<2>)==0
||(crv.EndPoint)<1>.DistanceTo(crv<2>)==0;
ind1 = List.AllIndicesOf(dis1<1>,true);
bln1 = true;
ind2 = [Imperative]
{
while (bln1)
{
cnt1 = List.Count(ind1);
ind1 = grpIndx(ind1);
cnt2 = List.Count(ind1);
bln1 = cnt2!=cnt1;
}
return = ind1;
}
crv1 = List.GetItemAtIndex(crv,ind2);
return = crv1;
};

def grpIndx(ind:var[]..[])
{
ind1 = List.SetIntersection(ind<1>,ind<2>);
cnt1 = List.Count(ind1<1><2>)>0;
ind3 = List.UniqueItems(List.Flatten(ind2<1>,-1)<1>);
ind4 = List.UniqueItems(List.Sort(ind3<1>));
return = ind4;
};``````

Polycurve from DWG file
Extracting closed Polycurves from given Surface
Drawing shapes from raster to vectorial
#4

Hello, i tried this method but i seem to be getting an error message. Can you tell me how this is possible, and how to fix it please?

#5

Add DSCore. In front of anywhere saying List