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.
Use a variable in a boundSpec
Lee_Hesketh
Member, Developers Posts: 148 ✭✭✭
Hell again, how could I use a variable as the maximum value for a lengthBoundSpec?
Thanks
Lee Hesketh
Thanks
Lee Hesketh
There are 10 types of people in the world. Those who know binary, those who don't and those who didn't expect base 3!
Tagged:
0
Best Answers
-
kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565Technically, no: LengthBoundSpec's are computed statically (before any variables have values), so that the spec is constant for every instance of your feature.
I see two options.
The cleaner one is: Use a large max, then inside your feature, do a reportFeatureInfo if the value is above the MAX (explaining why), and change definition.length to MAX.
The other option is to add editing logic which changes definition.length to MAX if it goes above MAX.
5 -
kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565How about something like:
var myMax = 20 * centimeter; if (definition.myLength > myMax) { reportFeatureInfo(context, id, "Length entered greater than calculated max " ~ toString(myMax) ~ ". Using max value."); definition.myLength = myMax; } // ...build your thing
5
Answers
I see two options.
The cleaner one is: Use a large max, then inside your feature, do a reportFeatureInfo if the value is above the MAX (explaining why), and change definition.length to MAX.
The other option is to add editing logic which changes definition.length to MAX if it goes above MAX.