import arcpy, os dist = r"N:\Projects\120802 CEMA Landscape Simulation Modelling for RMWB\05- Data\glink_seismic_Buffer_ClipExample.shp" origin = r"N:\Projects\120802 CEMA Landscape Simulation Modelling for RMWB\05- Data\section_for_clipping_disturbance_features.shp" sqrs = r"N:\Projects\120802 CEMA Landscape Simulation Modelling for RMWB\05- Data\sections_analysis.shp" outfolder = r"N:\Projects\120802 CEMA Landscape Simulation Modelling for RMWB\05- Data" outpoly = r"seismic_tile_example.shp" try: arcpy.Delete_management(outfolder + "/" + outpoly) except: pass arcpy.CreateFeatureclass_management(outfolder, outpoly, "POLYGON", "", "", "", dist) distdesc = arcpy.Describe(dist) distshapefieldname = distdesc.ShapeFieldName squaredesc = arcpy.Describe(sqrs) squareshapefieldname = squaredesc.ShapeFieldName originpoly = arcpy.SearchCursor(origin) squares = arcpy.SearchCursor(sqrs) inRows = arcpy.SearchCursor(dist) outRows = arcpy.InsertCursor(outfolder + "/" + outpoly) polyarray = arcpy.Array() origindesc = arcpy.Describe(origin) originshapefieldname = origindesc.ShapeFieldName orig = originpoly.next() originvalue = orig.getValue(originshapefieldname) origincentroid = originvalue.centroid for square in squares: squarevalue = square.getValue(squareshapefieldname) squarecentroid = squarevalue.centroid xoffset = squarecentroid.X - origincentroid.X yoffset = squarecentroid.Y - origincentroid.Y polyIndex = 0 for inRow in inRows: inShape = inRow.shape pntObj = arcpy.Point() arrayObj = arcpy.Array() for pnt in inShape.getPart(polyIndex): pntObj.ID = polyIndex pntObj.X = pnt.X + xoffset pntObj.Y = pnt.Y + yoffset arrayObj.add(pntObj) outShape = outRows.newRow() outShape.shape = arrayObj outRows.insertRow(outShape) polyIndex += 1
I don't see where 'pnt' is defined, so it can't have an attribute 'X'.
Ha, now I see it. It's hard to read unformatted.
So, it looks like you initially get an array of x,y values for the first part of the polygon with this:
for pnt in inShape.getPart(polyIndex):
Now you need to pull the the individual points from the array that is the first part of the first polygon record in your feature class. Think of multipart features.
you want: this