help,how to add a plygon to a shpefile with arcpy

Discussion created by montez on Jul 25, 2011
Latest reply on Jul 26, 2011 by cfox-esristaff
i worte a script to create a shapefile ,but i don't know how to draw a polygon in this shapefile.
i used  the code on help and draw some polygons to a new shapefile, but i don't know how to write these polygons to the shapefile i had created at beginning.
my code is:
# Import system modules
import arcpy
from arcpy import env
print arcpy.ListEnvironments()
# Set workspace
env.workspace = "D:/temp"

# Set local variables
out_path = "d:/temp"
out_name = "Mapindex.shp"
geometry_type = "POLYGON"
#template = "study_quads.shp"
has_m = "DISABLED"
has_z = "DISABLED"
# Creating a spatial reference object
prjfile = "C:\Program Files\ArcGIS\Desktop10.0\Coordinate Systems\Geographic Coordinate Systems\Asia\Beijing 1954.prj"
spatial_reference = arcpy.SpatialReference(prjFile)
# Execute CreateFeatureclass

if arcpy.Exists(out_path +"/" + out_name):
   arcpy.Delete_management(out_path +"/" + out_name)
   arcpy.CreateFeatureclass_management(out_path, out_name, geometry_type,"" , has_m, has_z, spatial_reference)
   arcpy.CreateFeatureclass_management(out_path, out_name, geometry_type,"" , has_m, has_z, spatial_reference)
# Set local variables
inFeatures = out_path +"/" + out_name
fieldName = "Mapcode"
fieldLength = 10
# Execute AddField twice for two new fields
arcpy.AddField_management(inFeatures, fieldName, "TEXT", "", "", fieldLength)

# A list of features and coordinate pairs
coordList = [[[108,32], [108,36], [114,36],[114,32]],[[108,32], [108,36], [102,36],[102,32]]]
# Create empty Point and Array objects
point = arcpy.Point()
array = arcpy.Array()
# A list that will hold each of the Polygon objects
#featureList = []
for feature in coordList:
    # For each coordinate pair, set the x,y properties and add to the
    #  Array object.    #
    for coordPair in feature:
        point.X = coordPair[0]
        point.Y = coordPair[1]

    # Add the first point of the array in to close off the polygon

    # Create a Polygon object based on the array of points
    polygon = arcpy.Polygon(array)

    # Clear the array for future use

    # Append to the list of Polygon objects

# Create a copy of the Polygon objects, by using featureList as input to
#  the CopyFeatures tool.
# env.OverwriteOutput = True
# arcpy.CopyFeatures_management(featureList, inFeatures)
and the error is 000725 : Dataset "d:\temp\Mapindex.shp"  already exists.

how can i do?
hope help,thanks