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.
list of boolean
papawo
Member, Developers Posts: 206 PRO
I want to export a list of boolean , similar to export enum but list of strings, where user can check 1 or more strings.
Can somebody point me to the right direction?
Can somebody point me to the right direction?
Tagged:
0
Best Answers
-
kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565What do you mean by export?
In a feature dialog, several boolean parameters can be created in succession by simply defining several boolean parameters:annotation { "Name" : "My First Boolean" } definition.myBoolean1 is boolean; annotation { "Name" : "My Second Boolean" } definition.myBoolean2 is boolean; // ...
5 -
Jake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,646@papwo
An enum is a special variable type that is present in most programming languages which allows the programmer to define a mutually exclusive set of values which a variable can take. Here is an explanation for Java:
http://tutorials.jenkov.com/java/enums.html
So if you do something like this in FS:export enum NUMBER { ONE, TWO, THREE, FOUR } // Later, in a feature precondition definition.num is NUMBER
you are saying that definition.num must be one of those four values you defined earlier. When translating this into UI, the logical choice for us was to make this into a dropdown (or tabs if using the HORIZONTAL_ENUM UIHint).
If you instead wanted 4 checkboxes, there is no way you could pack those into one variable. There are 4 separate true/false values you're trying to keep track of. You would have to do something like:// In a feature precondition definition.one is boolean; definition.two is boolean; definition.three is boolean; definition.four is boolean;
You're welcome to pack these into a predicate if you want, but it doesn't really matter if they're in a predicate or just in the precondition itself.Jake Rosenfeld - Modeling Team5
Answers
In a feature dialog, several boolean parameters can be created in succession by simply defining several boolean parameters:
An enum is a special variable type that is present in most programming languages which allows the programmer to define a mutually exclusive set of values which a variable can take. Here is an explanation for Java:
http://tutorials.jenkov.com/java/enums.html
So if you do something like this in FS:
you are saying that definition.num must be one of those four values you defined earlier. When translating this into UI, the logical choice for us was to make this into a dropdown (or tabs if using the HORIZONTAL_ENUM UIHint).
If you instead wanted 4 checkboxes, there is no way you could pack those into one variable. There are 4 separate true/false values you're trying to keep track of. You would have to do something like:
You're welcome to pack these into a predicate if you want, but it doesn't really matter if they're in a predicate or just in the precondition itself.