Hi Jake, I managed to revise the Python Script of Writing geometries in the IDLE and then I executed that Python Script in the Python Window of my ArcGIS 10.0:>>> # Create a new line 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\WrintingGeometries\WritingGeometries_3features.txt"
... # Get the output feature class
... # fcname = arcpy.GetParameterAsText(1)
... fcname = r"C:\TEMP\WritingGeometries\BS_Test.gdb\Polyline_fc"
... # Get the template feature class
... #
... # template = arcpy.GetParameterAsText(2)
... template = r"C:\TEMP\WritingGeometries\BS_Test.gdb\bsInFeatureClass"
... try:
... # Create the output feature class
... #
... arcpy.CreateFeatureclass_management(os.path.dirname(fcname),
... os.path.basename(fcname),
... "Polyline", template)
... # Open an insert cursor for the new feature class
... #
... cur = arcpy.InsertCursor(fcname)
... # Create an array and point object needed to create features
... #
... lineArray = 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 = lineArray
... # Insert the feature
... #
... cur.insertRow(feat)
... lineArray.removeAll()
... lineArray.add(pnt)
... ID = pnt.ID
... # Add the last feature
... #
... feat = cur.newRow()
... feat.shape = lineArray
... cur.insertRow(feat)
...
... lineArray.removeAll()
... fileinput.close()
... del cur
... except Exception as e:
... print e.message
...
Failed to execute. Parameters are not valid.
ERROR 000732: Feature Class Location: Dataset C:\TEMP\WritingGeometries\BS_Test.gdb does not exist or is not supported
ERROR 000732: Template Feature Class: Dataset C:\TEMP\WritingGeometries\BS_Test.gdb\bsInFeatureClass does not exist or is not supported
Failed to execute (CreateFeatureclass).
What did I do wrong in this script? I just created BS_Test.gdb in my ArcCatalog 10.0. I don't know why I got the error. Please kindly help and advise.Thanks, Scott Chang