Is using custom nodes better than separated nodes regarding script health?

I made a quick search about this issue i even asked chatgpt about it but i’m not sure about the answer, and it is important to me because i usually create complicated and long scripts which are used to accomplish complicated tasks, last script was working properly regarding the function, however sometimes it crashes and closes the revit immediately. And that was not a huge project yet, it is a small villa and i only selected 11 faces for the script to work with, i am assuming that these data are not that heavy to crash.
Anyway, its time to look for the script health, usually i don’t prefer to use custom nodes because i use my scripts in several computers in several firms, so i prefer to keep the script totally independent, however the question is, if it is possible to minimize the number of nodes in the script by combining some of them in custom nodes, would that help to make the script smoother and may avoid crashes?

1 Like

Do you have any ability to use Python nodes? Regular Custom nodes are just a collection of regular nodes, so you aren’t really simplifying the functionality, just making the main graph smaller looking. Outside of packing, I’ve found the main reason for custom nodes is easier list lacing and levels, but performance wise python or custom C# would be best.

1 Like

Actually i have no knowledge about python it is a blind area to me however i do use chatgpt to create some scripts with python and keep struggling to have the correct script which works properly, actually 9 out of 10 scripts fails.
Also i use the python scripts in the custom nodes of custom packages with total respect to the copywrite of them, sometimes i just modify them by chatgpt to get a specific task or to give him a guid how to build a correct script basics.

i searched a lot for a python scripts library which have a huge collection of codes useful for dynamo but i never found but those which are in the custom nodes, do you have any recommendations regarding this issue ?

The answer to this is ‘that depends on the context’.

For speed, it helps to evaluate the overall process from a user perspective. All code has to load, and this takes time, but that time can come at different points. As a result you need to account for the intended use as much as you account for the ‘speed on canvas,’ which is an important differentiator.

For graph authors (those who live in Dynamo and author content directly) Python is likely faster than a dyf, but only after the first run. This is because each Python node needs to initialize their own virtual machine which acts as a compiler for the Python environment. You can illustrate this by starting a new graph, launching TuneUp, and placing a custom node on canvas. Note the runtime which is assigned. Then hit the ‘force re-execute’ button in TuneUp and notice the run time; depending on which of the 3 Python engines you’re using you could get various results, but every run after the first will be quicker than the initial run. Bit when considering a consumers perspective (those who open a graph, run it, and close it, or use dynamo player) the speed of the subsequent runs isn’t fully realized as they have to spin up the virtual machine each time the use the graph and so they’re always seeing that slower first run.

For zero touch nodes the speed impact actually happens when you launch Dynamo, as the custom nodes and functions are loaded into memory at that point. Larger library of custom nodes will result in a slower startup time (even if you aren’t using them). But from an authors perspective this is likely moot, as we’re ok with the slower open. From a users perspective this appears when they launch player or open Dynamo, so they’re more likely complaining that Dynamo is slow to start then they are that the graphs take too long to run.

Custom nodes consisting of only out of the box nodes, don’t take as long to load, reduce the memory consumed by each graph as less data is serialized into the node (they only keep the output, not the intermediate steps), and if they are only using the out of the box nodes there isn’t a bigger startup time either. As such they feel as quick to the consumer as they do the author, and are generally a place to be speed wise.

There are a lot more factors than node type to consider though, and the only way to ‘know’ the fastest path for your particular situation is to utilize the right method for the context you’re operating in (ie: primarily authors or consumers; running from player or Dynamo; is dynamo already going to be open or is that included in the execution time; etc.). When in doubt ask, but know that you will have to test things out in your environment to know for sure.

2 Likes

This is actually an exceptionally good rate for chat gpt for AEC code use. Most people I have talked to fail 99/100 times. You have trained your AI quite well. Congrats!

I’d wager that you’ll have better luck learning to write Python and navigate the API yourself than getting an AI to get you the solutions you seek.

3 Likes

A post was split to a new topic: Graph crashes