Hi @Dimitar_Venkov
How abt this sublist, do you have any solution?
Thanks
Design Script in its current form is just not capable of handling these types of list structures. The only option is to know the rank of the input in advance and manually apply replication strategy to match that rank:
If you can’t guarantee the rank of your input, your only other option is to normalize the rank, loosing the original list structure.
1 Like
I tried my hand at using recursive functions in python and got something to work. Let me know if it helps or if there are any problems.
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.
def recOklist(listx,output):
temp = []
for i in listx:
if hasattr(i,"__iter__"):
recOklist(i,temp)
else:
if i == "":
temp.append("Ok")
else:
temp.append(i)
output.append(temp)
outList = []
recOklist(IN[0],outList)
OUT = outList
1 Like
Made another version just to allow more utility with choosing the test and the replace:
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.
def recOklist(listx,output,test,replace):
temp = []
for i in listx:
if hasattr(i,"__iter__"):
recOklist(i,temp,test,replace)
else:
if i == test:
temp.append(replace)
else:
temp.append(i)
output.append(temp)
outList = []
recOklist(IN[0],outList,IN[1],IN[2])
OUT = outList
Only works with single item for inputs 1 and 2, for now at least.
2 Likes
@Dimitar_Venkov @kennyb6
Thanks both, It’s quite much with me, i’m trying to comprehend