boolean annotation default base on an enum

jelte_steur_info
jelte_steur_info Member Posts: 683 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

  • NeilCooke
    NeilCooke Moderator, Onshape Employees Posts: 6,123 image
    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

  • NeilCooke
    NeilCooke Moderator, Onshape Employees Posts: 6,123 image
    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_steur_info
    jelte_steur_info Member Posts: 683 PRO

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