IF function with 3 options (or choose?)

I need to choose from a list of 3 types of tubes, each one with a different thickness and weight.
Like this :
–Type 1 → Thickness 1.0 → weight 0.690
–Type 2 → Thickness 2.0 → weight 0.170
–Type 3 → Thickness 3.5 → weight 0.790

So, it i select type one, the other two attributes must come out.

The first part: THICK was solved, as i formulated “select from a list” and then write the type and widht,Therefore, if I select “type 1”, its thickness is chosen, with the “optionlabel” option.

attribute: type-> select from a list
Thickness: =optionlabel("type)

So far so good, now i need that “WEIGHT” to convert to the value previously mentioned.

I tried to solve it with IF, and i couldnt make it work,
i tried with CHOOSE, the two first options work fine but I can’t get it to work with the third option

=CHOOSE(type, 0.690, 1.170, 0,790)
the third comes out empty…

I show you the example in skp:

Tube EXAMPLE.skp (20.3 KB)

UPDATE:

In the meantime i did this:

type 1 - 1
type 2 - 2
type 3 - 3

and then i created an attribute called “thickness” and =CHOOSE(OPTIONINDEX(“type”),0.690,1.170,0.790)

so far it works, but all these suggestions are VERY useful to have in order to resolve these kind of issues, as i find the skechup tutorials quite basic and there are few videos online. i am going to try all these options

Maybe nesting another IF in the formula. Something like this:

weight = IF(thickness=1, 0.690, IF(thickness=2, 0.170, 0.790))

  • If the thickness is 1, then the weight is set to 0.690.
  • If the thickness is 2, then the weight is set to 0.170.
  • If the thickness is neither 1 nor 2 (which implies it is 3.5 in your case), then the weight is set to 0.790.
1 Like

text.skp (30.3 KB)

the third value is 3,5

another way
=choose(int(type), 0.690, 1.170, 0.790)

Thank you, corrected!

using “,” instead of “.” can preserve text, otherwise functions will convert “numerical” text to numbers

In the meantime i did this:

type 1 - 1
type 2 - 2
type 3 - 3

and then i created an attribute called “thickness” and =CHOOSE(OPTIONINDEX(“type”),0.690,1.170,0.790)

so far it works, but all these suggestions are VERY useful to have in order to resolve these kind of issues, as i find the skechup tutorials quite basic and there are few videos online. i am going to try all these options

Thanks to this marvelous community and than you guys for being always there to help :heart_eyes: happy holidays!

1 Like