I’m having some trouble using the List.ReplaceItemAtIndex, where aparently the issue is with using two indexes to replace with.
In the example, I need to replace at index 2, value a, and at index 3, value b, but it’s behaving very weird, adding both values in duplicated lists… such as below:
listReplace.dyn (4.0 KB)
I’ve tried the solution here: http://dynamobim.org/forums/topic/replace-items-in-sublist/ … did not work.
Thanks for the effort guys!
At link you’ve referred to only one item is replaced per list/sub list in any workflow that involves the List.ReplaceItemAtIndex node
You’ll need an Imperative code block to replace more than one index.
Hi Vikram, thank you for you repply. Can you please clarify what do you mean by that?
For example, If you want to replace items at indices 1 and 2 you will need to do something like this
I see, but that doesn’t allows exceptions does it? If I build a workflow with two List.ReplaceItemAtIndex, it means that I’ll only be allowed to have two indexes to be changed, but in some cases I may have one, or four, etc…
Any ideas to handle that?
So, I found a work-around for the exception situation:
Doesn’t involves the List.ReplaceItemAtIndex and I think it looks neat.
It’d be nice if anyone has suggestions for alternatives.
I’ve just tried to explain the limitation. (You won’t be able to replace multiple indices in a list simultaneously)
You’ll have to come up with a definition that uses List.ReplaceItemAtIndex sequentially, such that it replaces one index of list, then another index of the resulting list and so on (any number of times)
I think this node from the clockwork package does exactly what you want
Does anyone have a design script equivalent for the clockwork package version? It would be helpful for use in Dynamo Studio applications.
I tried to arrange the list order after the replacement by using a new list as the basis for the ranking.
@Cody_Winchester could you start a new topic?
@salvatoredragotta , Why? I’m dovetailing into this exact topic.