Collecting Rooms from Main Model and Primary Design Options

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?

from Autodesk.DesignScript.Geometry import *

# Import Revit Nodes 
import Revit

# Import 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 = []


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":

The Python equivalent of a null is a NoneType object, or simply None. Therefore, your test should look like this:

i.Location is not None

You can also simplify your code using the all() function like this:

if all((
    i.Area != 0, 
    i.Location is not None, 
    len(i.GetBoundarySegments(options)) != 0, 
    i.DesignOption is not None

Thank you. I knew it had to be something simple.

Follow up related question: Within that same if statement, how do check to see if an element is in the primary option?

The DesignOption class has an IsPrimary property, so you can do it like this:

# Assume 'element' is a valid Revit Element
if element.DesignOption.IsPrimary:
    # Do stuff