Hi everyone,
I’m trying to use a filtered element collector to get all the rooms in the project, without the secondary design options. I want just Main model and primary design option rooms. I’ve made use of the PrimaryDesignOptionMemberFilter which only grabs the rooms in the primary options. Now I just need the main model rooms, and I’m trying to use an if statement to check if the i.designoption equals null, but it’s not working. Anyone have ideas or an easier way?
clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import Revit Nodes
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
# Import DocumentManager and TransactionManager
clr.AddReference ("RevitServices")
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
filter = PrimaryDesignOptionMemberFilter()
coll1 = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).ToElements()
coll2 = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).WherePasses(filter).ToElements()
#coll3 = coll1.UnionWith(coll2)
roomname = []
roomlevel = []
roomnum = []
area = []
department = []
TransactionManager.Instance.EnsureInTransaction(doc)
for i in coll1:
options = SpatialElementBoundaryOptions()
if i.Area != 0.00 and i.Location != "null" and len(i.GetBoundarySegments(options)) != 0 and i.DesignOption == "null":
roomname.append(i.LookupParameter("Name").AsString())
department.append(i.LookupParameter("Department").AsString())
area.append(i.LookupParameter("Area").AsValueString())
roomlevel.append(i.LookupParameter("Level").AsValueString())