Hi,Thank you for the help. I have now got this working. The problem was that the "coordList" was being created within the loop ratherthan before the loop.I am now using this cose that works. Howver i would like to give a value to each polygon.try:
# 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 coordList: # 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
#
#print ID, pnt.ID
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()
del cur
except Exception as e:
print e.message
I have tried this:try:
# 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 coordList: # Open the input file
# set the point's ID, X and Y properties
#
FeatID, pnt.ID, pnt.X, pnt.Y = string.split(line,",")
print FeatID, 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
#
#print ID, pnt.ID
if ID != pnt.ID:
# Create a new row or feature, in the feature class
#
feat = cur.newRow()
feat.setValue("OW_ID", FeatID)
# 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.setValue("OW_ID", FeatID)
feat.shape = lineArray
cur.insertRow(feat)
lineArray.removeAll()
del cur
except Exception as e:
print e.message
However this does not populate the fcname with the FeatID correctly.Any help will be greatly appreciated.