0

I have two issues

  1. level list does not contain name or other parameter why this error is comming to every element I am collecting enter image description here
  2. Urinals.Symbol.FamilyName("Type Comments").AsString() == "Urinal"): is not working
from pyrevit.output import charts
from pyrevit import script
from pyrevit import revit, DB
from Autodesk.Revit.DB import FilteredElementCollector, BuiltInCategory
__context__ = 'zerodoc'

from System.Collections.Generic import List
doc = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument

from rpw import db, ui, doc
from pyrevit.framework import List
from pyrevit import revit, DB
room_filter = "WORK"


import rpw
from rpw import doc, uidoc, DB

# GET ALL ROOMS IN MODEL
rooms = DB.FilteredElementCollector(doc).OfCategory(DB.BuiltInCategory.OST_Rooms)
Urinals = DB.FilteredElementCollector(doc).OfCategory(DB.BuiltInCategory.OST_PlumbingFixtures).WhereElementIsNotElementType().ToElements()
ub_count = 0
MRest_rooms = []
WRest_rooms = []
ADARest_rooms = []
Urinal_count = 0

#for u in Urinals:
#   if (Urinals.Symbol.FamilyName("Type Comments").AsString() == "Urinal"):
#    Urinal_count +=1
for r in rooms:
    if (r.Level.Name != 'CONTAINER LEVEL') and (r.LookupParameter("Name").AsString() == "M RESTROOM"):
        MRest_rooms.append(r)
    if (r.Level.Name != 'CONTAINER LEVEL') and (r.LookupParameter("Name").AsString() == "W RESTROOM"):
        WRest_rooms.append(r)

print "Number of Male Rest Room =",len(MRest_rooms)
print "Number of Female Rest Room =", len(WRest_rooms)

Level = DB.FilteredElementCollector(doc).OfCategory(DB.BuiltInCategory.OST_Levels).WhereElementIsNotElementType().ToElements()
print "Number of Level =",len(Level)
for i in Level:
 a = Level.Name
 print a
barbsan
  • 3,418
  • 11
  • 21
  • 28

2 Answers2

0

Look at it in the debugger and you will see for yourself.

Jeremy Tammik
  • 7,333
  • 2
  • 12
  • 17
0

Your error is this line:

Level = DB.FilteredElementCollector(doc).OfCategory(DB.BuiltInCategory.OST_Levels).WhereElementIsNotElementType().ToElements()
print "Number of Level =",len(Level)
for i in Level:
 a = Level.Name
 print a

It should be:

Level = DB.FilteredElementCollector(doc).OfCategory(DB.BuiltInCategory.OST_Levels).WhereElementIsNotElementType().ToElements()
print "Number of Level =",len(Level)
for i in Level:
 a = i.Name
 print a

Inside of the for loop you called Level.Name where Level is actually a list of levels. Hence the exception.

Same issue with the commented out code:

for u in Urinals:
   if (Urinals.Symbol.FamilyName("Type Comments").AsString() == "Urinal"):
    Urinal_count +=1

Replace with:

for u in Urinals:
   if (u.Symbol.FamilyName("Type Comments").AsString() == "Urinal"):
    Urinal_count +=1
konrad
  • 3,544
  • 4
  • 36
  • 75