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
Thanks will give this a try…
@khuzaimah.ElecEng, that worked!
April 25, 2019, 2:15pm
If you want to keep things a bit more tidy you can use a python script as well like so:
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.
with this i will only have one Set Element Parameter by Name?
thanks will try tomorrow…
April 25, 2019, 6:11pm
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
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
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";
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?
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.
You are most welcome!
I find DesignScript to contain a lot of awesome, time-saving shortcuts. I use it liberally in all of my graphs.
This is also a good application for using a dictionary
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.
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