`Get Item from List` alway grabs last item when picking a list number greater than the list size.

What do you do when you are using Get Item from List and you want it to return empty if Which is greater than the list size, instead of grabbing the last item?

I found a way to do it using Take from List and Block Empty List but it seems a like a strange way to do something that I think should be default.

I feel like a node setup like this should be possible. Am I missing why this works like this?

Why would you not want it as the default behaviour for lists? If there is a reason for it to behave the current way would it be possible to add a “Block when Empty” switch to the Get Item from List node so we could have it work both ways?

1 Like

Don’t know either if there are some reasons for this to be default behavior, but you could also use Get Item Ranges From List, because ignoring out-of-range items is the default behavior for this node.

If you wanna retrieve 1 element only, hack the make range to have the same min & max (see joined comp).
And if you wanna retrieve several elements, use the make ranges nodes normally (see joined comp 1 & 2).

 

Get Range List.vuo (1.59 KB)

Get RangeS List - 1.vuo (1.37 KB)

Get RangeS List - 2.vuo (2.54 KB)

2 Likes

Thanks @Bodysoulspirit! That worked perfectly as a work around!  

1 Like

I think the reason for it duplicating the last item in the list is that it makes it easier to deal with point-lists and transforms for instance. With it “remembering” the last instance for the rest you can quickly make a translate array providing only the transforms and adjust rotation and/or scale in one line instead of making separate lists containing the same value. Definable behaviour on the out-port would probably be nice though.

2 Likes