Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
Simple Math with Variables
romeograham
Member, csevp Posts: 676 PRO
I am trying to use a Feature Studio to set up project variables - to be used in a single Document.
I have, say, two specifications (Hmax & Hmin). I can set up Variables (setVariable) no problem.
Any help would be great!
Thanks
Romeo
I have, say, two specifications (Hmax & Hmin). I can set up Variables (setVariable) no problem.
setVariable(context, "Hmax", 30 * millimeter); setVariable(context, "Hmin", 28 * millimeter); setVariable(context, "Hrange" = (Hmax - Hmin)); /*how do I do math in this variable?*/Now, I'd like to make a new "Hrange" Variable, that does a little simple math with those two variables:
setVariable(context, "Hrange" = (Hmax - Hmin)); /*how do I do math in this variable?*/However, this expression doesn't work. I tried a few different ways to do it, but even this simple thing is beyond my understanding. I'm not sure what search terms will help in the Documentation - haven't had luck with the searches that made sense to me.
Any help would be great!
Thanks
Romeo
0
Comments
Thanks for the quick help @_anton !
setVariable(context, "Hrange", getVariable(context, "Hmax") - getVariable(context, "Hmin"));
I thought that's how I started out, but wasn't successful.
Can you paste a little example here?