I have a problem in my script which i do not know how to solve, so i hope someone else has a good insight/ idea for this problem
I have two inputs, a line/ points and a list of booleans. Now i want to split this line on each first false boolean/ each last boolean (seen in my example below).
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS
def ranges(lstBool, lstPoints):
#get index false
idxFalse = [idx for idx, i in enumerate(lstBool) if not i]
#return 1st point
yield lstPoints[0]
#init start end
start, end = idxFalse[0], idxFalse[0]
count = start
for item in idxFalse:
if not count == item:
yield lstPoints[start]
yield lstPoints[end]
#re-init start end
start, end = item, item
count = item
end = item
count += 1
yield lstPoints[start]
yield lstPoints[end]
#return last point
yield lstPoints[-1]
lstPoints = IN[0]
lstBool = IN[1]
out = []
lstPtToLine = [x for x in ranges(lstBool, lstPoints)]
for idx, i in enumerate(lstPtToLine):
if idx > 0:
line = DS.Line.ByStartPointEndPoint(lstPtToLine[idx - 1], i)
out.append(line)
OUT = out