Hi all ,
am trying to split a surface with a list of lines , I did a recursive function that will split the surface in 2 parts with the first curve , one part will go to a new list and the second will be split by the second curve to another 2 pieces and so on , I keep having an error that the index is out of range , any idea why this is happening surface split.dyn (24.5 KB)
Hi all ,
You might want to look into Geometry.SplitReursively in the Springs package.
Thanx for your reply Jacob but I really want to learn how to do it in pythonscript
In your example, what do you expect for the final output? A list of 6 surfaces (smallest possible pieces)? or a recursion that gives you the interim results as well (e.g. an uncut surface of 3 bays?)
I expect a list of 6 surfaces cut as per the lines locations , but I guess it will not work except I use a recursive method
sorry for replying with this account as my previous account doesn’t work
Per my understanding of your code and expectation (each resulting surface being cut by next cutter line) you do not need a classic recursion algorithm.
This code should give you what you expect:
from Autodesk.DesignScript.Geometry import *
def Splitter(Surface,cutters): output=  for i in cutters: srf = Geometry.Split(Surface , i) #picking the second surface to split if len(srf)>1: output.append(srf) Surface = srf if i == cutters [-1]: output.append(srf) return output OUT = Splitter(IN,IN)
However, if you want true recursion for more complex situations, you need to rethink the recursion stopper (that is after cutting a surface or surfaces with a cutter line, that line should be removed from the list of cutters and the resulting surfaces should be cut with the remaining cutter lines until all cutter lines are used and removed).
Thank you very much Habdirad this has done it , it was so informative