Hello Fellow Dynamites!!!
I am trying to achieve the following polycurve list from a list of polycurves. and have tried a solution but facing problem in looping and some logic and inturn getting the result. Kindly, help me out i am attaching the codes which i have tried.
note: all the polycurves are overlapped
> # Load the Python Standard and DesignScript Libraries
> import sys
> import clr
> clr.AddReference('ProtoGeometry')
> from Autodesk.DesignScript.Geometry import *
>
> from itertools import groupby
>
> def flatten(l):
> return [item for sublist in l for item in sublist]
>
> # The inputs to this node will be stored as a list in the IN variables.
> pcrv = IN[0]
>
> # Place your code below this line
> oc=[]
> boole=[]
> for pc in pcrv:
> e=[]
> for c in pc:
> a=PolyCurve.Curves(c)
> d=[]
> for b in a:
> c=str(Line.ByStartPointEndPoint(b.StartPoint,b.EndPoint))
> d.append(c)
> e.append(d)
> bo=[]
> for f in e:
> boo=[]
> for g in e:
> bool=[]
> for h in f:
> if h in g:
> bool.append(True)
> break
> else:
> bool.append(False)
> if all(bool):
> boo.append(True)
> else:
> boo.append(False)
> bo.append(boo)
> boole.append(bo)
> for bl in bo:
> i=sum(bl)
> crvs=[]
> for a,b in groupby(pc, lambda pc: i):
> crvs.append(list(b))
> crv=[]
> for j in crvs:
> len=[k.Length for k in j]
> maxlen=max(len)
> mi=len.index(maxlen)
> crv.append(j[mi])
> oc.append(crv)
>
> # Assign your output to the OUT variable.
> OUT = oc