HOW TO
The following script provides one way to center text around a user-defined point.
Code: '-- Headline: Centers GraphicText around a point '-- Description: The script will center a GraphicText object '-- over a user specified point. Attach this script to the '-- apply event of a Tool Button. '-- If the view you are working in is not named View1, '-- you will have to edit the script to use the correct name. aView=av.Getproject.Finddoc("View1") aDisp=aView.GetDisplay aGlist=aView.GetGraphics '-- The point is returned when the user clicks the view aPnt=aDisp.ReturnUserPoint '-- Change "Sample Test String" in the next line to what '-- you would like to use. aGtext=GraphicText.Make("Sample Test String", 0@0) '-- Create the TextPositioner Object and set the origin '-- of the GraphicText to it. tp=PointTextPositioner.Make tp.SetHAlign(#TEXTPOSITIONER_HALIGN_CENTER) tp.SetVAlign(#TEXTPOSITIONER_VALIGN_ON) aGlist.Add(aGtext) tp.Calculate(aPnt, aGtext.GetExtent, 8, nil) aGtext.SetOrigin(tp.GetOrigin) '-- Add the user defined point as a GraphicShape aGs=GraphicShape.Make(aPnt) aGlist.Add(aGs) aView.Invalidate
Note: For more information, refer to the ArcView Help topic "Customize (dialog box)."
Get help from ArcGIS experts
Download the Esri Support App