from collections import defaultdict
all_phases = FilteredElementCollector(doc).OfClass(Phase).ToElements()
last_phase = list(all_phases)[-1]
all_furniture = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Furniture).WhereElementIsNotElementType().ToElements()
dict_furniture = defaultdict(int)
for furn in all_furniture:
try:
room = furn.Room[last_phase]
dict_furniture[room.Id] += 1
except:
print('Furniture [{}] Has No Room in Phase : {}'.format(furn.Id, last_phase.Name))
for room_id, count in dict_furniture.items():
room = doc.GetElement(room_id)
if room: print(room.Name, count)
else: print("No Room: {}".format(count))