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.
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).
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.
And of course, if you want to modify the parameter names: just do it once in the function definition.