Dynamo: Avoid too much wires

After a while your Dynamo script can look like a spaghetti: wires everywhere. Although scripts are usually easy to interpret, too much wires can make it difficult.

To avoid this, you can use a simple technique: functions in code blocks.
This technique can be used if you use the same static values multiple times.

I will explain this with a simple example but of course this technique is more meant for complex scripts.

In this example I’m getting the values of 2 Revit parameters “Comments” and “Mark” and then I’m writing these values in the “Comments” and “Mark” parameters of other objects. This means that I have 2 wires.

Spagetthi_Start

Not too bad for this simple script but imagine a complex script, where you use these parameter names all over the place. You will get wires everywhere…

A nice trick is to define these parameters names in a design script function (=create a function in a code block).

Spagetthi_Function

Then, if you need in this case these parameter names somewhere else in your script you can just call the function in a “standalone” code block, without you need to wire it.

Spagetthi_End.PNG

And of course, if you want to modify the parameter names: just do it once in the function definition.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s