How to wire custom Annotation Constructor to a Tool in ArcMap 10?

2873
2
03-13-2011 10:42 AM
BobJubb
New Contributor
I have a custom annotation constructor that I need to implement in ArcMap's editing environment and I can't figure out how.

In previous versions, you simply registered the constructor in the proper category and then you could select it on the Annotation Toolbar. Now in ArcGIS 10, with the Annotation Toolbar gone, it appears that you have to create a custom tool to register  with the FeatureConstructionAnnotationTools CATIDs, and have the tool work with the anno constructor...right?

Well, I've created the tool and registered it, and sure enough it appears as a construction tool when editing an anno layer. I have my annotation constructor, which I've been using for years, but how do you assign the annotation constructor to the editor using the tool? How do you 'turn it on'?

I've read a bunch about custom shape constructors and how they're activated by assigning them to the editsketch (see the code below for the PointAlongLine ESRI sample)....but how do you accomplish that with an anno constructor (which is not a coclass of the shape constructor)?

Can anyone point me towards any code, a sample, ANYTHING that indicates how you "activate/fire up/turn on" an annotation constructor to begin placing anno?

Thanks everyone!

Bob J.
Indianapolis, IN
______________

Public Overrides Sub OnClick()
    Private m_csc As IShapeConstructor
    m_edSketch = TryCast(m_editor, IEditSketch3)

    'Restrict to line constructors (for this tool)
    m_edSketch.GeometryType = esriGeometryType.esriGeometryPolyline

    'Activate a shape constructor based on the current sketch geometry
    If m_edSketch.GeometryType = esriGeometryType.esriGeometryPoint Then
      m_csc = New PointConstructorClass()
    Else
      m_csc = New StraightConstructorClass()
    End If
    m_csc.Initialize(m_editor)
    m_edSketch.ShapeConstructor = m_csc
    m_csc.Activate()

    'set the current task to null
    m_editor.CurrentTask = Nothing
End Sub
0 Kudos
2 Replies
TimSexton1
Occasional Contributor

Bob,

Any luck with this?

0 Kudos
by Anonymous User
Not applicable

Its a little late, but here's the methodology.

Your project will have two classes.

The first class is the annotation constructor which implements IAnnotationConstructor and is registered in the AnnotationConstructors component category. The implementation of this class hasn't changed from ArcGIS 9 to 10, it just doesn't show up anywhere on the UI at 10.

The second class is the tool that provides the sketch and sets the annotation constructor. This is a regular feature construction tool that you can create with the new item wizard. This needs to be registered in the FeatureConstructionAnnotationTools component category. This appears as an annotation construction tool in the UI.


The following code snippet (back when VB was cool) shows a sketch tool using the point shape constructor feeding sketch points to a custom anno constructor.

    Public Overrides Sub OnClick()
        Try
            m_edSketch = TryCast(m_editor, IEditSketch3)
            m_csc = New PointConstructorClass()
            m_csc.Initialize(m_editor)
            m_edSketch.ShapeConstructor = m_csc
            m_csc.Activate()
            'Set the custom anno constructor
            Dim pID As New UIDClass()
            pID.Value = "esriEditor.AnnotationEditExtension"
            Dim AnnonEditExt As IAnnotationEditExtension = m_editor.FindExtension(pID)
            Dim AnnoConstructs As IEnumAnnotationConstructor = AnnonEditExt.AnnotationConstructors
            Dim rach As IAnnotationConstructor = AnnoConstructs.Next
            Do Until rach Is Nothing
                If rach.Name = "Curved (Custom)" Then AnnonEditExt.CurrentConstructor = rach
                rach = AnnoConstructs.Next
            Loop
            'Show annotation construction window
            pID.Value = "esriEditor.AnnotationConstructionWindow"
            Dim annoConWindow As IAnnotationConstructionWindow = m_editor.FindExtension(pID)
            annoConWindow.Visible = True

The rest of the tool is stock from the wizard.

0 Kudos