Help! SplitBrep issue

Hi, guys, I don’t understand what’s going wrong in ’ rhinoscriptsyntax.SplitBrep (brep, cutter, delete_input=False) ', pls help me! Thanks for ur replying !

my code:

import rhinoscriptsyntax as rs

def broken(thing):
box = rs.BoundingBox(thing)
cut = rs.AddSrfPt((box[1],box[5],box[7],box[3]))
list = rs.SplitBrep(thing,cut,True)
rs.DeleteObject(cut)
broken(list[0])

thing = rs.GetObject(“Things to broken”)
broken(thing)

Message: ‘NoneType’ object is unsubscriptable

Traceback:
line 10, in broken, "C:\Users\Administrator\Desktop\script\test.py"
line 10, in broken, "C:\Users\Administrator\Desktop\script\test.py"
line 13, in , “C:\Users\Administrator\Desktop\script\test.py

Hi @daizhuo,

your function creates a loop since it calls itself. I think what happens is that at some point the split fails because the object to split is getting smaller and smaller. To split one time only, below works, eg. using a sphere as “thing to broken”:

import rhinoscriptsyntax as rs

def broken(thing):
    box = rs.BoundingBox(thing)
    cut = rs.AddSrfPt([box[1],box[5],box[7],box[3]])
    list = rs.SplitBrep(thing,cut,True)
    rs.DeleteObject(cut)
    rs.SelectObjects(list)
    
if __name__=="__main__":
    thing = rs.GetObject("Thing to broken")
    if thing: broken(thing)
    

c.