PDA

View Full Version : IF statements in Yes/No parameters



Mr Spot
2004-05-22, 11:27 PM
I'm attempting to write a statement in a Yes/No parameter that basically says if A parameter is Yes then B parameter is No and I'm unsure of the formatting? I understand how to format an if statement,

ie: If (condition, result if true, result if false) however i dont' know how to apply it to a yes/no situation. Could someone please enlighten me???

Thanks.

Steve_Stafford
2004-05-22, 11:50 PM
Check HERE (http://www.zoogdesign.com/forums/phpBB2/viewtopic.php?t=3836&highlight=conditionals)

Mr Spot
2004-05-23, 12:01 AM
From that I can understand how to make one the opposite to another, ie one equalling not the other but what if i don't want it simply to be not the other. That is, if A is yes, B is no. But if A is no, B can still be no. To furher explain why i would want to do this i have two elements operating in the same space in a family and they can't both exist at the same time. That is you can have one or the other or none at all... I'm beginning to think its not possible.

In the end i'm just trying to place a restriction on the value rather than define an answer.

ita
2004-05-23, 02:20 AM
Mr Spot, in the false statement, imbed another if statement with the reverse condition.

if(condition,true, {if (condition,true,false)})

trust this works in Revit!!

Mr Spot
2004-05-24, 12:56 AM
That would work if i wanted to make them opposites however its only a restriction that they can't exist together... Which I've now discovered is impossible.

Chad Smith
2004-05-24, 01:17 AM
Could you possibly post the family you are trying to do this in, and a brief description of the parameters that should be affecting your On/Off parameters?

beegee
2004-05-24, 01:41 AM
But if A is no, B can still be no.

It looks to me as though you need to set up the condition for this to to occur, as well as the condition " If A = Yes, B = No "

LRaiz
2004-05-24, 02:18 AM
Would the statement below do what is needed?
B = IF( A, false, B)

beegee
2004-05-24, 03:37 AM
My interpretation of that formula is that when A is false, B is unchanged. That may work for Mr. Spot, but B may need to be set a value before this formula that corresponds with a condition, or else B will remain constantly on or constantly off whenever A is false.

I think we need more specifics before this can be analysed further.

Mr Spot
2004-05-24, 04:40 AM
I can't actually post the family as I was working on this at home. However I'll try to explain better.

Consider two elements A & B. The following options need to be possible:

When,
A = visible B = invisible
A = invisible B = can be either

and vice-versa, ie:

B = Visible A = Invisible
B = Invisible A = can be either

I want to be able to place a constraint on both A & B to say that they cannot both be visible at the same time.

Thanks.

Mr Spot
2004-05-24, 04:42 AM
The statement suggested by LRaiz wouldn't work as there is a circular chain of references. Ie: B cannot be in the formula as the formula is to define B.

jason.martin
2004-05-24, 06:28 PM
If you don't mind doing this in a different manner, it can be done quite easily.

Visibility (int) : 0, 1, or 2 (actually you can put in anything and it will act just like 0)

ItemAVisible (Yes/No) : Visibility = 1
ItemBVisible (Yes/No) : Visibility = 2

Setting Visibility to 0 (or any thing other than 1 or 2) will turn off both items. Setting Visibility to 1 will turn on item A, and setting Visibility to 2 will turn on item B.

If you wanted to make this a bit more complicated you could almost make it a bitwise comparison and say something like

ItemAVisible (Yes/No) : OR ( Visibility = 1, Visibility = 3)
ItemBVisible (Yes/No) : OR ( Visibility = 2, Visibility = 3)

So state 0 means show nothing, 1, means show Item A, 2 means show Item B and 3 means show both.

hth

jason

Mr Spot
2004-05-24, 10:23 PM
Thanks for the info, have you tried this at all? I'm just unsure of how you plan to program in switches 0, 1 & 2? What type of parameters would they be?

jason.martin
2004-05-24, 10:37 PM
Yes, I built a quick family using this type of procedure. The Visiblity parameter was an integer. The params could be either instance or type params. I've attached a simple example with 3 sections (the head part of mickey is always visible, but each of the "ears" can be turned on and off based on the Visibility integer).

hth

jason

gnl
2004-06-05, 07:20 AM
Great Idea jason.martin,
I liked the switch settings you posted.
My idea for Mr Spot would be: why don't you try putting a simple Not(<condition>) condition in the visible settings of either A or B?
This will generate the exclusive visibility behaviour you want to achieve... it's also automatically controlled this way...
see attached file...

it's not perfect, but you could work on it a bit more I think...

cheers