Wrapping custom subcategory from another family document fails

Hi,

I’m trying to grab a list of subcategories from another family document, but it’s failing to wrap the custom subcategories for some reason. Does anyone know why, or what other method I should use perhaps?

It works for custom subcategories in the same document (as evidenced by the clockwork node Category.Subcategories), and it works for built-in subcategories in another family document, but not for custom ones.

Here’s my basic setup:

My python node basically works the same as part of the Genius Loci node Family Get SubCategory dealing with family documents, but without the exception handling.

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

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

famDocs = UnwrapElement(IN[0]) if isinstance(IN[0],list) else [UnwrapElement(IN[0])]
outlist = []

for famDoc in famDocs:
	if isinstance(famDoc,Document):
		subcats = famDoc.OwnerFamily.FamilyCategory.SubCategories
		subcatselems = [Revit.Elements.Category.ById(subcat.Id.IntegerValue) for subcat in subcats]
		outlist.append(subcatselems)
	else: pass

OUT = outlist

If I don’t try to Revit.Elements.Category.ById the subcategories and just output them unwrapped, it works fine, but that’s not very useful within dynamo.

You can’t wrap the categories like other elements (with ToDSType()) so the workaround is to use the Revit.Elements.Category.ById where the Id must exist in the current document.

I will remove the unnecessary family document input in the next update of the package.

So you’re not aware of any way to wrap the categories in another document?

Because currently it does work for built-in subcategories, but not custom ones. I even tried loading the family in the document, since I thought maybe if the family’s subcategory appears in the document I am accessing it from, then I will be able to wrap it, but no I couldn’t.