Hi all,In a text file, I stored the ID, X-coordinate and Y-coordinate of 12 points - see the attached txt file. I used the Python Window of my ArcGIS 10.0 to execute the following Python script:>>> #////// newWritingGeometries12Points.py ////////////
... # Create a new "Point" feature class using a text file of coordinates.
... # Each coordinate entry is semicolon delimited in the format of ID;X;Y
... # Import ArcPy and other required modules
... #
... import arcpy
... from arcpy import env
... import fileinput
... import string
... import os
... env.overwriteOutput = True
... # Get the coordinate ASCII file
... #
... #infile = arcpy.GetParameterAsText(0)
... infile = r"C:\TEMP\WritingGeometries\WritingGeometries_12Points.txt"
... # Get the output feature class
... # fcname = arcpy.GetParameterAsText(1)
... fcname = r"C:\TEMP\BS_Test.gdb\Points12_fc"
... # Get the template feature class
... #
... # template = arcpy.GetParameterAsText(2)
... template = r"C:\TEMP\BS_Test.gdb\bsInFeatureClass"
... try:
... # Create the output feature class
... #
... arcpy.CreateFeatureclass_management(os.path.dirname(fcname),
... os.path.basename(fcname),
... "Point", template)
... # Open an insert cursor for the new feature class
... #
... cur = arcpy.InsertCursor(fcname)
... # Create an array and point object needed to create features
... #
... pointArray = arcpy.Array()
... pnt = arcpy.Point()
... # Initialize a variable for keeping track of a feature's ID.
... #
... ID = -1
... for line in fileinput.input(infile): # Open the input file
... # set the point's ID, X and Y properties
... #
... pnt.ID, pnt.X, pnt.Y = string.split(line,";")
... print pnt.ID, pnt.X, pnt.Y
... if ID == -1:
... ID = pnt.ID
... # Add the point to the feature's array of points
... # If the ID has changed, create a new feature
... #
... if ID != pnt.ID:
... # Create a new row or feature, in the feature class
... #
... feat = cur.newRow()
... # Set the geometry of the new feature to the array of points
... #
... feat.shape = pointArray
... # Insert the feature
... #
... cur.insertRow(feat)
... pointArray.removeAll()
... pointArray.add(pnt)
... ID = pnt.ID
... # Add the last feature
... #
... feat = cur.newRow()
... feat.shape = pointArray
... cur.insertRow(feat)
...
... pointArray.removeAll()
... fileinput.close()
... del cur
... arcpy.SetParameterAsText (0, fcname) # newly added 18Sept2012, per BS.
... except Exception as e:
... print e.message
...
1 -61845879.0968 45047635.4861
2 -3976119.96791 46073695.0451
ERROR 999999: Error executing function.
>>>
I have no ideas why I got: ERROR 999999: Error executing function. Please kindly help and tell me where I made mistakes and how to resolve this error.Thanks,Scott Chang