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 annotation default base on an enum

jelte_steur814jelte_steur814 Member Posts: 330 PRO

Hi,
i'm working on a featurescript with a selection driven array parameter that contains an Enum parameter and a Boolean parameter.

                annotation { "Name" : "Flip wall", "UIHint" : UIHint.OPPOSITE_DIRECTION, "Default" : true }
                wallShape.flipWall is boolean;

I'd like to set make the "Default" dependent on the chosen Enum. How can i do this?

the precondition doesn't allow to set/change variables. it also did not allow me to declare the same annotation twice (in an if/else)
Can it be done through editing logic? how can i get it to execute for each array parameter when the enum is changed?

Best Answer

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,802
    Answer ✓

    Editing logic fires every time the user makes a change so that would work, however if the user has manually flipped it, you would have to have another (hidden) parameter to store that interaction otherwise it could become quite annoying if the flip status changed each time.

    -OR-

    You could have two parameters with different names, then check the value of the enum in the main body of the code to decide which flip to use.

    Senior Director, Technical Services, EMEA

Answers

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,802
    Answer ✓

    Editing logic fires every time the user makes a change so that would work, however if the user has manually flipped it, you would have to have another (hidden) parameter to store that interaction otherwise it could become quite annoying if the flip status changed each time.

    -OR-

    You could have two parameters with different names, then check the value of the enum in the main body of the code to decide which flip to use.

    Senior Director, Technical Services, EMEA
  • jelte_steur814jelte_steur814 Member Posts: 330 PRO

    the latter will be easiest I guess, should have thought of that myself.

Sign In or Register to comment.