Basically what I want to do is annotate selected pipe. The function is similar as ArcMap COTs function. (Select feature in ArcMap, right click layer name in TOC and select ???Annotate Selected Features???)
I have a pipe feature layer and pipe_Anno layer which is feature linked. AnnotateLayerProperties had been custom previously. If I run ArcMap COTs function, annotation can be popped up.
Firstly, I can get AnnotateLayerProperties and then related Symbol setting, I can create an new feature and put this feature in pipe_Anno layer with related symbol setting, everything is fine except feature location, because I want to put this feature at start/end point of this pipe and all of these setting has been done in Annotation layer properties by ArcCatalog.
Then I checked the ESRI help and tried below code:
IAnnotateFeature2 pAnnotateFeature = new AnnotateFeatureClass();
IMapOverposter pMapOverposter = m_Map as IMapOverposter;
IGraphicsContainer pGraphicsContainer;
IBarrierCollection pBarrierCollection;
pBarrierCollection = m_Map.get_Barriers(m_MxdDocument.ActiveView.Extent) as IBarrierCollection;
IElement pPlacedElement=null; IElement pUnplacedElement=null;
pAnnotateFeature.Label(pMapOverposter.OverposterProperties, pAnnotateLayerProperties, pSelectedFeature, m_MxdDocument.ActiveView.ScreenDisplay as IDisplay, m_Map.SpatialReference, pBarrierCollection, out pPlacedElement, out pUnplacedElement);
The reason is I want to get Element based on custom setting, unfortunately I got error as "Attempted to read or write protected memory. This is often an indication that other memory is corrupt";
Is there something I am missing? Or is there a way can help me find the suitable annotation location based on setting?
Thank you for your help.
Regards,
Bing