# Python logic to enumerate identical wattage values per circuit

I need to work through all the circuits on all the panels in a project and then group together numbers of fixtures with the same wattage value on each individual circuit. So if I had a Panel DBP-001, and on circuit R1 I had 4 sockets, 2 that have a wattage of 100W each and 2 that have a wattage of 200W, my output would have to be, (DBP-001, R1, 2 x 100W and 2 x 200W)

I have managed to combine wattage values by count using Dynamo, but I’m pretty certain that there must be a simpler way to use python to loop through fixtures per circuit per panel and enumerate the wattages?

Hello.
Can you attach a small sample Revit file with some circuits/panels and the Dynamo graph? It is a lot easier to test things out if we don’t have to recreate the data.

Can’t test it because I don’t have your data yet but this function worked for me:

``````def enumStrings (stringList):
strDict = {}
for s in stringList:
if s not in strDict:
strDict[s] = 1
else:
strDict[s] += 1
amounts = ["{} x {}W".format(c,v) for v,c in strDict.items()]
if len(amounts) == 1:
return amounts[0]
elif len(amounts) == 2:
return " and ".join(amounts)
else:
return ", ".join(amounts[0:-1]) + ", and " + amounts[-1]

OUT = [enumStrings(x) for x in IN[0]]
``````

3 Likes

Morning.

Thanks for the reply. I appreciate any guidance you may be able to give.

Attached is a small example file (Revit 2019) and a Dynamo graph (Ver 2.0.2) collecting the relevant information into a python script (which part
I have not yet developed.)

What I am working towards is reading all the panels in the project, and collecting the individual circuits on each panel (as obviously there will
be identical named circuits on multiple panels). Once identified, then I need to collect the wattage values on each circuit and group them together by similar values.

Then end result should look something like (when viewed in excel)

Many thanks.

Reinardt Bronkhorst