我有两个问题
Urinals.Symbol.FamilyName("Type Comments").AsString() == "Urinal")
:不起作用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
答案 0 :(得分:0)
在调试器中查看它,您将自己看到。
答案 1 :(得分:0)
您的错误是此行:
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
应为:
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
在for
循环中,您调用了Level.Name
,其中Level
实际上是一个级别列表。因此,例外。
注释掉的代码也存在相同问题:
for u in Urinals:
if (Urinals.Symbol.FamilyName("Type Comments").AsString() == "Urinal"):
Urinal_count +=1
替换为:
for u in Urinals:
if (u.Symbol.FamilyName("Type Comments").AsString() == "Urinal"):
Urinal_count +=1