Hi there,
I have a list which is populated by placeholder text and I wish to replace such text by other values later in the script.
I followed this script by @Dimitar_Venkov and I succeed with a single replacement item.
The point is now I have a list of items to replace and I wish to substitute one of them at the time.
I mean: 1st occurrence shall take 1st item on my “replacement list”, 2nd occurrence shall take 2nd item of my “replacement list” and so on.
I post a picture of my graph for better understanding, hoping someone could shed a light.
The code block shown the “static” replacement list which works feeding the same value for all the occurrencies.
On the left, the list.transpose contains the actual values of my “replacement list” I want to replace.
Hi @Kulkul and thanks for your reply.
Your solution is somehow over my head though and I couldn’t modify your code on my own to get what I need.
In my poor understanding I thought I need to loop through my original list to spot each occurrency, get the index and replace it with the value from the other list.
The ValuesList index shall be selected via a variable referring to the count the occurrencies found in the original list and incrementing as the loop gets executed.
Can you give me further support in this?
Thanks again for your time.
My code
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *
# The inputs to this node will be stored as a list in the IN variables.
changeList = IN[0]
origList = IN[1]
# Place your code below this line
outList = origList
changeIndex = 0
for i in outList:
if outList[i][0] == "CodArt":
for subNumber in i:
outList[i][subNumber] = changeList[changeIndex][subNumber]
# outList[i][0] = changeList[changeIndex][0]
# outList[i][1] = changeList[changeIndex][1]
# outList[i][2] = changeList[changeIndex][2]
# outList[i][3] = changeList[changeIndex][3]
changeIndex += 1
# Assign your output to the OUT variable.
#OUT = outList[0][0], changeIndex
#OUT = outList[1][0], changeIndex, changeList[1][0]
OUT = outList
for i in outList: #print(outList[outList.index(i)][0])
if outList[outList.index(i)][0] == “CodArt”:
for subNumber in i:
outList[outList.index(i)][i.index(subNumber)] = changeList[changeIndex][i.index(subNumber)]