I am trying to copy features a number of times based on a numeric field value.
The code below works for points when the POINT type is chosen. However, when I switched the feature type to POLYGON it correctly copies the features as many times as I want, but the polygons do not display when brought into arcmap. For example, the output attribute table (shown below) is populated, but the SHAPE_length and SHAPE_Area fields are shown as zero. Is there perhaps something in this code maybe within the input or search cursor '*' function that is not reading the shape_area and shape_length fields? The input feature class is a polygon and has a defined shape_area and shape_length for each record, which is not being carried over into the output feature class.
This table is from the output polygon feature class:
def main(): import arcpy import os fc_in = r"input.gdb\inputfeatureclass" # this one exists fld_count = "PHASE_COUNT" fc_out = r"input.gdb\outputfeatureclass" # this one will be created arcpy.env.overwriteOutput = True sr = arcpy.Describe(fc_in).spatialReference # create the empty output featureclass path, name = os.path.split(fc_out) arcpy.CreateFeatureclass_management(path, name, "POLYGON", fc_in, "SAME_AS_TEMPLATE", "SAME_AS_TEMPLATE", sr) # insert the features into the output fc with arcpy.da.SearchCursor(fc_in, '*') as curs_in: flds_in = curs_in.fields idx_cnt = flds_in.index(fld_count) with arcpy.da.InsertCursor(fc_out, '*') as curs_out: for row in curs_in: cnt = row[idx_cnt] for i in range(0, cnt): curs_out.insertRow(row) if __name__ == '__main__': main()