Replace_items_bug.gh (8.0 KB)
Hi all!
The trick of using -1 index to “select” the last item of a list… doesn’t work with Replace items component.
Is this a bug?
Am I doing something wrong?
Replace_items_bug.gh (8.0 KB)
Hi all!
The trick of using -1 index to “select” the last item of a list… doesn’t work with Replace items component.
Is this a bug?
Am I doing something wrong?
Use ListLength-1 instead?
Using “-1” index is simple and precise.
Having to pick list length would be using one additional input, which is not convenient.
A single “-1” index with a single item for replacing, works.
It doesn’t with many indexes/items.
Hello ; how this wrong and the other correct? both of them look wrong and i don’t think replace items worked like that, items must replaced with precise indices and length of list to modify >= length of lists of items to replace with, or you have a different point?
Green is correct because the index used are just “1”, so only the second element of the original list is modified.
“CC” is the last of the “I” input, to that’s the one remaining.
Totally expected result, for me.
Red is wrong because the value “2” of the original list, which is the third element (index=2), is replaced! … even when i never used an i=2 index for replacing.
Even worse, original list length was 3, the output have a length of 4 … replacing should not increase or decrease the length of the list it is working on…
Hi Riccardo when you use a list of items with Replace i you must use -2 to replace the last item. This method just works only with this component.
On the other hand, when is a single value this work as expected .
Emm but why?
Wrap must be True
Oh man. I’ve totally overseen that it’s false by default, unlike the others.
Thanks Thomas!
Is there any reason why this doesn’t work for multilpe indexes? My goal is to replace first and last item.
My usual workaround:
Default value of “Replace items” component is “False”. That’s why it is inverted in my example…
wow, I would’t expect that at all thanks for sharing… Possibly a bug?
This is confusing. I found my workaround more bulletproof that this “-2 / -1” thing.