HOW TO
You can use the TextPositioner Avenue class to place text along a line. The script below demonstrates how to do this.
Code:
'-- Open the view with the theme you wish to label.
'-- Promote the line theme you wish to label to the
'-- top of the Table of Contents; then run the script.
'-- Edit the following line with the name of your view.
theView = av.GetProject.FindDoc("View1")
thePrj = theView.GetProjection
theFTab = theView.GetThemes.Get(0).GetFTab
shapeField = theFTab.FindField("Shape")
'-- Edit the following line with the name of the field you will use to label with.
textfield = theFTab.FindField("text")
thePLine = theFTab.GetShapeClass.MakeNull
for each rec in theFTab
theFTab.QueryShape(rec, thePrj, thePLine)
theText = theFTab.ReturnValueString(textField, rec)
gt = GraphicText.Make(theText, 0@0)
gt.SetDisplay(theView.GetDisplay)
tp = TextPositioner.Make(PolyLine)
tp.SetHAlign(#TEXTPOSITIONER_HALIGN_CENTER)
tp.SetVAlign(#TEXTPOSITIONER_VALIGN_ON)
tp.Calculate(thePLine, gt.GetExtent, 1, nil)
gt.SetOrigin(tp.GetOrigin)
gt.SetAngle(tp.GetAngle)
theView.GetGraphics.Add(gt)
end
Article ID:000003929
Get help from ArcGIS experts
Download the Esri Support App