Tuesday, 14 March 2017

Dynamo scripts portability

It's been my experience that writing scripts that work for different project files can be quite challenging. Writing scripts that work for different offices even more so.

I follow John Pierson on Twitter and recently he was so kind to share a script for renaming rooms. See tweet: John Pierson's tweet

He always makes very good dynamo scripts so I copied his script and had a go at one of my files. Unfortunately it did not work. My file has a couple of additional levels that made it not work and my file had rooms in it that were Not Placed.

To make it work for my file I had to rewrite quite a bit of the script. I had to take out his dictionaries. I didn't get those to work me. That is not criticising John's work. I would merely like to point out that it can be rather tricky to write scripts that work on different project files.   
It's working for this file but there are some file dependencies in it. It's relying on the level names and that is not so good. So let's try and fix that.

it's a bit better.  I should have appended a 0 if the number was smaller than 10 but I didn't bother with that just yet.

In my script I also had to get the level names twice. That feels like I could have done it more efficiently. But it works at this moment.

But what about checking whether no error has slipped in? Maybe the logic is wrong somewhere and you end up renaming rooms a completely different name. It can happen. So I setup this file to export the new and old name to excel. The bottom groups are all for excel.

this is just to create a filename with date for excel and place this file in the same folder as the RVT file. 

I added a Pauze node here just to make sure to capture the changed name. (I am not entirely certain if it's necessary)

Anyways thank you John for the inspiration. Reading other people's script is always a good learning exercise.

Google+ Badge