ArcObjects Annotation – Getting Annotation Text Geometry as Polygon Using ArcObjects

annotation;arcobjects

How can i get the rectangle boundary of an annotation object using ArcObjects?

Once we select an object on the map, there is a boundary as shown in the first picture.

Also is there an option to get the minimum rectangle that covers the text as shown in second picture?

enter image description here

I tried

    IAnnotationFeature annoFeature;
    annoFeature.Annotation.Geometry;

but this only gives me a polyline geometry which seems to be the baseline of text

Best Answer

For your first example, try IElement.QueryOutline:

QueryOutline returns a polygon representing the outline of the element. A valid polygon object must be passed in to the method along with the current display. The method then updates the polygon object. The results for point and line elements will be similar to the minimum bounding envelope returned by QueryBounds, while the results for polygon elements while be the actual outline of the element (not the bounding envelope).

As for your second example, it's much more difficult, but should be possible by first converting the annotation to a multi-part polygon and then getting the minimum area bounding rectangle of that polygon.

The following two links should have enough code to get you there, or very close, but they are in VBA, not C#:

Related Question