Skip to content

Instantly share code, notes, and snippets.

@eak24
Created March 20, 2018 18:02
Show Gist options
  • Save eak24/d3e1b67db03cad4ab8e139fee60633f0 to your computer and use it in GitHub Desktop.
Save eak24/d3e1b67db03cad4ab8e139fee60633f0 to your computer and use it in GitHub Desktop.
Change a 'child component' expression in Fusion 360
#Author-
#Description-
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
fd = adsk.fusion.FusionDocument.cast(app.activeDocument)
data_file = fd.documentReferences.item(0).dataFile
child = app.documents.open(data_file)
param = adsk.fusion.FusionDocument.cast(child).design.userParameters.itemByName("side_lengths")
param.expression = "5 m"
child.save("this is different!")
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