' Name: View.XYCoordDump ' ' Title: Creates a file with coordinate information from user ' ' Topics: GeoData ' ' Description: Creates a comma delimited textfile containing a unique ID, ' x and y coordinates, and user input information. The coordinate ' information is taken from the location on the View chosen with the mouse. ' ' The Object Tag of the tool executing this script is used to store the ' current point id number. The number is retrieved at the time of execution, ' incremented, and written to the file, ensuring a unique ID number. ' Additional attributes concerning the location are input by the user, and ' all information is written to the specified file. ' ' The features described in the file, by their xy coordinates, may be added ' as a theme. First import the textfile as a Table, then use the Table as ' an XY event source. ' ' The points appear temporarilly and are not saved as part of the GraphicList ' of the display. See the section commented in the body of the script below ' to add points as Graphics to the GraphicList. ' ' Requires: The script must be executed from the apply event on a tool in a ' DocGUI that supports view documents. ' ' Self: ' ' Returns: theView = av.GetActiveDoc theFile = ("wrxyinfo.txt".AsFileName) ' Create the file and write header if it does not exist, otherwise ' open it for append, and initialize the point id... ' The object tag field of Self (the control this script is executed from) ' is used to store the ID number. ' if (theFile.IsFile.Not) then lf = LineFile.Make(theFile,#FILE_PERM_APPEND) lf.WriteElt("ID,XCoord,YCoord,Info") SELF.SetObjectTag(0) id = SELF.GetObjectTag + 1 else lf = LineFile.Make(theFile,#FILE_PERM_APPEND) if (SELF.GetObjectTag = nil) then SELF.SetObjectTag(0) end id = SELF.GetObjectTag + 1 end ' Get the point from the user... pt = theView.GetDisplay.ReturnUserPoint ' Create a symbol for the point... s = BasicMarker.Make s.SetStyle(#BASICMARKER_STYLE_PATTERN) s.SetColor(Color.GetRed) ' Draw the point on the display... d = theView.GetDisplay d.BeginClip d.DrawPoint(pt,s) d.EndClip d.Flush '' To include the point as a Graphic on the GraphicList, comment the '' previous section and uncomment the section immediately following... ' gp = GraphicShape.Make(pt) ' theView.GetGraphics.Add(gp) ' Get additional attribute information from the user... theInfo = MsgBox.Input("Enter information about the location:","Information","") if (theInfo.AsString = "nil") then theInfo = " " end ' Get the x and y values... x = pt.GetX y = pt.GetY ' Set the precision for the coordinate values... x.SetFormat( "d.dddddd" ) y.SetFormat( "d.dddddd" ) ' Build the string which will be written to the file... filestring = id.AsString+","+x.AsString+","+y.AsString+","+theInfo ' Write the string to the file, close the file, and save the ID number... lf.WriteElt(filestring) lf.close SELF.SetObjectTag(id)