Incremental cross section surface area reporter

Incremental cross section surface area reporter

awilliamwright
Enthusiast Enthusiast
533 Views
2 Replies
Message 1 of 3

Incremental cross section surface area reporter

awilliamwright
Enthusiast
Enthusiast

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.

0 Likes
534 Views
2 Replies
Replies (2)
Message 2 of 3

BrianEkins
Mentor
Mentor

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
Enthusiast
Enthusiast

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.

0 Likes