Nested if function on solidworks

Hello

I want to determine a price for a piece based on its length (0-1 m, 1-2 m, 2-3 m). Is it possible to nest two if functions to be able to determine a price based on the length of an odds?

In my case, only three length ranges are possible and therefore only three prices. Maybe another solution than nesting yews can be used?

Thank you in advance.

Hello

It seems to me that it is possible. You just have to be careful with the parentheses closings, you get lost quickly!

1 Like

It seems to me too but I can't get a correct syntax (see attached photos).


capture_fonction_if.jpg

I have solidworks 2011 and I know it doesn't read if, you have to put iif.

Maybe that's still the case.

Hello

Several examples:

http://www.lynkoa.com/forum/3d/equation-if

http://www.lynkoa.com/forum/3d/comment-creer-une-succession-de-condition-dans-les-equations-solidworks

 

2 Likes

I already tried something like this I think.

And it only takes one if end per line.

You have to create several custom properties in a cascade in such a way that the last one reacts in the right way.

 

Fred

Hi Remi,

It's possible, here's the syntax:

= ( IIF ( ( "Longueur@Esquisse1" ) < 100 , 15 , IIF ( ( "Longueur@Esquisse1" ) < 150 , 30 , IIF ( ( "Longueur@Esquisse1" ) < 200 , 45 , 1 ) ) ) ) )

I'm attaching the SW file for example.

Indeed, the parentheses and their exact number is very important

Good luck 

Mick


gg.sldprt
4 Likes

Indeed, thank you for the last answer, so it is possible to write it on a single line. Thank you, it's perfect.

 

Thank you to everyone for the answers.