Code block bug: if true a, else b - returns shortest list

Is this a bug? Returns a list of values equal to the shortest inputlist…



Hi @jnoordzij,

Without lacing option I think it is by default doing shortest. If there is no a or b to compare then it will stop. In your case both image should stop at the shortest list.

First image true - return all a to the extent of available to compare b

Second image false - return all b to the extent of available to compare a

Looks like not a bug. But just can compare available no. of a with no. of b.


Thanks. But that doesn’t make a whole lot of sense to me.
I am expecting the code to do what it looks like: check if ‘Test’ is true or false. If true: return a. If false: return b. It should not do any comparing inside a or b ( at least i.m.o. )
Is there a way to achieve the thing i want (with code block / design script)?

You could do a simple python script like:

test = IN[0]
a = IN[1]
b = IN[2]

if test:
    OUT = a
    OUT = b
1 Like

yes thank you I did that already. Thank god at least Python does what it’s supposed to do :wink:


use a scopedIf node or an if statement inside an imperative block. (if you want to use DS)

1 Like

Thanks @Michael_Kirschner2 . Can you post an example? I’m not good with imperative blocks.

You can also use GetItemAtIndex, and your IF is choosing between indexes.
Something like this:


That’s pretty clever! Thanks

Might work in a single code block too (haven’t tested):
DSCore.List.GetItemAtIndex([trueList, falseList], (test ? 0 : 1));

1 Like