Hi everyone. Ive done a bunch of searches, and have gotten much farther than I would have otherwise, but I am still getting stuck. I am trying to create a script that will change the definition query on a speicific layer in an MXD file. The script will then select by location, intersected with the new features from the layer that the definition query was changed for. Then these selected features will be copied to a new feature class or shapefile. Here is the code I have at this point. Thank you in advance for any help!!
import arcpy mxd = arcpy.mapping.MapDocument("C:/Rafig_GIS/PYTHONTESTING/2011/2011_CountyComm/Data/DataPrep.mxd") for lyr in arcpy.mapping.ListLayers(mxd): if lyr.name == "CountyCommission_TriCounty": layer.definitionQuery = "[DISTRICT] = '1' AND [COUNTY] = 'ORANGE'" arcpy.SelectLayerByLocation_management("BusRoutes_Ridership","INTERSECT","CountyCommission_TriCounty","","NEW_SELECTION") arcpy.CopyFeatures_management("BusRoutes_Ridership","C:/Rafig_GIS/PYTHONTESTING/2011/2011_CountyComm/Data/Orange/Or_Com1.shp")