Get_elements_by_categories byType

Hello,

I’m looking for the pyrevit method that give this “old school” result :
DCs = DB.FilteredElementCollector(doc).OfCategory(DB.BuiltInCategory.OST_DuctCurves).WhereElementIsElementType().ToElements()

I know there is this one : DCs = get_family(‘DB.BuiltInCategory.OST_DuctCurves’, doc=doc) but it gives me the Instances and I want the Types.

I already search in this library
https://github.com/pyrevitlabs/pyRevit/blob/master/pyrevitlib/pyrevit/revit/db/query.py
but I couldn’t find the “get_elements_by_categories” with the option “WhereElementIsElementType”.

If someone has an idea how to resolve this.

Kind Regards,
Yoann

Your first FilteredElementCollector should be returning the DuctTypes in the project(?) The old school will work just fine.

You’re probably looking for get_types_by_class.
But you have to give that a class of MEPCurveType as that is what a DuctType returns.
Then you would have to filter DuctType by category from that list as you’ll have more than you want.

I’d stick with your simple OfCategory filter as it is more direct.

1 Like

I understand now I was searching get_types_by_categories but it doesn’t exist. I just try to use the new pyrevit functions but it will works with the other code.
Thank you for you answer.

If this is something you think will be useful to others, feel free to add a function to the query module and make a PR