Get all subcategories in a specific family from the project file

Is there a way to get all the subcategories of a specific family from the project file? I used this code, inputing the category of the family and the family document of that specific family, but it returns all the subcategories of that category in the project and I want just the subcategories that are present in that specific family (so all the subcategories “coming” from that family)

import clr

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager


cat = UnwrapElement(IN[0])
fam_doc = UnwrapElement(IN[1])
subcat = cat.SubCategories

OUT = [Revit.Elements.Category.ById(x.Id.IntegerValue) for x in cat.SubCategories]

Do you want something like this?:

not really, I need to get the subcategories of a FamilyDocument (the family file) of a specific family in a file, but with a dynamo script that runs in the project file

Hi
@CarlosCMB

you can use “BriMohareb_2023” to get geometry (line) in family by subcategory

image

1 Like

Hi how about something ?

3 Likes

Exactly what I needed, thanks!

2 Likes