Dear all
I was trying to find all user defined subcategories in a family document and I noticed different behaviour in the .addin when I was running it from an already opened (active) family document in Revit, or when opening the family from the API and then run the doc.EditFamily command
In have attached sample code and a sample family in which you can see the difference
var scats = d.OwnerFamily.FamilyCategory.SubCategories.OfType<Category>().ToList();
var userdefinedsubcats = scats.Where(c => c.Id.IntegerValue > 0).ToList();
Console.WriteLine(userdefinedsubcats.Count);
I think if you add an extra subcategory manually to this family, it will find one user defined subcategory, instead of two, when running it from editfamily and will return two user defined subcategories when running it from an active family