I have an issue with the ReplaceByCondition node.
I have a nested list of elements (lines in my case) and I have to replace 2 specific elements on level @1 in a specific position. I can get the specific position because the 2 elements to be replaced are unique, so ReplaceByCondition seemed an obvious solution.
But, here’s the problem:
The elements to be substituted are 2 lines. The element to replace them are two lists.
As you see from the image, the node is taking just the first element of the list.
Any idea on how to make it work?
I could also have used ReplaceItemAtIndex, but I would have to input to the node a specific index of the nested list, something like , and this doesn’t work either…
Hi @rubenbosetti - I can’t see what you are feeding into your Condition here, but you could try something as follows?
The condition is a predicate, which is a fancy term for a function. In this case you are expected to pass that function, which means Dynamo will fill in a few blanks.
Thank you very much solamur!
That’s what I was doing, but I have no issue with this, that was working perfectly.
The problem comes out when i try to replace an item with a list. Check this, I reproduced your script with the variant that gives me problems…
The item “Line 3” should be replaced with a sublist with two elements. Instead the node is splitting [“Hello”,“World”] into the constituent elements and placing them separately into two different positions.
Another way to do it could be this: (on the right side of the image)
But I don’t know how I can use design script sintax for putting a specific index of sublists in input…
I’ve half-solved this using design script. It was more simple than expected (top right of the image):
Although it won’t be simple to do this if you have multiple indexes to replace…
Ah yes, for multiple elements please do use @Bjorn_Keulemans1’s solution
The ReplaceByCondition node is coded as a singleton and won’t allow you to use List@Level or Lacing that would allow for your desired solution.