Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Script Noob: trying to automate split body

Message 1 of 2
175 Views, 1 Reply

Script Noob: trying to automate split body

Hi All, 


I'm a long time Fusion 360 user wading into scripting for the first time. I study fish and need to slice up a model of a fish I built 100 times and export the relative masses of each segment (segment mass/total body mass). I need to do this for a total of nine fish and doing it by hand is really tedious.


So far I have a script where, as far as I can tell, I am able to:


enter the body length of the fish

enter the number of segments I want

select the main body and the starting face 

calculate the segment thickness


The next steps I need to do and am having trouble figuring out are:


1: Creating offset planes from the starting face

2: Splitting the body using the offset planes

3: exporting masses of each segment


I have experience coding in Python/MATLAB generally. But I do not know much about the Autodesk libraries or how to use them. I haven't found any good video tutorials that go beyond creating the first script. I know I'll need For Loops and things like that. I'm mainly having trouble figuring out how to create planes and things like that. I've been looking at some of the sample codes like bottle and pipe but they are of limited use. I don't necessarily need someone to write this for me, just point me toward some articles or templates that would help get me started.


Here is a screenshot of my code: 


and the model I am trying to slice (the face I'm using to offset planes highlighted in blue): 



Thanks a million,




Message 2 of 2
in reply to: StePhDen2020

Hi @StePhDen2020 .


I have created a sample that creates multiple offset planes from a selected Construction Plane.

#Fusion360API Python script
import adsk.core, adsk.fusion, traceback

_app = adsk.core.Application.cast(None)
_ui = adsk.core.UserInterface.cast(None)

def run(context):
        global _app, _ui
        _app = adsk.core.Application.get()
        _ui = _app.userInterface

        msg :str = 'Select ConstructionPlanes'
        selFiltter :str = 'ConstructionPlanes'
        sel :adsk.core.Selection = selectEnt(msg ,selFiltter)
        if not sel: return

        # selected plane
        basePlane :adsk.fusion.ConstructionPlane = sel.entity

        # get component
        comp :adsk.fusion.Component = basePlane.parent

        # get planes
        planes :adsk.fusion.ConstructionPlanes = comp.constructionPlanes

        # conditions
        step = 1 # unit Cm
        count = 10

        # create offset plane
        planeInput :adsk.fusion.ConstructionPlaneInput = planes.createInput()
        for idx in range(count):
            offsetValue = adsk.core.ValueInput.createByReal(idx * step)
            planeInput.setByOffset(basePlane, offsetValue)

        if _ui:

def selectEnt(
    msg :str, 
    filtterStr :str
    ) -> adsk.core.Selection :

        sel = _ui.selectEntity(msg, filtterStr)
        return sel
        return None

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th

Autodesk Design & Make Report