Original User: roy_hewittThis is the method that I have already in my code (and it works in the python window):
arcpy.MakeFeatureLayer_management(sheds, "currentShed", clipClause) # Create feature layer of HUC (from user input)
arcpy.SelectLayerByAttribute_management("currentShed", "NEW_SELECTION", clipClause) # Select current HUC
df.zoomToSelectedFeatures() # Zoom to extent of selected HUC
arcpy.RefreshActiveView # Refresh view of mxd before exporting to PNG
I tried your method as follows and got the same result:
arcpy.MakeFeatureLayer_management(sheds, "currentShed", clipClause) # Create feature layer of HUC (from user input)
arcpy.SelectLayerByAttribute_management("currentShed", "NEW_SELECTION", clipClause) # Select current HUC
layer = arcpy.mapping.Layer("currentShed")
df.extent = layer.getExtent()
arcpy.RefreshActiveView()
I'm noticing that when I run the script tool I never see the feature layer "currentShed" created. When I run the code in the python window I see each successful step with the creation of the feature layer, and the selection made. The extent changes immediately after the selection tool succeeds.