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.

How to inhibit precondition enums based on earlier entry.

owen_sparksowen_sparks Member, Developers Posts: 2,263 PRO
Hi folks.

Looking for some help regarding precondition enums, and specifically an elegant method of inhibiting some options depending on what is entered earlier.

Suppose we have one enum for drink type, and another for drink size

export enum Drink_Type
{
    annotation { "Name" : "FizzyPop" }
    POP,
    annotation { "Name" : "Juice" }
    JUICE,
    annotation { "Name" : "Beer" }
    BEER
}

export enum Drink_Size
{
    annotation { "Name" : "Small" }
    SMALL,
    annotation { "Name" : "Medium" }
    MEDIUM,
    annotation { "Name" : "Large" }
    LARGE



annotation { "Name" : "Select Drink Type" }
definition.DrinkTypeChosen is Drink_Type;
                
annotation { "Name" : "Select Drink Size" }
definition.DrinkSizeChosen is Drink_Size;

Further suppose Beer is only available in Medium and Large.  (Who'd want a small beer anyway?)  

How do we take away the option for the user to pick a small beer?

The least terrible idea I've come up with so far is to have multiple enums populated as to what's available:-

export enum Drink_Size_Default
{
    annotation { "Name" : "Small" }
    SMALL,
    annotation { "Name" : "Medium" }
    MEDIUM,
    annotation { "Name" : "Large" }
    LARGE


export enum Drink_Size_Beer
{
    annotation { "Name" : "Medium" }
    MEDIUM,
    annotation { "Name" : "Large" }
    LARGE


if (definition.DrinkTypeChosen == Drink_Type.BEER ))
            {
                       annotation { "Name" : "Select Drink Size" }
                       definition.DrinkSizeChosen is Drink_Size_Beer;
            }
            else
            {
                       annotation { "Name" : "Select Drink Size" }
                       definition.DrinkSizeChosen is Drink_Size_Default;
            }  

Is this plausible?

Is there a cleaner more elegant method?

I think what I'm really after is something along the lines of-
     
if definition.DrinkTypeChosen = Drink_Type.BEER  then  enum Drink_Size.Small.hidden = true   

As ever, thanks for your help.

Owen S.     
Production Engineer
HWM-Water Ltd

Best Answers

Answers

  • owen_sparksowen_sparks Member, Developers Posts: 2,263 PRO
    Thanks Gents, excellent information.

    The benefits of the table method seem to outweigh the minor inconvenience of setting them up.

    I really appreciate you guys taking the time to explain the process.

    @kevin_o_toole_1 This is for a "Nut Pocket" featurescript that I said I'd have a go at.  (My first attempt at fs, so please don't expect much.)  I'll make my first stab at the problem public later today.

    Cheers,
    Owen S.



    Production Engineer
    HWM-Water Ltd
  • MBartlett21MBartlett21 Member Posts: 1,552 EDU
    I'll make my first stab at the problem public later today.
    @owen_sparks
    Is the document public?
    If so, what is the link I would use to get to it?
    MB - I make FeatureScripts: view FS (My FS's have "Official" beside them)
Sign In or Register to comment.