Error Trapping an Empty List

Hi There,

I have a need to error trap a null set.

I am reading in spreadsheet data that describes the points and profiles for a 3D sweep. There are 2 types of profile that can be used in the sweep. (a circle, and a flat or filleted rectangle) The incoming list can have a mix of designated type or only use one type of profile depending on individual circumstance. Therefore, I choose a Boolean mask to expose the round and flat types.

The problem comes in when one or the other profile type is exclusively chosen for a given design. The boolean mask then returns a “full” list for one type and a empty list for another type. I would like to capture the errors prior to passing on to a node failure. I’m not too sure the node failure is actually a “bad” thing as it’s a failure and no geometry is created. 8^) However, I don’t think it’s a good practice.

please see the node map below and I have added a closer look at the nodes that perform this task. Thanks in advance.

Larry H.closeupTrap Null

There’s really not much you can do about it to be honest. Like you said, it’s not hurting anything, and you can’t keep a portion of a graph from running so your best bet is to just leave it as is or do it in Python.

You can always add an output somewhere that explains what is going on if you’re worried about misinterpreting warnings as an error. (Ex: “4 sweeps and 0 circles created.”)

you can keep a portion of the graph from running using a scope if node - it has different rules than the if node though - keep the two branches completely separate.

I don’t think I understand how that would work… You could use ScopeIf to manage the final output but how would you keep part of a graph from running using ScopeIf? It would still have to be evaluated somewhere wouldn’t it?

scope if passes code around, not data, only one of the two input branches is executed, this is why you can use this node to accomplish recursion which is not infinite.

1 Like

So that’s the difference. That makes a lot of sense. Thanks for explaining that.

many thanks for the responses! This may be a really dumb question, but it is perplexing me. How do I test for null? Everything I seem to try makes Dynamo ill. I get how a language that thrives on arrays would throw up when is reads a null set, but I’m not sure how to feed the “test” statement in the Scopedif and the if statement without just plain feeding it null. If there are any examples that can be shared I’d appreciate it.

I think the Object.IsNull node is what you are looking for :slight_smile:

If there are null values, then remove them…or replace them with dummy values if you need the index order.

Thanks Amy… That’s a good start. While I believe that I’m testing for null. The Boolean Mask returns an “empty list” result. I am assuming that this is null, but not sure. However, it’s well worth trying!

I do cleanse the original lists of their many many nulls with success. The issue is that I generate a null “Empty Set” during a Boolean mask operation. This is to be anticipated as some of the data will only have one type of profile type. Other data will have a mixture of profile types so I need to anticipate the error and trap it.

Unfortunately, an “Empty List” is not == to null. IsNull does not return a Boolean true or false just “Empty List”. Bummer it was a ray of hope…:disappointed_relieved:

Name updated to Error Trapping an Empty List… Apologies for not being more precise.

I have made some graphs for verifying student assignments. If I need a data input and I have no idea what kind of data the graph will meet when checking example 2500 files. Then I replace with a dummy value I later can remove because its result is so far from what the assignment would end up with under normal conditions.

This is a much easier way than try to code all the exceptions the graph will meet when you literally don’t have any idea of how an assignment might be tried to solve. Something that gives me a null value/empty list in those cases is been replaced so the graph doesn’t break, I keep track on the indexes, and the result is later being withdrawn from the final result.

It is better to use some more computer time than my time :wink:

Ah then the List.IsEmpty node - this will give you a boolean value for whether or not you have an Empty List which you can use to filter them from your list

Huh… My bad I thought that node created an empty list. I may have been looking at the incorrect node. this is the node I’m talking about! You’re referring to List.Empty (very close names lol)

Got it! Returns a true. Not sure of what to do with the “true” output of an If statement. I’d like it to feed it to the bit basket, but that’s the next problem. I now need to make sure I untangle any interaction between the profile options and move forward. Code on friends! Code on!:call_me_hand:

Hi Mike and all.

Like all good :sunglasses: development projects… There have been requirement changes that have forced a rewrite of the duct canvas I’ve been working on. However, I have returned to the point where I do need to conditionally branch based on the duct profile geometry I described above. re:(Rectangular, or Round geometry) I do believe that Scopeif is the right decision because I need to either create one type of profile or another based on the csv file that I now am reading.

Admitting to complete nob-dom, I need some assistance here.

Can anyone share an example of Scopeif moving down one path or another? I have tried Boolean Mask, but because my work examples only contain one duct type or another I land up with an empty set on the “out” branch of the Mask. (error trapping an empty list…) I am even more of a novice at Python, but am willing to modify a code block given some guidance.



I’m not married to the branch location, but it seemed logical and I do want to keep this geometry generation separate.

Finally, the DanEDU package makes quick work of irritating nulls in my lists. GREAT JOB!

Larry H