Convert true to number value


I want to the value that list number is larger than a+b
but when I using the ‘>=’, it is only return ‘true/false’.
I want to extract number value which is larger than a+b
how can I do…?

Hi @hojukys and welcome, use the node List.FilterByBoolMask

4 Likes

Hi there, and welcome!

Here’s a visual representation of what @Elie.Trad means.

2 Likes

As mentioned before, the ‘node’ based way to do this would be to leverage the List.FilterByBoolMask node.

Alternatively you could use a line of DesignScript in a code block for the whole thing. Something along the lines of this:
DSCore.List.Clean(numberList>a+b ? numberList : null) , false);

Breaking down the statement above, we all the DSCore library, get the List module, and call for the Clean function. Then we use an if statement in the format test ? ValueIfTrue : ValueIfFalse where the test is checking the values in the number list agains the sum of a and b, and the true value is the number from the list, and the false value is a null. By using the false override on the List.Clean function the nulls at stripped out of the list.

3 Likes

thank you!!!

hello, writing DSCore is not mandatory?
but you write like that (you show pedagogy)
to retain Library.Module.Function()
that’s it ?

thank you
Cordially
christian.stan

OUT = []

for i in IN[0]:
	if i >= IN[1]:
		OUT.append(0)
	else:
		OUT.append(1)

Hi,

or via python

KR

Andreas

1 Like

In this case I call out the DSCore because the List namespace has a few common collisions with other widely distributed packages. By directly referencing the library we keep error messages from popping up or causing the code to fail for some users. :slight_smile:

1 Like