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?
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.
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.
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.
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.
thank you once again!
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?
My value is 8.085, therefore l am expecting response âbâ, but l get ââ
Are you certain all your values are âflattenedâ?
You donât have a valid conditional statement. You need to use && for a range of values.
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.
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.
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.
Ya sorry it was a string. I was zoomed in to much and forgot what the data was.
Hey Jacob,
This worked for me when I just had a single item as the then (i.e. Family 1 Goes Here"). I need a list to be created differently based on the input. When I use the following, it only results in the first item of the list:
Do I have the syntax wrong?
Thanks,
Scott
Hereâs a link to the original post: What if you have more than 1 if statement? - Revit - Dynamo (dynamobim.com)
If does not utilize the internal lacing mechanisms, so it canât process variable depth lists. Instead separate the single output into two or three.
First have your if statement return an index number as a new variable, then build a list of all your desired values, and then pull the resulting set from the list.
Looks like this:
I think @jacob.small nailed it. I started to give it a try before he posted and then continued for my own benefit. Thanks, for the clean solution Jacob.
Failed solution 1:
Failed solution 2 (Basically the same as above):
Working solution (same concept as Jacobs):
It looks like the new if node will be able to accommodate this function.