AnsweredAssumed Answered

Convert Labels to Anno

Question asked by mkohlerpsl on Sep 20, 2018

I have an addin made with that allows user to create points and automatically calculate labels when a point is added. OnCreate is trapped and the label is calculated by querying the parcel data for the address and constructing a string. The process works fine and creates the labels. Next, the user needs to adjust the location of the labels so everything fits on the map nicely. So I used the Convert Labels To Annotation sample that can be found everywhere. It worked and created the annotation. The problem is that not all labels were converted and nothing was added to the overflow window, which I popup automatically after the conversion is done. So I said to the user, just use the label tool and click on the point to place the label and then adjust the location. However, the label tool is adding to the <Default> Annotation Group and not the annotation group that was just created and so the reference scale is different and the labels come out different sizes.


Currently, I have the user navigating to the TOC and right clicking the layer to create the annotation when done adding points. Users are very low level and we want to make everything as point and click as possible.


I thought if I could access the Annotation Groups and set the new anno group to be active, that would ensure all labels are at the same reference scale. I can't for the life of me figure out how to get to that. See image belowActive Annotation Target


Below is the code I used to create the annotation layer.

 Private Sub BtnPoleAnno_Click(sender As Object, e As EventArgs) Handles BtnPoleAnno.Click
        Dim pMap As IMap = pMxDoc.FocusMap
        Dim pConvertLabelsToAnnotation As IConvertLabelsToAnnotation = New ConvertLabelsToAnnotationClass()
        Dim pTrackCancel As ITrackCancel = New CancelTrackerClass()
        pConvertLabelsToAnnotation.Initialize(pMap, esriAnnotatiType.esriMapAnnotation, esriLabelWhichFeatures.esriAllFeatures, True, pTrackCancel, Nothing)
        Dim pGeoFeatureLayer As IGeoFeatureLayer = polesLyr
        If Not pGeoFeatureLayer Is Nothing Then
            Dim pFeatureClass As IFeatureClass = pGeoFeatureLayer.FeatureClass
            Dim annoName As String = String.Format("{0}_{1}", TxbBndId.Text, "poles")
            pConvertLabelsToAnnotation.AddFeatureLayer(pGeoFeatureLayer, annoName, Nothing, Nothing, False, False, False, False, False, "")
            pGeoFeatureLayer.DisplayAnnotation = False
        End If
        pMxDoc.ActiveView = pMxDoc.PageLayout
        EMS.CallExistingTool("FocusDataFrame", pMxDoc)
        EMS.CallExistingTool("ShowOverflowAnno", pMxDoc)
        EMS.SetExistingToolActive("SelectElements", pMxDoc)
        aerialLyr.Visible = False
    End Sub


I have also tried to get a reference to the anno layer for the feature class but the .Extension for the feature class always comes back = Nothing.


 Dim pDoc As IMxDocument = My.ArcMap.Application.Document
Dim pLyr As IFeatureLayer = pDoc.FocusMap.Layer(0)
Dim pAnnoClass As IAnnoClass = pLyr.FeatureClass.Extension


Would anyone be able to either figure out why the overflow window is not showing the unplaced labels, provide a clue as to how to set the Active Annotation Layer or any ideas that would help.