Controlling Flow to Prevent Errors

I need to find a way to control flow, and the existing If & ScopeIf options don’t appear to be the solution.

I have a graph that analyses and populates data for Spaces, Areas and other elements simultaneously. Currently when that graph is run, errors will be thrown if there are no spaces, or if there are no Areas in the project.

On controlled tests I have found that using If or ScopeIf will still throw the errors, which is exactly what I need to avoid.

I can think of the following possible options:

  1. An option to control the route OUT of a node instead of the opposite used by the If method
  2. An option to split the graphs up, using a parent graph that only executes a child graph if a boolean is true

If not with standard nodes, could either of the above be possible via Python? I suspect option 1 would be, though I have 30+ nodes after the point where the first error is thrown that I’d then have to write in Python.

I understand some errors may be harmless, but given that we’ll be using Dynamo Player to run these scripts it won’t be possible to tell if it’s a harmless error or another that’s causing the issue without opening up the full graph.

Any and all advice would be much appreciated, thanks!

If your goal is 0 errors then you’ll probably be best off using Python for safer control flow (try/except or if/elif statements).

If you can accept ‘script ran with warnings’ then you can use ‘isnull’ or check if an input contains nulls and then feed that to an If node to send through a safer data object (e.g. Empty list). Usually this will mean any modification/creation nodes will do nothing and usually would pass an empty list forward.

Should you know Python/API, my recommendation is going to be that. At some point I also recommend pyrevit as it offers the unique ability to cancel a script partway (and you can do this inside logic pathways using if/try statements - very powerful).

Generally I’m finding it easier to manage as well as it works across all Revit builds as one, whereas Dynamo does not work cross version as well (Ironpython deprecation in 23, nodes not present or graphs not portable between major builds). But that’s a rant for another time, in another topic…

3 Likes