Multiple IF condition

Hi guys, i need help…

What i want to achieve is determine if door is single-swing, double swing or uneven.

if Door type name starts with D1, write Single Swing.
If it starts with D2, write Double Swing, if D3 then Uneven Door.

how can i do this? I’m playing with the If node but the value is writing at the wrong door…

do you want to write the value in a specific parameter ?

Yes, i will write the value to a specific parameter later…

this concept will help you, if some D’s are missing you will get warning but it is ok it will work

d1

1 Like

Thanks will give this a try…

Thanks @khuzaimah.ElecEng, that worked!

1 Like

If you want to keep things a bit more tidy you can use a python script as well like so:

EDIT:
the ‘elements’ variable is not needed, don’t know why i put it in there hehe, your python script needs just one input, the Element.Name list.

2 Likes

with this i will only have one Set Element Parameter by Name?
thanks will try tomorrow…

Yes. This python node creates a list of strings that’s the same length of your input. So only one setElement node is required.
Let me know how it goes :wink:
Paolo

1 Like

Or you can do this natively in DesignScript too!

This allows us to run the following: Test this condition - Give a result if true, give a result if false. But in the false space we nest another test :slight_smile: This is similar to the way you do this in Revit.

// Test ? ResultIfTrue : ResultIfFalse (Nest this)
String.StartsWith(str, "D1") ? "Single Swing" :
String.StartsWith(str, "D2") ? "Double Swing" : "Unknown";
7 Likes

Thanks, it worked as well. Good this is since there is only one output for the value, i can convert this script to a node. Thank you so much.

Thanks for the reply, i need at least 3 conditions, i may add more in the future…is it also possible here?

EDIT :
just tested and it worked as well…i added more options and it runs well.

Thank you so much guys for the options. I learned something new.

2 Likes

You are most welcome! :slight_smile: I find DesignScript to contain a lot of awesome, time-saving shortcuts. I use it liberally in all of my graphs.

2 Likes

This is also a good application for using a dictionary

1 Like

I’m really not familiar with dictionaries, can you show me an example if its not too much to ask?

using the inputs you described above: you create your dictionary mapping values to each other, then you can just run the list of objects through the Dictionary.ValueAtKey node to get the list of values associated with the key.

3 Likes

Thanks, this one worked as well…i use String.Substring to trim my list as my Door type name doesn’t have the dashes.

Can you share a script (file or image) of how you got it to work with a dictionary… or any of the other suggestions?

just follow the post by @mclough and you should be okay, or you can also share what you have and we’ll see it from there

I got it to work :slight_smile:

1 Like