What should I do when a node will sometimes get an empty list?

I have a portion of a graph dedicated for adding family parameters to the current family from an excel document. The graph also adds shared parameters and sets values and formulas.

Sometimes I have a family type that does not include any family parameters from the excel. This means the section of graph will produce warnings since it is receiving an empty list. This doesn’t do anything negative but I want to avoid having warning show up in the dynamo player for end users. Any ways to get around these warnings or stop this section of code from running.

Hi @crapai

There are several ways to do this.

First, Filter out empty lists or null values before executing code

Second, if the first is not possible. Use functions and the Function.Apply node to execute code. this gives the same result but without any warning. But this can be quite complicated for large script, so in that case I would suggest step 1.

I you have any more questions, please attach pictures of your script situation so we can help you more clearly

3 Likes

Third option:

Wrap the entirety of the graph (less the inputs) inside a custom DYF node, and deploy that as a package as you deploy your graph.

Warnings inside the node are suppressed for the most part (see “empty list” results in an output but no warning produced by custom nodes which are internally failing to work in as a result of a dynamo change between versions as an example). This will have an added benefit as changes between Revit versions can be deployed at the package level remaining mostly unseen and unedited, while users point at the same .dyn (which now contains one or two nodes in total).

1 Like

I’ve gone with the function apply route.
I have a “list.count” to see if the list is empty and then using a “if” node to replace the empty list with a fake one. After that I use another “if” node to send the actual function or a dumby that will not make a warning with the fake list. It works when there is not a list but now my “FamilyDocument.AddParameter” is resulting in null when I tried added a family parameter.

Found out my null was user error. Forget to fill in the parameter type in the spread sheet.