Equation iff

 Hello everyone ,
I have a small problem, I can 't  make an equation on Solidworks.  Let me explain.
I have a variable that must be = -50 if a component is even. And = 0 if the component is odd.       
So I tried: IFF("component"=2, -50,0)  and no result, I 'm drying.  

example


equation.png

Hello

Is it possible to make a family of parts because with Excel it's simpler.

may the force be with you.

 

2 Likes

Looking at the list of SOLIDWORKS functions it doesn't seem possible:

SW Functions

Otherwise, a macro or a family of parts to use the 'mod' operator and you're done:

Mod Operator

Hello

In the SOLIDWORKS doc

Visual Basic If Function

You can also use the If function in Visual Basic by specifying a dimension in a template.

This function returns every other value based on the evaluation of an expression.

Thus, if the specified equation is "D1@Sketch1" = (If("D1@Sketch4">15, 20, 10)) + 8, then :

If "D1@Sketch4" is ...Then "D1@Sketch4">15, 20, 10 is set toAnd "D1@Sketch1" is set to ...
> 152028
<= 151018

Kind regards

Alan

1 Like

Hello

I think the problem comes from calculation of calculation. Let me explain, if I make an if of this type on a manually modified global variable it applies correctly.

For the equation in the screenshot, the calculation is waiting for the previous equation to be solved, so I have a doubt about its application in dynamics. A little Ctrl+Q doesn't solve the problem?

Thank you for your leads, I don't know enough about the subject to apply your advice, I will study the issue of room families later.

However my equation works, it is going from IF to IFF. So I'm going to repeat it for all the values including the previous results instead of 0. 

Thank you for your answers!