A good friend created the attached piece of code for me. I got that to work. I will try to work from there, but I hoped somebody would have done more work prior to me:
#Author-
#Description-
import adsk.core, adsk.fusion, adsk.cam, os, traceback
def get_immediate_children(component😞
# Get the child occurrences (components) directly under the specified component
child_occurrences = component.occurrences
# Extract the actual component objects from the occurrences
child_components = [occ.component for occ in child_occurrences if occ.isVisible]
return child_components
def set_parameter(app, design, parameterName, parameterValue😞
ui = app.userInterface
userParameters = design.userParameters
userParameter = userParameters.itemByName(parameterName)
if userParameter:
userParameter.expression = str(parameterValue)
else:
ui.messageBox('User-Parameter "{}" nicht gefunden.'.format(parameterName), 'Fehler')
return
# update parametric text plugin
app.fireCustomEvent('thomasa88_ParametricText_Ext_Update')
adsk.doEvents()
adsk.doEvents()
def export_stl(exportMgr, body, parameterValue😞
# Dateinamen aus dem Körpernamen ableiten
fileName = os.path.join("D:\\tmp", body.name + '_' + str(parameterValue) + '.stl')
stlOptions = exportMgr.createSTLExportOptions(body, fileName)
stlOptions.sendToPrintUtility = False # Setze auf True, wenn du die Exportdatei direkt drucken möchtest
# Körper als STL exportieren
exportMgr.execute(stlOptions)
def run(context😞
ui = None
try:
# Zugriff auf Fusion 360 UI
app = adsk.core.Application.get()
ui = app.userInterface
# Dokument und Design erhalten
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
if not design:
ui.messageBox('Kein aktives Fusion 360 Design.', 'Fehler')
return
# Get the root component
root_component = design.rootComponent
# Get the immediate child components under the root component
immediate_children = get_immediate_children(root_component)
# User-Parameter ändern
parameterName = 'HoseDiameterInner' # Name des zu ändernden Parameters
for parameterValue in range(30, 50, 5😞
set_parameter(app, design, parameterName, parameterValue)
# Export
exportMgr = design.exportManager
for component in immediate_children:
export_stl(exportMgr, component, parameterValue)
ui.messageBox('Export erfolgreich abgeschlossen.')
except:
if ui:
ui.messageBox('Fehler aufgetreten:\n{}'.format(traceback.format_exc()))