If with empty list

Hello,

If my string.length = empty i want to replace it with a list of n items “1”
But if it is not empty i want to use the values from string.length.

But if i put the “Empty list” value to the if node i get the “empty list” as a result.

Thanks
Edwin

Try the ScopeIf node instead.

1 Like

With the ScopeIf the program keeps running in a loop

Ugh, yeah, that node sometimes is buggy.
In that case use the workaround I posted here:

Still not working as it should be see the dyn file.

at the bottom the flatten list has 3 items so List.IsEmpty is false but the “answer” is empty list.

If - Empty list.dyn (11.5 KB)

And … you stumbled across another Dynamo bug. :slight_smile:
Don’t use the same variable name in both code blocks.
Try “seq1” and “seq2” instead…

Thank you very much for your replies and time it works just fine.

Edwin

Thank you Erfajo,

But i do not want to replace the “Empty List”, what i want is when there is an “Empty List” (always 1 item) replace it with a list with n items with value 1.

Edwin.

Your list.replace should do the trick too.

1 item empty list comes out a boolmask node if the condition does not excist from there its an empty list.

thnkx

Edwin

I think this is similar to what I tackled last week, I ended up using the “replace by condition node”. Another option for anyone who’s interested:

This shows the result when the list isn’t empty:

This shows the result when the list is empty:

Hope this helps,

TJ

1 Like