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.
Default values not working.
adamohern
Member, OS Professional Posts: 216 PRO
I'm filling in the default values in my feature. They look fine in the code (no error flags), but they seem to be ignored when instantiating the feature. Is there a trick to getting defaults to work properly?
0
Comments
To change the user-visible default for booleans, enums, and strings, use the "Default" annotation:
annotation { "Name" : "Hollow", "Default" : false } definition.isHollow is boolean;
To change the user-visible default for a length, angle, or number, you'll need to specify it inside a value bound, which you can create as a constant before your feature:
Note that the default values are different based off a users' default units. Check out the valueBounds module for some examples of bounds used in Onshape features.
I agree the difference is confusing now, but fortunately this stuff will be documented better in 1.45.
This is obviously redundant. Is there a cleaner way to do this if all I want is a default value regardless of display unit?
Unfortunately, the precondition analysis expects the BOUNDS that you provide to be declared as a map literal, so you can't even make a simple function like lengthBoundsWithExactDefault(1/4 * inch) which would return the right thing.
For now the syntax you're using is the best thing available, but yeah, it's not great. We'll think about making the precondition analysis smarter, and adding lengthBoundsWithExactDefault to the Standard Library.