Therefore, you have to use some other method to check the category of a family. On some family instances, you can use FamilyCategory instead of Category, like you are doing in your working code ...