Last active
December 26, 2023 10:38
-
-
Save botamochi6277/e977a979e061372e84c067108c56a156 to your computer and use it in GitHub Desktop.
Fusion360 Script
This file contains 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
import adsk.core, adsk.fusion, traceback | |
import os.path, sys | |
def run(context): | |
ui = None | |
try: | |
app = adsk.core.Application.get() | |
ui = app.userInterface | |
# get active design | |
product = app.activeProduct | |
design = adsk.fusion.Design.cast(product) | |
# get all components in this design | |
allComps = design.allComponents | |
# get the script location | |
scriptDir = os.path.dirname(os.path.realpath(__file__)) | |
# create a single exportManager instance | |
exportMgr = design.exportManager | |
for num in range(2,15): | |
design.userParameters.itemByName('numPin').value = num; | |
numPin = design.userParameters.itemByName('numPin').value | |
# export the component one by one with a specified format | |
for comp in allComps: | |
compName = comp.name | |
fileName = scriptDir + "/" + "S" + str(int(numPin)) +"B-PH-SM4-TB" | |
# export the component with STP format | |
stpOptions = exportMgr.createSTEPExportOptions(fileName, comp) | |
exportMgr.execute(stpOptions) | |
# reset userParameters | |
design.userParameters.itemByName('numPin').value = 3; | |
ui.messageBox("finish"); | |
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