setting Plane setByOffSet - linking Offset to User Parameter

setting Plane setByOffSet - linking Offset to User Parameter

StephenCim-001
Advocate Advocate
710 Views
2 Replies
Message 1 of 3

setting Plane setByOffSet - linking Offset to User Parameter

StephenCim-001
Advocate
Advocate

Hi All

 

I have this snip of code.

#read in a User Parmeter

UserStoneFinalHeight = userParams.itemByName('StoneFinalHeight')

#Extract the value of the parmeter

offsetValue = adsk.core.ValueInput.createByReal(UserStoneFinalHeight.value)

#create a offer plane user the value from the parameter

planeInput.setByOffset(xyPlane, offsetValue)
planeStone = planes.add(planeInput)
planeStone.name = 'stone'
planeStone.isLightBulbOn = False

 

Now this works, but the Offset is not linked to the parameter , so if I change the parameter UserStoneFinalHeight the offset does not update.

 

With Dimensions , I can link a dimension a parameter with

stoneDim.parameter.expression = 'StoneRadius'  But I can't figure out how to link the offset to a parameter.

 

Can anyone help 😉

 

Cheers, Stephen

0 Likes
Accepted solutions (1)
711 Views
2 Replies
Replies (2)
Message 2 of 3

BrianEkins
Mentor
Mentor
Accepted solution

You're creating the reference plane by inputting a value.  It just happens that you got that value from an existing parameter but the call to add the reference plane doesn't know where the value came from.

 

What you need to do instead is pass in the name of the parameter.  Create the ValueInput object like this instead.  This way you're defining an expression that Fusion will use when creating the parameter that drives the offset value.  The expression could be more complex like UserStoneFinalHeight.name + "/2", which would create an expression that is half the value of the UserStoneFinalHeight parameter.

 

offsetValue = adsk.core.ValueInput.createByString(UserStoneFinalHeight.name)
---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 3

StephenCim-001
Advocate
Advocate

Thanks Brian

 

That worked and I would also like to thank you for the gear script/addin that ships with F360 I refer to it a lot 🙂

 

Cheers, Stephen

0 Likes