I am using ArcGIS 10,3 and I am trying to create a python script that will automate a mapping process. I have point feature classes and polygon feature classes. I have used MakeFeatureLayer_management to create layers. I then use SelectLayerByLocation to select the polygon that INTERSECTS with the point layer and then I add both the point layer and polygon to the mxd. Once I have them there, I then zoomToSelectedFeatures. I am having trouble clearing the selected features once they have been added to the mxd prior to my exporting the mxd to a pdf. Any help would be appreciated.
JD
Solved! Go to Solution.
arcpy.SelectLayerByAttribute_management(Layer, "CLEAR_SELECTION")
arcpy.RefreshActiveView()
arcpy.SelectLayerByAttribute_management(Layer, "CLEAR_SELECTION")
arcpy.RefreshActiveView()
Untested, but I believe you can run Select Layer By Attribute, specifying CLEAR_SELECTION as the selection type.
Tested many many time previously and works.
That is a workflow that I have had to set up as well. Have a few maps templates, have to loop through each record in a polygon feature class, zoom to the feature, use attribute data to control text elements on my map, then export out to chosen output type on each template.
Ian,
Thank you very much this was very helpful. I had trouble at first using the arcpy.SelectLayerByAttribute_management right after I had added the layer and zoomToSelectedFeatures. What I ended up doing was to use a "for loop" to go through the layers in a TOCLayer list and used an "if" statement to clear it there. Not sure if this is the most efficient way to do this, but it is working now. Thanks!