Logical Operation

Dear Dynamo Team,
I was planing to prepare script to replace items of list with the new one according to index numbers. Please see photo and script to understand problem. I used List.Replaceitem and etc nodes but did not work when i want to replace item with multiple values. Could you please help me.
Task.dyn (2.0 KB)

The List.ReplaceItemAtIndex node exists…

Dear Paul,
I checked that node also. Unfortunately, could not get result.

How important is the non-chronological order of the list of indices to you?

@ kvusal

I don’t know if you know python and\or want to have it in python, but I made a little script for your problem.

1 Like

Thanks Daniel,
Can you please share script as text file.

That looks like it should work.
Within Dynamo these things are really difficult, it’s like you’d have to create a List.Map except you need to get it working for two different inputs instead of one.

@ kvusal
sure, Here is the text file
kvusal.txt (192 Bytes)

NLDaniel,
Many thanks for your support. The python worked great. However due to some difference at my input (level of input list) it did not worked at my computer. Most probably we need minor change at your script to work. Is it possible you to connect my computer throw team viewer to solve this problem? :frowning:

You can also use List.ReplaceItemAtIndex+ from Clockwork to replace multiple indices in the same list.
image

1 Like


Another python script:

#The inputs to this node will be stored as a list in the IN variables.
inlist = IN[0]

for i,r in zip(IN[1],IN[2]):
	inlist.pop(i)
	inlist.insert(i,r)
#Assign your output to the OUT variable.
OUT = inlist

Made this before realizing NLDaniel had already made one. Here is just a shorter version of NLDaniel’s:

#The inputs to this node will be stored as a list in the IN variables.
inlist = IN[0]

for i,r in zip(IN[1],IN[2]):
	inlist[i] = r
#Assign your output to the OUT variable.
OUT = inlist

If you are having problems with levels, can you show a picture of the actual inputs you are using?

3 Likes