I'm rewriting a Python 2.x script so that it can be used in Pro. I am struggling to figure out the syntax for refreshing a map series in Python. I found this page: MapSeries—ArcPy | ArcGIS Desktop, and I know there is a refresh() method, but I cannot figure out how to use it. I tried
lyt = aprx.listLayouts("AgLayout") for lyr in m.listLayers("Parcel*"): lyr.definitionQuery = "JOINPIN = '201-02-0-00-00-012.03-0'" lyt.refresh()
Line 6 throws an error that says "AttributeError: 'Layout' object has no attribute 'refresh'
Solved! Go to Solution.
Use the refresh method if any of the following occurs:
- Features are added to or deleted from your index layer.
- Updates are made to the index field values.
- The map frame extent is changed due to zooming, panning, or change to map scale.
Once the script is completely rewritten, the user will input a PIN number for the parcel being mapped. When that PIN number changes, it will meet the criteria for using the refresh method. I just can't figure out how to tell it to refresh.
Yeah, based on the documentation it sounds like it might be a bug (maybe related to the inability to set the map extent in a map view using arcpy.mp). Are you using the PIN to update the layer's definition query? I notice that in ArcMap refreshing the data driven pages zooms to the visible features, but as you say, refreshing the map series doesn't change the map's extent in Pro.
If you're using definition queries, the zoomToAllLayers() method of the MapFrame class might provide what you're looking for. Something like lyt.mapSeries.mapFrame.zoomToAllLayers().
Well, this is very frustrating! Refresh does not do what the ArcGIS documentation on Map Series for Pro says it should do. Even if I click the Refresh button in the ribbon, the dynamic labels update, but the map does not update its extent to the location specified by the index layer's updated definition query. I get the same results with the Python code. And, as you point out, Stephen, arcpy.mp doesn't have a zoom to selected features option. I tried zoomToAllLayers(), but it did exactly that -- zoomed to the full extent of every layer in the map.
Does anyone know how to look up bug reports to see if anyone has reported this to Esri?