What if you have more than 1 if statement?


#1

Hey everyone, ive been looking through the forum for examples on multiple if statements. But, all i could find are one if statement examples. Does anyone know how to do this with nodes or design script?


Build directory path from DynamoPlayer input
#2

Try this code block:

a==6?
	"Family 1 Goes Here":
	a==2?
		"Family 2 Goes Here":
		"Family 3 Goes Here";

You can go as deep as you like, and remove the quotes to use different families which will become inputs to the node instead of strings.


#3

Hey Jacob,

Do i just put in the family name where it says “Family 1 Goes Here”? When i remove the quotations i get an error.


Replace item at index
#4

Post what you did so I can walk you through it. All versions of Dynamo for Revit was uninstalled by IT in my computer last night so unfortunately I can’t do it directly for you.


#5

HOLY MOLY! if this is what you meant, it worked!!! thank you thank you jacob


#6

That was it. For speed sake remove the a; b; c; … g; part. The input variable can be called after the fact in this case and it will make things read better and can help with performance on larger graphs too.


#7

thank you once again!


#8

Hi Jacob.

I have a scenario where a STRING response is required to be returned, depending on whether a value occurs between ranges of values. But l have tried it with IF statements, <=, >= etc, but no joy.

Any thoughts on what l am doing wrong?

image


#9

My value is 8.085, therefore l am expecting response ‘b’, but l get “”


#10

Are you certain all your values are “flattened”?


#11

You don’t have a valid conditional statement. You need to use && for a range of values.
image


#12

Just ask them in sequence - if it’s less than 5.4 then return the first value. If the value wasn’t less than 5.4 but it’s less than 8.5 then your number falls between 5.4 and 8.5. No need to check if it’s > 5.4 a second time.

That said, the logical statement you couldn’t find is:

T> 5.4 && T< 8.4

Though the upper value should likely be a <= test.


#13


#14

You’re still doing 2x the amount of computations here - Only ask something once unless you have a requirement to do it twice. By asking smallest to largest you’ll remove parts from the set sequentially.


#15

I am doing something wrong here but I cannot figure it out. Any of you have an Idea?

Edit: List.Firstitem output was a string not a number. Simple String.ToNumber and it works fine now.
Some times you get drawn into what you are doing and you forget to look at what you have done.


#16

What is the Object.Type for “Days”?

By the looks of it, I’d wager it’s not an integer.


#17

Ya sorry it was a string. I was zoomed in to much and forgot what the data was.