HOW TO
The script below is designed to take the text from a view and place it into a table that can be used as an event theme. It also allows for the text to be added into other applications, such as ArcInfo and various CAD applications.
Code:
'-- This script will take all of the GraphicText
'-- objects in a view, and add the coordinates of
'-- their origins and text to a table.
'-- Get the View and the Project
theView = av.GetActiveDoc
theProject = av.GetProject
'-- Get all of the GraphicText objects in the view
theGtl = theView.GetGraphics.FindAllByClass(GraphicText)
'-- Ask the user for a name and location for the new table
def = av.GetProject.MakeFileName("label", "dbf")
theName = FileDialog.Put(def, "*.dbf", "Select file location")
'-- Create the table and the fields
theNewVTab = VTab.MakeNew(theName,dbase)
xfield = Field.Make("xcoord",#FIELD_FLOAT, 12,6)
yfield = Field.Make("ycoord",#FIELD_FLOAT, 12,6)
idfield = field.make("id", #FIELD_SHORT, 5,0)
textfield = Field.Make("text", #FIELD_CHAR, 30,0)
theNewVTab.AddFields({xfield, yfield, idfield, textfield})
'-- Add the graphic information to the table
For Each gt in theGtl
recnum = theNewVtab.AddRecord
theNewVTab.SetValue(xfield, recnum, gt.GetOrigin.GetX)
theNewVTab.SetValue(yfield, recnum, gt.GetOrigin.GetY)
theNewVTab.SetValue(idfield, recnum, (recnum+1))
theNewVTab.SetValue(textfield, recnum, gt.GetText)
end
'-- Create the table doc and add it to the project
theNewTable = Table.Make(theNewVTab)
theNewTable.SetName(theNewVTab.GetName)
theProject.AddDoc(theNewTable)
theNewTable.GetWin.Open
theNewVTab.SetEditable(FALSE)
Article ID:000004195
Get help from ArcGIS experts
Download the Esri Support App