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


default searchFor values is “empty list, null, empty string”

1 Like

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.

Thanks, for your heads up @EzDoesIt
It is my bad that the node didnt work. The way I feeded the input to the node had an error. I have updated the package, so it now takes lists as weel as replacement values.

Home.dyn (3.2 KB)

Whether it helps you am I not sure, I dont understand empty list as holding one item, then it is not a empty list!? but you can search for a given value to replace as well.

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