"Replace False" Node

I made a node that replaces falsy elements in a list with something else. Its name is “Replace False”. One would think “Manage.ReplaceNulls” would be similar, but it is not.

An example of use: Getting Width parameters from system Curtain Panels but one is not rectangular, so that parameter is falsy. Not false, per se.

Should it be called “Replace Falsy”?

Usage in a warning using “Dialog” node:

Assuming the ‘falsy’ elements are empty strings, you could also do this…

Is there a way to put a falsy (not an empty string) into a Code Block?

Curious as to what object type the 'falsy’ actually is :slight_smile:
Could you please share a file with an example?

I just published it as Replace Falsy

Its python:

items = IN[0]
rep = IN[1]
elementlist = list()
for item in items:
	if not item:
		item = rep
	elementlist.append(item)
OUT = elementlist

Example is the Width of this System Panel:

One panel has falsy width.rvt
Its Width is neither null nor 0.

What you call a ‘falsy’ is actually an empty string

Below is an example using the file you’ve uploaded above…

1 Like

[quote=“Vikram_Subbaiah, post:8, topic:4394”]
What you call a ‘falsy’ is actually an empty string[/quote]
But the other data types are numbers? Who would guess that getting length parameters would return a string? Or, does “” get turned into a falsy, somehow?

Yes it’s an empty string, that’s how the developers have solved it:
Excerpt from source code of the GetParameterValueByName node:

        if (param == null || !param.HasValue)
            return string.Empty;
1 Like

Just another thing to know. Python ‘not’ works on it, though.