Skip to content

Instantly share code, notes, and snippets.

@botamochi6277
Last active December 26, 2023 10:38
Show Gist options
  • Save botamochi6277/e977a979e061372e84c067108c56a156 to your computer and use it in GitHub Desktop.
Save botamochi6277/e977a979e061372e84c067108c56a156 to your computer and use it in GitHub Desktop.
Fusion360 Script
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