Logical Operation


#1

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)


#2

The List.ReplaceItemAtIndex node exists…


#3

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


#4

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


#5

@ 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.


#6

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


#7

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.


#8

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


#9

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:


#10

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


#11


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?