- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello All,
I'm enjoying Fusion360 so much, I'm wanting to dig deeper and seeing what can be automated.
Right now I'm using Fusion360 for modelling and Blender Cycles for rendering, which means I have to Export to STL.
The most ideal setting for me with the default STL exporter is to export as multiple files. It works well, however, it exports single bodies, and creates rather convoluted filenames, that are a pain to work with.
I've written this simple script that exports occurrences, which means I can have a component with separate bodies, acting as one part. However, they get imported at their own origin, with no location or rotation data. Which means that when I import all into Blender, I get a huge mess of parts (Components), whereas using Fusion's Built-in exporter, I get all parts (Bodies) in their rotated (and moved) positions.
The ideal order of events for this operation are:
1. Press a button "STL Export" (not included in the code)
2. Select folder
3. Files exported in "high" setting, with no extra dialogs (or user input), with their Component names.
Any simple solutions to this? Thank you all in advance.
Here's an excerpt of my plugin so far, it's a very rough draft - apologies for that;
class CommandExecuteHandler(adsk.core.CommandEventHandler):
def __init__(self):
super().__init__()
def notify(self, args):
try:
app = adsk.core.Application.get()
ui = app.userInterface
#msg = ''
# Set styles of file dialog.
fileDlg = ui.createFileDialog()
fileDlg.isMultiSelectEnabled = False
fileDlg.title = 'Fusion File Dialog'
fileDlg.filter = '*.*'
# Set styles of file dialog.
folderDlg = ui.createFolderDialog()
folderDlg.title = 'Fusion Folder Dialog'
# Show folder dialog
dlgResult = folderDlg.showDialog()
if dlgResult == adsk.core.DialogResults.DialogOK:
#msg += '\nSelected folder: {}'.
format(folderDlg.folder)
#ui.messageBox(msg)
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
rootComp = design.rootComponent
exportMgr = design.exportManager
# export the component one by one with a specified format
allOccu = rootComp.allOccurrences
for occ in allOccu:
# create stl exportOptions
fileName = folderDlg.folder + "/" + occ.component.name
stlExportOptions = exportMgr.createSTLExportOptions(occ, fileName)
stlExportOptions.meshRefinement = adsk.fusion.MeshRefinementSettings.MeshRefinementHigh
stlExportOptions.sendToPrintUtility = False
exportMgr.execute(stlExportOptions)
except:
if ui:
ui.messageBox('STL Export Failed / Cancelled')
Solved! Go to Solution.