Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Setting model parameters

1 REPLY 1
SOLVED
Reply
Message 1 of 2
jeremiahrose
853 Views, 1 Reply

Setting model parameters

I am using the API to sketch many circles like this:

circle = sketch.sketchCurves.sketchCircles.addByCenterRadius(center, 10)

However, what I actually want to do is set each circle's radius to equal a user parameter called "userRadius". If I was doing this in the UI, I would sketch the circle and enter the string "userRadius" into the radius input box, but the addByCenterRadius function does not accept a string.

 

I'm aware that you can use the ModelParameters object to get an individual parameters by calling "itemByName", but this isn't useful at all because I do not know the name of the parameter. And I can't find a way to get the parameter name ("d1" "d22" "d76" etc) from the circle object.

How do I create an object and set its dimensions to equal a user parameter in the API? How do I create a model parameter? How do I find the model parameters associated with a particular object if all I have is the object as a variable?

 

Thanks!
Jerry

1 REPLY 1
Message 2 of 2
jeremiahrose
in reply to: jeremiahrose

Figured it out. I needed to add a SketchRadialDimension to the SketchCircle, then access the ModelParameter from there and set it's expression:

# create a SketchCircle with a placeholder radius. centerPoint is a Point3D
circle = sketch.sketchCurves.sketchCircles.addByCenterRadius(centerPoint, 1)
# create a SketchRadialDimension to constrain the circle's radius. textPoint is the position of the dimension's text.
rd = sketch.sketchDimensions.addRadialDimension(circle, textPoint, True)
# Set the expression of the parameter
rd.parameter.expression = 'userRadius'

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report