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,660 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.     
Business Systems and Configuration Controller
HWM-Water Ltd

Best Answers

Answers

  • owen_sparksowen_sparks Member, Developers Posts: 2,660 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.



    Business Systems and Configuration Controller
    HWM-Water Ltd
  • MBartlett21MBartlett21 Member, OS Professional, Developers Posts: 2,034 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 - draftsman - also FS author: View FeatureScripts
    IR for AS/NZS 1100
  • Evan_ReeseEvan_Reese Member Posts: 2,060 PRO
    @owen_sparks
    I'd definitely use the heck out of a feature like this. Did you end up getting it to a point you were happy with?
    Evan Reese / Principal and Industrial Designer with Ovyl
    Website: ovyl.io
  • owen_sparksowen_sparks Member, Developers Posts: 2,660 PRO
    @owen_sparks
    I'd definitely use the heck out of a feature like this. Did you end up getting it to a point you were happy with?
    @Evan_Reese
    Sorry I became ill after posting this so real life got in the way.  After getting better I'm afraid I didn't get around to picking it up again.
    Owen S.
    Business Systems and Configuration Controller
    HWM-Water Ltd
  • Evan_ReeseEvan_Reese Member Posts: 2,060 PRO
    @owen_sparks
    I'd definitely use the heck out of a feature like this. Did you end up getting it to a point you were happy with?
    @Evan_Reese
    Sorry I became ill after posting this so real life got in the way.  After getting better I'm afraid I didn't get around to picking it up again.
    Owen S.
    The important thing is that you're ok! I might take a stab at something similar in the future. It's a good concept.
    Evan Reese / Principal and Industrial Designer with Ovyl
    Website: ovyl.io
Sign In or Register to comment.