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: 

Model parameters, expressions and values.

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
brad.bylls
269 Views, 2 Replies

Model parameters, expressions and values.

Using the below code to create an extrusion.
I am able to change the top name(yellow) of the parameter.
What I would like to do is change the sub-name(blue) and the 'Name'(green)
Lastly I would like to change the expression(red) to be the same as the value(in)
Because it is a TwoSidesExtent, I am at a loss as to how to do it.
# Create the head clearance
        cutHeadSketch = sketches.add(xyPlane)
        cutHeadCircle = cutHeadSketch.sketchCurves.sketchCircles.addByCenterRadius(center, numBoltCboreDiam/2)
        cutHeadSketch.sketchDimensions.addDiameterDimension(cutHeadCircle, adsk.core.Point3D.create(-110))
        cutHeadSketch.name = 'Head Clearance Sketch'
        cutHeadProf = cutHeadSketch.profiles[0]
        cutHeadExtInput = extrudes.createInput(cutHeadProf, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
        distance1 = adsk.fusion.DistanceExtentDefinition.create(adsk.core.ValueInput.createByReal(numBoltClearanceLength - numBoltBodyLength))
        distance2 = adsk.fusion.DistanceExtentDefinition.create(adsk.core.ValueInput.createByReal(numBoltTravelLength))
        deg0 = adsk.core.ValueInput.createByString("0 deg")
        cutHeadExtInput.setTwoSidesExtent(distance1, distance2, deg0, deg0)
        cutHeadExt = extrudes.add(cutHeadExtInput)
        cutHeadExt.name = 'Head Clearance Extrude'
 
Error.png
Brad Bylls
2 REPLIES 2
Message 2 of 3
kandennti
in reply to: brad.bylls

Hi @brad.bylls .

 

I don't think sub-name (blue) can be changed.
(I couldn't do it even with GUI)

 

'Name' (green) can be changed by getting the model parameters.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-86e451c2-785f-4cdf-97c9-ecba4882c8d1 

 

Wouldn't expression (red) be'in'by using createByString?

 

 

        # Head Clearance Sketch
        cutHeadSketch = sketches.add(xyPlane)
        cutHeadSketch.name = 'Head Clearance Sketch'

        cutHeadCircle = cutHeadSketch.sketchCurves.sketchCircles.addByCenterRadius(center, numBoltCboreDiam/2)
        cutHeadCircle_Dia = cutHeadSketch.sketchDimensions.addDiameterDimension(cutHeadCircle, adsk.core.Point3D.create(-1, 1, 0))
        cutHeadCircle_Dia.parameter.name = 'BoltCboreDiam'# parameter rename
        
        # Head Clearance Extrude
        cutHeadProf = cutHeadSketch.profiles[0]
        cutHeadExtInput = extrudes.createInput(cutHeadProf, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)

        distance1 = adsk.fusion.DistanceExtentDefinition.create(
            adsk.core.ValueInput.createByString('{} in'.format(numBoltClearanceLength - numBoltBodyLength)))# use createByString

        distance2 = adsk.fusion.DistanceExtentDefinition.create(
            adsk.core.ValueInput.createByString('{} in'.format(numBoltTravelLength)))# use createByString

        deg0 = adsk.core.ValueInput.createByString("0 deg")

        cutHeadExtInput.setTwoSidesExtent(distance1, distance2, deg0, deg0)
        cutHeadExt = extrudes.add(cutHeadExtInput)
        cutHeadExt.name = 'Head Clearance Extrude'

        cutHeadExt.extentOne.distance.name = 'Head_Length'# parameter rename
        cutHeadExt.extentTwo.distance.name = 'Travel_Length'# parameter rename
        cutHeadExt.taperAngleOne.name = 'Head_Angle'# parameter rename
        cutHeadExt.taperAngleTwo.name = 'Travel_Angle'# parameter rename

 

 

Message 3 of 3
brad.bylls
in reply to: kandennti

Thank you for the help.

It worked.

Brad Bylls

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