Python 3.x syntax for refreshing a map series (formerly DDP)

2154
6
Jump to solution
01-23-2019 01:35 PM
AmyRoust
Occasional Contributor III

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")[0]

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'

0 Kudos
1 Solution

Accepted Solutions
StephenM
Occasional Contributor II

You need to access the mapSeries property of the Layout object, since refresh() is a method of the mapSeries object. Something like lyt.mapSeries.refresh().

View solution in original post

6 Replies
DanPatterson_Retired
MVP Emeritus

MapSeries—ArcPy | ArcGIS Desktop 

with limitations

refresh ()

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.
0 Kudos
AmyRoust
Occasional Contributor III

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.

0 Kudos
StephenM
Occasional Contributor II

You need to access the mapSeries property of the Layout object, since refresh() is a method of the mapSeries object. Something like lyt.mapSeries.refresh().

AmyRoust
Occasional Contributor III

That worked! Well, OK, it refreshed the dynamic text that I had on the page, but it did not refresh the map's extent to go to the new PIN. Maybe that's a bug?

0 Kudos
StephenM
Occasional Contributor II

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().

0 Kudos
AmyRoust
Occasional Contributor III

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?

0 Kudos