PROBLEM
Geodatabase annotation displayed in the ArcMap window rotates, so it is no longer horizontal to the page when the projection of the ArcMap Data Frame is changed.
Note:
The contents of this article do not apply to splined annotation or annotation created to follow the angle of a line segment.
When geodatabase annotation is created in a specific coordinate system, the annotation is horizontal to the page. When the projection of the ArcMap Data Frame is changed to a new Coordinate System with a different Central Meridian, the annotation rotates either clockwise or counterclockwise toward the new Central Meridian.
Warning:
The script below must be installed in a saved MXD file in order to run correctly.
Code:
Option Explicit
' Author ESRI BeLux - nov 2004
Public Sub AnnoLineToPoint()
' Condition:
' - Start Edit session
' - Annotation selected (with text different from null string)
' -----------------------------------------------------------
Dim pEditor As IEditor
Dim pID As New UID
Dim pEnumFeature As IEnumFeature
Dim pFeature As IFeature
Dim Count As Long
Dim pActiveView As IActiveView
Dim number_feature As Integer 'Nombre de features modifiés
number_feature = 0
pID = "esriEditor.Editor"
Set pEditor = Application.FindExtensionByCLSID(pID)
pEditor.StartOperation
Set pEnumFeature = pEditor.EditSelection
pEnumFeature.Reset
Set pFeature = pEnumFeature.Next
Do Until pFeature Is Nothing
Dim pElement As IElement
Dim pAnnoF As IAnnotationFeature
Set pAnnoF = pFeature
Set pElement = pAnnoF.Annotation
If TypeOf pElement Is ITextElement Then
If TypeOf pElement.Geometry Is IPolyline Then
Dim pGeometry As IGeometry
Dim pPointColl As IPointCollection
Set pGeometry = pFeature.Shape
Set pPointColl = pGeometry
Dim pPointColl2 As IPoint
Set pPointColl2 = New Point
'Place the point of the point on the middle of the line
'The text is place in a polygone.
Dim newx As Double, newy As Double
newx = ((pPointColl.Point(0).X + pPointColl.Point(3).X) / 2)
newy = ((pPointColl.Point(0).Y + pPointColl.Point(3).Y) / 2)
pPointColl2.PutCoords newx, newy
Set pGeometry = pPointColl2
pElement.Geometry = pGeometry
Dim pTextElement As ITextElement
Set pTextElement = pElement
Dim pSimpTextSymbol As ISimpleTextSymbol
'we need to reset the offset because the feature shape doesn't
'represent it. Otherwise, the text will move if it has offsets
Set pSimpTextSymbol = pTextElement.Symbol
pSimpTextSymbol.Angle = 0 ' Force the texte to be horizontal
pTextElement.Symbol = pSimpTextSymbol
Set pElement = pTextElement
pAnnoF.Annotation = pElement
Set pFeature = pAnnoF
pFeature.Store
number_feature = number_feature + 1
'do nothing for lines: we are working with points here
End If
End If
Set pFeature = pEnumFeature.Next
Loop
pEditor.StopOperation "Convert Line to point annotations for " & number_feature & " features."
pEditor.Display.Invalidate Nothing, True, esriAllScreenCaches
End Sub
Article ID: 000009577
Get help from ArcGIS experts
Download the Esri Support App