As you can see the If statement Dynamo itself offers isn’t exactly simple.
I’ll check for you if I can create a more elegant solution with a python script.
You can, you should add a similar if node to the false input of the other if node.
You’d have to think somewhat backwards from what you’d normally do when programming.
I’d look up how to put it in a code block or added python script, which would probably be a whole lot cleaner and actually simpler. But I have to admit that my knowledge of that is pretty terrible.
If statements in designscript are fairly straightforward.
Test ? True: False;
Where
Test is a comparison returning a true/false.
True is the desired result if the Boolean test returns true.
False is the result if the Boolean test returns false.
The ? marks the end of the test.
The : marks the end of the true.
The ; ends the line of code.
An example:
Math.Ceiling(a/2) == A/2?
“This is a even number”:
“This is an odd number”;
Feed in 2 and you’ll divide 2 by 2 and round up to 1, which will equal to 2 divided by two, so your output will be “this is an even number”. Feed in 3 and the math.ceiling function will round 3/2 up to 2 which isn’t equal to 3/2, so your result will return “This is an
odd number”.
You can nest these, but make sure you have the correct format. This gets a bit tough to do from memory, but this should give you an idea to play with:
just to be pedantic - this is not an if statement - it’s use of a conditional ternary operator (3 inputs) … I am a stickler for this kind of diction because it is helpful to use common terms to programming languages when moving into other languages or domains.
We should have a vocab lesson sometime and do a write up in a post. ‘Programming terms demystified’ would be very useful for the many new users being attracted as a result of the easy access provided by Dynamo - you do the teaching and I will do any back end heavy lifting I can.