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 parameter syntax?
Emily_Qi_Wang
Member Posts: 13 EDU
What is the syntax for setting default parameter values when defining a new feature?
I checked the doc files and SCOPE Weds slides that Kevin sent recently and didn't see this mentioned; apologies in advance if it's obvious and I missed it.
===
Code excerpt example (Also, are there code blocks in the Onshape forum discussion editor?)...
I checked the doc files and SCOPE Weds slides that Kevin sent recently and didn't see this mentioned; apologies in advance if it's obvious and I missed it.
===
Code excerpt example (Also, are there code blocks in the Onshape forum discussion editor?)...
precondition
{
annotation { "Name" : "Radius" }
isLength(definition.radius, LENGTH_BOUNDS);
annotation { "Name" : "Teeth" }
isInteger(definition.teeth, POSITIVE_COUNT_BOUNDS);
}
// function action stuff here //
{ /* default parameters can go here?? */ });
===
For the default parameters block, I tried a few things:
* "definition.teeth" : 10
* definition.teeth = 10
* "Teeth" : 10
* and so on...
Thanks in advance!
// function action stuff here //
{ /* default parameters can go here?? */ });
===
For the default parameters block, I tried a few things:
* "definition.teeth" : 10
* definition.teeth = 10
* "Teeth" : 10
* and so on...
Thanks in advance!
0
Comments
{ teeth : 10 }
should do it. Also{ 'teeth' : 10 }
. We have code blocks. Switch to HTML mode with the slash-in-angle-brackets icon and use code.../code around your code block.annotation { "Name" : "Merge with all", "Default" : false } booleanDefinition.defaultScope is boolean;
Default works for string, boolean, and enum. It doesn't work for number. I doubt there is a strong reason for it not working for number. Somebody needs to write the code. Maybe we'll get a feature request...In this case, the thing to do is to make a local copy of POSITIVE_COUNT_BOUNDS from valueBounds.fs and adjust the middle number (the default).