scientist79

CopyFeatures_management overwrites

Discussion created by scientist79 on Feb 24, 2012
Latest reply on Feb 24, 2012 by pink34
In the following code "CopyFeatures_management" copies features to the same feature class which means overwrite. How can i add new features to one feature class or namely different feature classes and prevent overwriting.

import arcpy
from arcpy import env
env.workspace = r"D:\pomme de terre 2\pomme de terre2.gdb"
env.overwriteOutput = 1

fc1 = "Flowline24k_sl_u2"
fc2 = "Graph"


for a in range(1,6):

        obj = "ID_1=%d" % (a)
        
        arcpy.SelectLayerByAttribute_management (fc1,"NEW_SELECTION",obj)      
        arcpy.SelectLayerByLocation_management(fc1,"INTERSECT",fc1)
        arcpy.CopyFeatures_management(fc1,"hidden")
        arcpy.SelectLayerByAttribute_management (fc1,"CLEAR_SELECTION")

        coordList = []

        arcpy.FeatureVerticesToPoints_management("hidden", "vertices", "MID")
        arcpy.AddXY_management("vertices")
        rows = arcpy.SearchCursor("vertices")

        for row in rows:
            X = row.getValue("POINT_X")
            Y = row.getValue("POINT_Y")
            coordList.append([X, Y])

        del row, rows

        coordList.sort()

        point = arcpy.Point()
        array = arcpy.Array()


        for feature in coordList:
            point.X = feature[0]
            point.Y = feature[1]
            array.add(point)

        polyline = arcpy.Polyline(array)           
        array.removeAll()

        arcpy.Delete_management("vertices")
        arcpy.Delete_management("hidden")        
        arcpy.CopyFeatures_management(polyline, fc2)

Outcomes