Not able to activate family symbol

Hi all,

I am trying to collect all generic families in a project and tyring to activate a family with name “Room”.But I am getting an error which says

Here is the code I have used.Can anyone help me to resolve the issue.Code is working when I Place the aforesaid family in the model.I think filtered element collector is collecting the generic family only when it is placed in the model.

public void ActiavteFamilySymbol()
Document doc = this.Document;
IList Generic_Famlies = new List();
FamilySymbol RoomTag_Family = null;

        //Collecgting Generic  Families
        Generic_Famlies = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_GenericModel).WhereElementIsNotElementType().ToElements();
        foreach( var fam in Generic_Famlies)
            if (fam.Name.Contains("Room"))
                var RoomTag_Family_Temp = doc.GetElement(fam.GetTypeId());
                RoomTag_Family = RoomTag_Family_Temp as FamilySymbol;
        TaskDialog.Show("aCTIVE STATUS",RoomTag_Family.IsActive.ToString());
        using (Transaction AF = new Transaction(doc))
            if (!RoomTag_Family.IsActive)

Your filter is backwards. The ActivateFamilySymbol() method obviously takes a FamilyType but your filter is specifically for elements WhereElementIsNotElementType, which is only going to return FamilyInstances. There are no instances of the type you’re looking for or the family would have already been active.

1 Like

Thanks.Collected types instead of instances and it worked.