I am querying all loaded families of a specific category (ex. families of pipe fittings) but I cannot do it in FilteredElementCollector of RevitDB API. I am coding in python.
I tried the code below but I got all the families in Revit with different category: FilteredElementCollector(doc).OfClass(Family).WhereElementIsNotElementType().ToElements()
I also tried the code below but got all the family types for a specific category. FilteredElementCollector(doc).OfClass(FamilySymbol).OfCategory(BuiltInCategory.OST_Doors).ToElements()
But when I tried the code below, somehow I get an empty list. FilteredElementCollector(doc).OfClass(Family).OfCategory(BuiltInCategory.OST_Doors).ToElements()
Is there any way to do querying all the loaded families of a specific category using FilteredElementCollector?
Based from the picture you attached, you are querying family types. Is there a way to query the base family? I can query the family of categories now but not of a specific category. I have to add a for loop to query families of a specific category. If possible, I want to use one line only because I am doing 70k pipes and 70k fittings. A lot of for loop may slow my script.
import clr
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
OUT = [f.Family for f in FilteredElementCollector(doc).OfClass(FamilySymbol).OfCategory(BuiltInCategory.OST_Doors).ToElements()]
import clr
import sys
import System
from System.Collections.Generic import List
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
#import transactionManager and DocumentManager (RevitServices is specific to Dynamo)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
filter = System.Predicate[System.Object](lambda x : x.FamilyCategory.Id == ElementId(BuiltInCategory.OST_Doors))
fec = List[DB.Element](FilteredElementCollector(doc).OfClass(Family).ToElements()).FindAll(filter)
OUT = fec
Thank you very much. Your code differs with @c.poupin a little bit but when I convert it to c#, it is exactly the same. I am just doing scriptlets in python and if successful, I implement it in c#. Right now, my job is to optimize code and make the existing scripts and nodes faster and efficient to handle hundreds of thousands of elements in one model.
Again, I cannot thank you enough for the suggestions you have given me.