Sunday, July 25, 2021

How to Speedup Your Dynamo

    When ever I create a Dynamo graph, what I do at the end is reviewing the graph (or python code) and ask myself whether it is the fastest flow. (Yes, I'm a Korean. Click if you want to learn a Korean word pali-pali)

There would be a lot of situations though, there are some representative ways to speedup Dynamo.

1. Use Numbers rather than Geometries as possible.

figure#1. Geometry.Translate

    Figure#1 is a graph to generate 100,000 points by using Geometry.Translate. And it took 2.55 seconds.

figure#2. Point.ByCoordinates

    Figure#2 is a graph using Pioint.ByCoordinates from generated coordinates directly to get the same list as figure#1. It took 2.02 seconds.

0.5 seconds doesn't look long time, it's literally less than 'just a second'. But if you are dealing with a large graph and it can contain a huge data set, it won't be 'just a second ' difference.

2. Don't make the same data twice or more.

    Sometimes, in a large graph, You can create the same lists or items several times just for the graph to look pretty or make it easy to understand. Remember that all of data will be calculated and saved. The larger data the slower your system.

3.  Use Python.

    One known good reason to use python in Dynamo is to import Revit API, but it is not the only advantage.

    1st. Minimize data sets to save.

    2nd. Make a Dynamo graph smaller.

    3rd. Easy to combine multiple calculations.

    4th. Enable to skip unnecessary calculations.

    and more...


    Below is an example of using python. One simple Python Script replaced multiple nodes. Python made the graph smaller and speedup the flow.

figure#3. Categorizing curves using original nodes

figure#4. Categorizing curves using python

firuge#4-1 Python code for Categorizing curves

    I'm not a programmer but an architect. What I know about Python is just few. But just small knowledge of python should help you a lot.

Enjoy :)

No comments:

Post a Comment