Numbering models and exporting

Numbering models and exporting

a.brown5
Observer Observer
701 Views
2 Replies
Message 1 of 3

Numbering models and exporting

a.brown5
Observer
Observer

I have been using Fusion 360 for about 3 weeks now (still learning). I have to export a cylinder with a number cut in it from 1 to 100 all separate. Is there a quicker way to export 100 stl's other than to open, edit the sketch, change the number, then cut (extrude) into the cylinder, then export as stl, undo what I just did then edit the sketch, change the number, cut etc

 

0 Likes
Accepted solutions (1)
702 Views
2 Replies
Replies (2)
Message 2 of 3

goyals
Autodesk
Autodesk

I think it should all be possible through API. Please take a look at http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-A92A4B10-3781-4925-94C6-47DA85A4F65A. Thanks.



Shyam Goyal
Sr. Software Dev. Manager
0 Likes
Message 3 of 3

BrianEkins
Mentor
Mentor
Accepted solution

Here's a little script that demonstrates doing what you need.  You'll need to modify the path and the logic for the numbering.  I've attached the model I used to test.  The thing that's special about it is that it contains a sketch that I named "Text".  The script finds that sketch and the text box inside it and continues to edit the text.  For each edit, it exports the file as STL.

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

        # Find the sketch that contains the text to edit.
        numSketch = root.sketches.itemByName('Text')

        # Iterate through, editing the value and exporting.
        path = 'C:\\Temp'

        for i in range(1, 5):
            # Get the first textbox from the sketch. It uses the first
            # one because there's an assumption it's the only one.
            skText = numSketch.sketchTexts.item(0)

            # Update the text to the current number.
            skText.text = str(i)

            # Export the file as stl.
            filename = os.path.join(path, 'Export_' + str(i) + '.stl')
            stlExportOptions = des.exportManager.createSTLExportOptions(root, filename)
            stlExportOptions.meshRefinement = adsk.fusion.MeshRefinementSettings.MeshRefinementMedium
            des.exportManager.execute(stlExportOptions)

        ui.messageBox('Finished exporting files to ' + path)
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes