Dynamo İf/and/else statement

Hello,

I have two changeable input values and one output value in my family and i want to do that. For example, if my “a” value is 1 and “b” value is 2, output “c” value must be 10.

İn revit i can do that in this way, if(a=1,b=2),10,0) but i didn’t do that with dynamo codes ? Could you help me ?

In a code block try this:

Input =="a"?
1:
Input == "b"?
2:
Input == "c"
10:
"Unexpected value! Check your dataset!"

That’s from memory on my phone so it may be off. Cpu is locked up doing some heavy lifting at the moment so I can’t confirm.

General idea is:

Test ?
IfTrue : 
IfFalse;

The ? marks the end of the test and initialized the function so don’t forget it.
The : divides the true from false so don’t forget it either.
The ; marks the end of the line of code, so… well you get the idea.

Nesting can go pretty deep. I haven’t found a limit yet anyway. Nesting is also possible on either the true statement or the false statement:

    Test ?
    IfTrueTest?
    IfTrueTestTrue:
    IfTrueTestFalse:
    IfFalseTest?
    IfFalseTestTrue:
    IfFalseTestFalse;

Helps to use offset tabs (though the forum doesn’t like typing them on a phone) for various levels of nesting so you know where you are in a given statement.

4 Likes