#Author-Saskia Müller #Description-Soll die Bodys anhand von Ebenen in viele kleine Bodys zerlegen. #Einmal in kleine Würfel und einemal in Detektoreinheiten, also kugelsymmetrisch #ähnlich. Dafür müssen Ebenen erstellt werden anhand derer gesplittet wird. zu #Testzwecken wird für die Kugelsymmetrische Zerlegeung ein Apllicator als #Kugelschalenelement mittels API erstellt. import adsk.core, adsk.fusion, adsk.cam, traceback def run(context): ui = None try: app = adsk.core.Application.get() ui = app.userInterface # Create a document. #doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType) product = app.activeProduct design = adsk.fusion.Design.cast(product) # Get the root component of the active design rootComp = design.rootComponent #Creating Linear Dimension (Plane) where I want them #Create a new Sketch on the xy-Plane sketches = rootComp.sketches # Make all xyz-Planes known xyPlane = rootComp.xYConstructionPlane sketch = sketches.add(xyPlane) xzPlane = rootComp.xZConstructionPlane sketch = sketches.add(xyPlane) yzPlane = rootComp.yZConstructionPlane sketch = sketches.add(xyPlane) #------------------------------- #------------------------------- #creates new Planes in each of the three directions, in mm steps, since #the diameter of the eye is about 23mm the loop goes from -15mm to +15mm #this should be enough to include the 1mm thick eye applicator #will be used to cut our eye-mdel into several cubes, to be used as #sensitive scorers for xyz_planes in [xyPlane, xzPlane, yzPlane]: for i in range(-15, 16): #cm, will be converted into mm later # Get construction planes planes = rootComp.constructionPlanes # Create construction plane input planeInput = planes.createInput() # Add construction plane by offset offsetValue = adsk.core.ValueInput.createByReal(i/100.)#in mm now planeInput.setByOffset(xyz_planes, offsetValue) planeOne = planes.add(planeInput) #Creating Planes end # the following is just how it would work in an ideal world # simply take each body and split it with every possible # splitting tool and ignore any errors that occur allBodies = rootComp.bRepBodies for body in allBodies: #Splitting #Create SplitBodyFeatureInput splitBodyFeats = rootComp.features.splitBodyFeatures splitBodyInput = splitBodyFeats.createInput(body, planeOne, True) #1: body to be split, 2: SplittingTool, 3:SplittingToolExtended # Create split body feature split_Object = splitBodyFeats.add(splitBodyInput) #Splitting end except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))