Community
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.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Incremental cross section surface area reporter

2 REPLIES 2
Reply
Message 1 of 3
awilliamwright
200 Views, 2 Replies

Incremental cross section surface area reporter

This may be a bonkers question, but how difficult would it be to write a script that would generate a report of a project's cross-sectional surface area, at incremental positions, along its length?

 

This is normally something aerospace engineers would need for designing supersonic aircraft. I'm just a scifi designer, but I try to have my designs inspired by real world engineering, and wish there was a way I could find out how "correct" my designs would be for supersonic flight.

 

Again, I know, bonkers request. But real world engineering often lends very strong believability to purely artistic designs.

2 REPLIES 2
Message 2 of 3
BrianEkins
in reply to: awilliamwright

That's possible and there are probably a few approaches.  Here's some code that will hopefully get you started.  It sections the first body in the root component with a plane that is parallel to the X-Y plane and starts at Z zero and steps in the positive Z 1 cm for each section and creates up to 20 sections.  All of that is easily changed.

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        design = adsk.fusion.Design.cast(app.activeProduct)
        root = design.rootComponent

        bm = adsk.fusion.TemporaryBRepManager.get()
        body = root.bRepBodies.item(0)

        baseFeature = root.features.baseFeatures.add()
        baseFeature.startEdit()

        offset = 1
        position = adsk.core.Point3D.create(0,0,0)
        for i in range(20):
            plane = adsk.core.Plane.create(position, adsk.core.Vector3D.create(0,0,1))
            sectionWireBody = None
            # Wrap section in a try except to handle the case where there isn't an intersection.
            try:
                sectionWireBody = bm.planeIntersection(body, plane)
            except:
                continue

            if sectionWireBody:
                sectionBody = bm.createFaceFromPlanarWires([sectionWireBody])

                # You can get the faces from the returned body (typically there will be
                # one) and get area properties from it such as area and the centroid.
                for face in sectionBody.faces:
                    print( str(face.area))

                root.bRepBodies.add(sectionBody, baseFeature)

            position.z += 1

        baseFeature.finishEdit()

        ui.messageBox('Finished')
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

 

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 3
awilliamwright
in reply to: BrianEkins

Thanks! I may try this, but right after posting my question, I realized that I could just use a slicer program, for 3d printing, to get the exact same data. I'll probably try that avenue first.

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