
Not applicable
04-12-2017
10:53 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm creating some UserParameters, and trying to pass them as arguments during creation of various shapes and features. When passing them, I use ValueInput.createByString("nameOfParameter"). This isn't working (error messages below). It works in the GUI. Here's my code:
import adsk.core, adsk.fusion, traceback def run(context): ui = None try: app = adsk.core.Application.get() ui = app.userInterface product = app.activeProduct design = adsk.fusion.Design.cast(product) # Get the root component of the active design rootComp = design.rootComponent #defining userParams userParams = design.userParameters userParams.add("strawDia", adsk.core.ValueInput.createByString("10 mm"), "mm", "") userParams.add("noOfPegs", adsk.core.ValueInput.createByString("3"), "", "") origin = adsk.core.Point3D.create(0, 0, 0) #first sketch, central hub hubSketch = rootComp.sketches.add(rootComp.xYConstructionPlane) hubCircles = hubSketch.sketchCurves.sketchCircles hubCircles.addByCenterRadius(origin, adsk.core.ValueInput.createByString("strawDia")) #uMag = adsk.core.UnitsManager #print(uMag.isValidExpression("strawDia*2", "mm")) except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
To see if it was getting evaluated correctly, I tried to use evaluateExpression and isValidExpression, but it always tells me I have the wrong type/number of arguments despite me adhering to the specification in the documentation.
I cannot use any of the ValueInput creation methods, not even createByReal. Only sending an actual double seems to work.
Could I pointed to what I'm missing?
Solved! Go to Solution.