The objective is to obtain the indices of a list with depth 4, (List of Elements by category with List of Parameters with Sublist Values) vs List of Elements of category with List of Elements) .
The detail is that the mapping is done by brute force and I cannot unstructured the list to reduce the complexity, so although some elements are not contained within the list of the parameters I have to pass it to avoid a value placement error.
The clearest example would be seen here, I have to pass the empty lists of elements within the comments list, and then continue through list two that if it has elements.
# The inputs to this node will be stored as a list in the IN variables.
IndexVals = IN[0]
TLFParN = IN[1]
ListVal = []
# Place your code below this line
for LSval in TLFParN:
templist = []
for LVal,indices in zip(LSval,IndexVals):
tempsublist = []
try:
for i in indices:
value = LSval[i]
tempsublist.append(value)
templist.append(tempsublist)
ListVal.append(templist)
# Assign your output to the OUT variable.
OUT = ListVal
It is a spreadsheet with different sheets of schedules. Those schedules have quantities from link models for that, Now I try to find the elements in the current model ( The result is the index), and then I want to access the value on the excel to set in the model; that’s why I have this deepness in the lists.
I read your case, but I cannot figure out what you are trying to do here. I have checked your example file and this too doesn’t make it clear. What are you trying to do with these 2 array’s in the example file?
you first list is a list containing “List of Elements by category with List of Parameters”?
your second list contains what, Indices of some sort?
Could you some how show what the end result should be or explain it a bit more?
# 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.
IndexVals = IN[0]
TLFParN = IN[1]
# Place your code below this line
ListVal = []
for LSval in TLFParN:
templist = []
for Lval, indexes in zip(LSval,IndexVals):
if indexes == []:
Lval = []
else:
for i in indexes:
Lval[i] = i
templist.append(Lval)
ListVal.append(templist)
# Assign your output to the OUT variable.
OUT = ListVal
Thank you very much but It give more outputs that suppose to deliver.
Carlos from BIM Central Mexico resolved this problem with this 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.
IndexVals = IN[0]
TLFParN = IN[1]
# Place your code below this line
ListVal = []
def findMySet(lsSet, indexVals):
lsData = []
m= 0
for IsIndexes in indexVals:
data = []
if len(IsIndexes) > 0:
for indx in IsIndexes:
if len(lsSet[m]) >= indx:
val = lsSet[m][indx]
data.Add(val)
m += 1
lsData.Add(data)
return lsData
for lsSet in TLFParN:
resVal = findMySet(lsSet,IndexVals)
ListVal.Add(resVal)
# Assign your output
OUT = ListVal
# The inputs to this node will be stored as a list in the IN variables.
IndexList = IN[0]
ValueList = IN[1]
# Place your code below this line.
OutValues = [[[] if index == [] else [valList[i][item] for item in index] for i, index in enumerate(IndexList)] for valList in ValueList]
# Assign your output to the OUT variable.
OUT = OutValues