Description
Dynamo handles lacing on it’s own(provided that the python script is within a custom node), however sometimes you may have to handle multi-dimensional arrays by your self.
The solution is simple, you use recursivity. Basically you iterate through each element in the list and if the item is a list, then apply the iterate function to that item, if not then apply the custom function:
Solution
import re ### isIterable function determines if the object is an array or not def isIterable(unit): t1 = t2 = False; if(isinstance(unit, (tuple, set, list, dict))): t1 = True; if(hasattr(unit, "__iter__")): iterstr = str(unit.__iter__()); if(re.search("System.Array", iterstr)): t2 = True; return (t1 or t2); ### iterating over the list (if it's a list) or apply function def iterateAndDo(elements, myFunction): if(isIterable(elements)): returnList = []; for element in elements: returnList.append(iterateAndDo(element, myFunction)); return returnList; else: return myFunction(elements); ### our custom function def Log(input): #do something here return; OUT = iterateAndDo(IN[0], Log)