my use case:
a) 1 room including 5 walls (W1…W5) each wall has an area and an allocation value.
b) 2 lists: List1: impact value (CO2eq/m2) list for external walls (n=50), List2 impact value (CO2eq/m2) for internal walls (n=50).
My goal is to ask: When Wall has Allocation value 1 then WallArea * all values from List1, else WallArea * all values from List2.
The output should be:
For every wall a list out of 50 impact values, representing the total impact value for the entire wall.
Actually, it is a simple for loop, but I face problems with List IN[2] and [3] somehow IronPython doesn’t like these lists.
The most warning I get is:
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 34, in
TypeError: object cannot be interpreted as an index
Whereas I believe the index is correctly written.
I tried to unwrap the elements, for IN[0] and IN[1] its fine, but he cant unwrap [2] and [3].
Unwrap works recursively and returns Revit elements unwrapped in the same list structure as the original input. You therefore don’t need your own function/nor iterate your inputs to unwrap each item. If you attempt to unwrap elements which cant be unwrapped (i.e. anything which isn’t a Revit Element), then the function returns your input unmodified.
Line 34 looks fine - maybe try discarding your def and calling UnwrapElement() directly on your inputs and see if that gets you any further.
File “”, line 42, in
TypeError: object cannot be interpreted as an index
same error as before.
BTW, i have tried the script with two simple lists as IN2 and IN3, there the script runs perfectly fine.
I really think there might be some problem in the creation of list 2 and 3.
Might there be anything to think of when using excel list, modified in dynamo python and using it again in another python?
There are a few things to check; are all your inputs lists? The exception is pretty clear so have you investigated the line where the exception occurs? Without seeing your code, my guess is you are either indexing an object which isn’t a list, or indexing a list but not passing an integer into the indexer. As you cant debug in the Python text editor, you could comment out all other lines, create a temp list, and append the items you are iterating then output them as this may help you to isolate the problem.
Ensure the data structure of you GetItemAtIndex nodes (looks like you’ve renamed them so I’m deducing this from the input ports), matches the data structure of your ‘simple lists’ and see if that solves things. Also check that the Excel data is always output as a 2D list and not a 1D list or singleton if say, only 1 row or 1 cell of data is imported. If it doesn’t then there’s your problem; inconsistent data structure.
I believe so too. I will keep you posted if i figure it out. need to think over it how to restructure my lists.
anyways, thank you very much for you input and feedback.
still stuck, have tried to modify my list inputs without any success, in case someone had a similar problem, please be my guest. I just can´t figure whats wrong with the data structure.
in the python I am actually combining values from the geometry of walls, and from an excel sheet.
but yes you are right, you don´t need to create walls…just use simple list inputs. fine as well.