Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. 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.

BOOLEAN IN UI

papawopapawo Member, Developers Posts: 206 PRO
I have 2 boolean selection in UI.
How to inactivate other boolean  if user selected other one?
Tagged:

Best Answer

Answers

  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    You can make a parameter appear conditionally based on other parameters by defining them inside an if statement, like so:
    annotation { "Name" : "Boolean 1" }
            definition.boolean1 is boolean;
    
            if (!definition.boolean1) {
                annotation { "Name" : "Boolean 2" }
                definition.boolean2 is boolean;
            }         

  • papawopapawo Member, Developers Posts: 206 PRO
    edited November 2016
    how to make boolean1 disappear if boolean2 is chosen?
  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    Unfortunately there's no way to do that right now. Inputs can only control visibility of other inputs below them, not above them.

  • john_f_carrjohn_f_carr Onshape Employees Posts: 74
    If you have three valid states (false+false, false+true, true+false) you can use an enumeration instead of a pair of booleans.
  • mahirmahir Member, Developers Posts: 1,307 ✭✭✭✭✭
    I forgot what it's called exactly, but there is a new Horizontal_UI_Hint option that lets you list an enumeration as a row of mutually exclusive horizontal buttons. This seems well suited to your purpose.
  • papawopapawo Member, Developers Posts: 206 PRO
    @john_f_carr - can you do an example?
  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    If your boolean options are, for instance, "With square hole" or "With round hole", you can instead have a dropdown menu (an enum) with choices for hole type "None", "Square", or "Round".

    Here's a simple example feature doing this:
    https://cad.onshape.com/documents/d23d3f02d297f1a626d988ff/w/f7169c9d20aac5513724f724/e/1a5ba32207c8142eba85d86e




  • papawopapawo Member, Developers Posts: 206 PRO
    edited November 2016
    @kevin_o_toole_1 -   that is great but what I am aiming to do is similar below. I wanted the user to pick only one option and when he does other option will disappear or disabled . Main 2 booleans will only appear if nothing is selected or 1 boolean were unselect.

    https://cad.onshape.com/documents/583de44c545b20104cad6da9/w/3c81f383481ff03c72213fc0/e/1743674a7d5a5a04c35b645d

  • papawopapawo Member, Developers Posts: 206 PRO
    edited November 2016
    the 2 boolean are separate choices with separate features for specific part.
    if user pick boolean 1 it must be for part1 and it will cut a "square", and if boolean 2 , it must be for part 2 and it will cut a "triangle"
    interchanging will be wrong .


    i want user to pick 1 of the 2 boolean only . and then use the same featurescript again for the other part.

    but if this is impossible. the nearest thing i can do is the horizontal row sample you did, unless you have more idea under your sleeve.  :)

  • mahirmahir Member, Developers Posts: 1,307 ✭✭✭✭✭
    The nature of FeatureScripts is that you can go back and make changes just like a regular feature. What you're looking to do is contrary to that workflow. If a user wanted option 1 but clicked option 2 by accident, he'd have to exit the feature and start again. This doesn't sound very user friendly. I'd stick to an enum, either dropdown or horizontal.
  • papawopapawo Member, Developers Posts: 206 PRO
    @mahir ---  If a user wanted option 1 but clicked option 2 by accident, he'd have to exit the feature and start again. 

    user can still go back by unclicking either of the boolean.

    but anyway..i guess i will go with the horizontal..

    thanks people.  :)
Sign In or Register to comment.