Results 1 to 3 of 3

Thread: Create New Annotation Symbol

  1. #1
    Member
    Join Date
    2003-11
    Posts
    2
    0 Did you find this post helpful? Yes

    Default Create New Annotation Symbol

    I'm working on a add-in to edit and insert annotation symbols. I can edit and delete annotation symbols easily enough, but I can't figure out how to insert a new one! I know the name of the family, and it has only one type. There's the NewAnnotationSymbol method, but I can't seem to get the annotationsymboltype from the name. I think I may have gotten around this by filtering the database for an element, and then working my way back up to the symbol. So I have three questions: 1) Is that the only way to get the annotation symbol type? 2) is the following line correct?

    new_key=doc.Document.Create.NewAnnotationSymbol(point, ann_type, doc.ActiveView);

    /* where the following were previously defined
    Element new_key;
    XYZ point;
    AnnotationSymbolType ann_type */

    and 3) Just before this line, I'm prompting for a point (doc.Selection.Pickpoint). I assume I have to close my form first. I'm doing something wrong there, because I tried to call the close() method but the form is still visible and it locks up everything.

    Thank you for reading this, and I apologize if it seems incoherent. If I've left out a lot of necessary information, please let me know.

  2. #2
    Member
    Join Date
    2003-11
    Posts
    2
    0 Did you find this post helpful? Yes

    Default Re: Create New Annotation Symbol

    Discovered part of the solution through trial and error. I needed to call the form.dispose() method instead of form.close() to pick my point.

  3. #3
    Member
    Join Date
    2012-09
    Posts
    31
    0 Did you find this post helpful? Yes

    Default Re: Create New Annotation Symbol

    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.

Similar Threads

  1. Annotation Symbol Leaders
    By colmag6 in forum Revit MEP - Wish List
    Replies: 1
    Last Post: 2011-10-27, 12:14 PM
  2. Annotation Symbol
    By mr6jam in forum Revit Architecture - General
    Replies: 5
    Last Post: 2009-07-14, 08:22 PM
  3. Annotation symbol, again
    By greg.gebert978266 in forum Revit Architecture - Families
    Replies: 8
    Last Post: 2008-05-27, 02:54 PM
  4. Annotation Symbol
    By shatcher in forum Revit Structure - General
    Replies: 0
    Last Post: 2008-04-15, 04:00 PM
  5. Annotation Symbol
    By brentcarlson892079 in forum Revit Architecture - Families
    Replies: 5
    Last Post: 2003-08-14, 01:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •