Created
February 10, 2023 13:16
-
-
Save ebith/4f124929b8976c2bd623a9ea38e371dc to your computer and use it in GitHub Desktop.
詳細な名前を付けてSTLを出力するFusion 360スクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Author-ebith | |
#Description-Output STL with detailed name. | |
# 謎: | |
# - availablePrintUtilitiesが空っぽ | |
# - sendToPrintUtility = Trueとするとfilenameが無視されてGUID固定になる | |
# Todo: | |
# - ボディを選べるように | |
printUtilityPath = 'C:/Users/ebith/scoop/apps/cura/current/UltiMaker-Cura.exe' | |
import os.path | |
import subprocess | |
import tempfile | |
import traceback | |
from datetime import datetime | |
import adsk.core | |
import adsk.fusion | |
def run(context): | |
ui = None | |
try: | |
app = adsk.core.Application.get() | |
ui = app.userInterface | |
product = app.activeProduct | |
design = adsk.fusion.Design.cast(product) | |
rootComp = design.rootComponent | |
exportMgr = design.exportManager | |
with tempfile.TemporaryDirectory() as tmpdirname: | |
tmpfilename = os.path.join(tmpdirname, f'{rootComp.name} {datetime.now().strftime("%Y-%m-%d %H%M%S")}.stl') | |
stlRootOptions = exportMgr.createSTLExportOptions(rootComp, tmpfilename) | |
stlRootOptions.sendToPrintUtility = False | |
stlRootOptions.meshRefinement = 0 # High | |
exportMgr.execute(stlRootOptions) | |
subprocess.run([printUtilityPath, tmpfilename]) | |
except: | |
if ui: | |
ui.messageBox('Failed:\n{}'.format(traceback.format_exc())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment