====== Autodesk Fusion 360 ====== ===== Open all components in Slic3r ===== #Author-Bernhard Kiesbauer #Description- import adsk.core, adsk.fusion, adsk.cam, traceback import tempfile import os import subprocess import threading def startAndWait(cmd, filelist): p = subprocess.Popen(cmd) p.wait() for f in filelist: os.unlink(f) def run(context): ui = None silcerCmd = [r"\\printer\data\Slic3rPE-1.41.2\slic3r.exe", "--datadir",r"\\printer\data\slic3r-config"] try: app = adsk.core.Application.get() ui = app.userInterface f = tempfile.NamedTemporaryFile(delete=False) f.close() filename = f.name filelist = exportCompBodyAsSTL(filename) for f in filelist: silcerCmd.append(f) t = threading.Thread(target=startAndWait, args=(silcerCmd, filelist)) t.start() except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc())) def exportCompBodyAsSTL(destFilename): app = adsk.core.Application.get() ui = app.userInterface rv = [] product = app.activeProduct design = adsk.fusion.Design.cast(product) exportMgr = design.exportManager i=0 for comp in design.allComponents: #for body in comp.bRepBodies: fileName = "{}_{}.stl".format(destFilename, i) #print(comp.name) #print(comp.classType()) try: # create stl exportOptions stlExportOptions = exportMgr.createSTLExportOptions(comp, fileName) stlExportOptions.sendToPrintUtility = False stlExportOptions.meshRefinement = adsk.fusion.MeshRefinementSettings.MeshRefinementHigh exportMgr.execute(stlExportOptions) rv.append(fileName) i+=1 except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc())) return rv