Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inputLayer = arcpy.GetParameter(0)
- idField = arcpy.GetParameter(1)
- i = arcpy.GetParameter(2) # start value
- grid = r"R:GISPROJECTSDept_WaterUtilitiesToolsOceansideToolbarShapefilesGrids.shp"
- field_names = [f.name for f in arcpy.ListFields(grid)]
- cursor = arcpy.UpdateCursor(inputLayer)
- arcpy.AddMessage("Generating ID's...n")
- for row in cursor:
- #Select by location
- arcpy.SelectLayerByLocation_management('grid', 'intersect', 'inputLayer')
- for field in field_names:
- C = row.getValue("COL")
- R = row.getValue("ROW")
- for id in idField
- ID =
- Fc = str(i).zfill(2)
- Col = str(C).zfill(2)
- Row = str(R).zfill(2)
- Fno = str(i).zfill(3)
- Code = Fc + Col + Row + Fno
- row.setValue(idField, Code)
- cursor.updateRow(row)
- i += 1
- arcpy.AddMessage("nnFinished...")
- arcpy.AddMessage("Last ID created: " + uniqueID)
Add Comment
Please, Sign In to add comment