If I know the family/type name that I want to use, I use these methods to get a loaded family symbol. I'm assuming that you're using a Generic Annotation - you should change the category to whatever is appropriate in your situation. You could also remove the "OfCategory(cat)" filter from the getFamilySymbols method if you're not sure what category of annotation it is.
Code:
FamilySymbol symbol = Families.getFamilySymbol(doc, BuiltInCategory.OST_GenericAnnotation, "Family Name", "Type Name");
AnnotationSymbolType symType = symbol as AnnotationSymbolType;
AnnotationSymbol sym = createDoc.NewAnnotationSymbol(point, symType, doc.ActiveView);
The helper methods are below:
Code:
public static class Families
{
public static Dictionary<string,List<FamilySymbol>> getFamilySymbols(Document doc, BuiltInCategory cat)
{
Dictionary<string, List<FamilySymbol>> symbols = new FilteredElementCollector(doc)
.OfClass(typeof(FamilySymbol))
.OfCategory(cat)
.Cast<FamilySymbol>()
.GroupBy(f => f.Family.Name)
.ToDictionary(f => f.Key, f => f.ToList());
return symbols;
}
public static FamilySymbol getFamilySymbol(Document doc, BuiltInCategory cat, string familyName, string symbolName)
{
Dictionary<string, List<FamilySymbol>> symbolDict = getFamilySymbols(doc, cat);
List<FamilySymbol> symbolList;
FamilySymbol familySymbol = null;
if (symbolDict.ContainsKey(familyName))
{
symbolList = symbolDict[familyName];
IEnumerable<FamilySymbol> foundSymbols = symbolList.Where(g => g.Name == symbolName);
if (foundSymbols.Count() > 0)
{
familySymbol = foundSymbols.First();
}
}
return familySymbol;
}
}
}
I haven't tested that on families that don't have any named types but it shouldn't be too hard to modify if you need that functionality.