Dictionaries in Dynamo have been around for quite a while now. So far most of the time I only encountered them with certain nodes. I know there are some nodes OOTB to create them, but so far, I had never seen a use for the things I do with Dynamo. Which doesn’t mean there aren’t any.
I have this script I created quite some years ago that I so once in a while use. I extract some information from a Revit project. Since the script always seems to work fine I never really bothered reviewing or updating it.
One of the things the script does is that it gets all the linked files and report back the instance and type worksets for that link. I link reviewing that information because often I get a pretty good insight into how much the user knows about Worksets in combination with links and I can often offer solutions for improving performance.
This time the script worked but the data was all in the wrong columns. The script pushes out information to CSV files which I read into power bi to make a pretty dashboard. But because someone decided to use comma’s in the name of the worksets things ended up in the wrong columns…
So I needed to go into the script and fix this by adding a string. Replace node. While looking where to fix this in the script I ran into this part of the script:
Several replace by conditions after each other. That looks now like a lot of unnecessary nodes. It takes the values form the parameter discipline which are integers, these integers I like to replace with the actual name.
If I create a dictionary from the values and the words I want to replace them from, it looks a lot savvier.
The string “other” that gets added is because some views don’t report a value for discipline, other is in my mind a bit neater than nothing.
I often tell people when doing Dynamo training that dynamo is like a toolbox, and you need to learn what the tools do so you can expand your solution solving skills.
In other words, practise what you preach…