Setting model expression formulas

brad.bylls
Collaborator

Setting model expression formulas

brad.bylls
Collaborator
Collaborator

I am trying to set a model parameter expression in a script.

# Create the body clearance
    cutBodySketch = sketches.add(xyPlane)
    cutBodyCircle = cutBodySketch.sketchCurves.sketchCircles.addByCenterRadius(center, numBoltClearDiam/2)
    cutBodySketch.sketchDimensions.addDiameterDimension(cutBodyCircle, adsk.core.Point3D.create(010))
    cutBodySketch.name = 'Body Clearance Sketch'
    cutBodyProf = cutBodySketch.profiles[0]
    cutBodyExtInput = extrudes.createInput(cutBodyProf, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
    distance = adsk.core.ValueInput.createByReal((numBoltBodyLength-(numBoltBodyDiam * numThreadEngage)) * -1)
    cutBodyExtInput.setDistanceExtent(False, distance)
    cutBodyExt = extrudes.add(cutBodyExtInput)
    cutBodyExt.name = 'Body Clearance Extrude'
    cutBodyExt.expressions = 'd2 - ((d1 * 1.5) * -1 )'
 
The last line does not produce an error.
Is it possible to do this?
Brad Bylls
0 Likes
Reply
Accepted solutions (1)
574 Views
5 Replies
Replies (5)

goyals
Autodesk
Autodesk

From the code you shared it looks like you are setting expressions property on extrude feature but no such property exists there so it should throw exception. Expression set property is available on parameter class http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-0e50e797-b406-4c51-9bdb-d9aa62af920b



Shyam Goyal
Sr. Software Dev. Manager
0 Likes

brad.bylls
Collaborator
Collaborator

Thanks for the input.

However, that is for user parameters.

I want to put a formula in a model parameter.

 

Brad

Brad Bylls
0 Likes

brad.bylls
Collaborator
Collaborator

I can't see the replies so I don't know if it solved.

Brad Bylls
0 Likes

goyals
Autodesk
Autodesk
Accepted solution

I just found an old post showing how you can reference model parameters in an expression to create a feature.

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/reference-to-modelparameter-object-in-an-e...

This is example in API documentation showing how to use expression property of model parameters

http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-CB1A2357-C8CD-474D-921E-992CA3621D04

 

I hope it helps. Thanks.



Shyam Goyal
Sr. Software Dev. Manager
1 Like

brad.bylls
Collaborator
Collaborator

It was complicated but I figured it out from the second link.

Thank you so much.

Brad Bylls
0 Likes