I have a list with element IDs of which some are duplicates. The IDs refer to walls and their surface areas, and if I have duplicates in the list, it means that one wall surface area is split up into 2, thus the individual values are incorrect because they need to be added together again.
So now I was thinking about filtering the duplicates in the ID list and turn that into a command to add up the 2 values in the referenced list of surface areas to get the actual complete wall surface area again. Preferably with Python.
thanks for both answers, I tried the solutions and came across a problem:
1 List.GroupByKeyOnly
It works only when the list is flattened. But when flattened I loose the connection of the walls to the room, since one wall interacts with several rooms I am having a hard time reassigning the surface areas to the rooms.
2 Python Script
When running the script I get a warning:
Warning: IronPythonEvaluator.EvaluateIronPythonScript failed Traceback (most recent call last): File “< string >”, line 18, in < module > IndexError: index out of range: 2
Also Dynamo within Revit has an issue using “areas” as a variable name in the codeblock because it’s a class name. Does it hurt when I change the name to something like “outareas” just in the codeblock node?
.
Do you know how to work that out?
Again, thank you for the help!
Try this one. Basically, we create a new hash table with keys is each element in list1 and the value is each element in list2 accordingly. Then we run a loop, if it find the duplicated keys, then add up the value.