Creating a robust preprocessing module with conditional statements

Posted below is a pre-processing module I’m making to then feed into a whole bunch of sheet creation logic, the end result of which is intended to be deployed to the Dynamo Player for the project. The problem I’m having is that sheets keep generating even if the logic of the module fails correctly. This creates many erroneous useless sheets in REVIT.

The module doesn’t need to strictly return text errors but it is helpful for teammates. What I really don’t want the module to do is execute and create a whole bunch of erroneous sheets. I keep reorganizing and reorganizing the nodes but am not getting the results I want. I’d prefer it to just fully stop when it fails and return the error but perhaps I’m asking too much (still love Dynamo tho). Can anyone offer any ideas about how they would approach this? I’m on REVIT 2017.2 and Dynamo 1.3.2.

We’d need to see where the sheets are created, and all the logic leading up to it in order to know what the issue is here. Note that you’re passing several values along to points further up the graph without generating the logic, so my guess is one of those is something other than ‘null’. Case in point - passing room names from the Lunchbox Room Element Collector. Or passing the index of the matching string instead of the results of the last if node.

Hmmm… Well thanks for the feedback. Maybe I’ll keep rewriting my code so that everything goes through the pre-processing module and that the if statement failure returns “null”. I don’t mind posting the full workspace here but it’s getting quite large and I wanted to be considerate of everyone’s time since it can take awhile to analyze large projects like this. I will try to post the updated code here in a bit.

1 Like

I would recommend creating your own, simple python script for conditional statements. I’ve had a lot of trouble trying to handle different lengths of lists or running different functions based on the condition.

if IN[0]:
    OUT = IN[1]
else:
	OUT = IN[2]

I ended up modifying the preprocessing logic above so it returned a Boolean as well and then added the Tool.RunMe node to the various sheet creation nodes (that are customized for each page). Seems to be working and it gives more future control over what sheets get created. Dynamo in production is great!

1 Like