Select to view content in your preferred language

Layout Refresh method for arcpy.mp

2235
11
07-22-2024 09:01 AM
Status: Open
Labels (1)
HaydenWelch
MVP Regular Contributor

Currently there is no way to "refresh" a standard Layout object using the mp module. You can however refresh a mapseries.

 

import arcpy.mp as mp

# Current behavior for mapseries
project = mp.ArcGISProject("CURRENT")
layout = project.listLayouts()[0]
layout.mapSeries.refresh()

# Desired behavior for layouts
project = mp.ArcGISProject("CURRENT")
layout = project.listLayouts()[0]
layout.refresh()

 

Tags (2)
11 Comments
asmith_tssw

Hi @JeffBarrette, thanks for your response. I will try to outline what the script does. It is a script tool being run within Pro. The important input to the tool is a point feature class that we update every day with points for residence addresses. We get daily map requests from our client to do a buffer analysis on residence points and see if there are businesses within a 25-mile radius to the residence points or if the point falls outside of that distance. I won't go over all of it but I will lay out the important parts.

  • Input the residence address points as a feature class.
  • Select out the points that are new using a table that we also input into the script tool for each batch of map requests.
  • Create 25-mile buffers around those points and append the newly created buffers to an existing buffer polygon feature class that is in the layout.
  • Find the nearest business point for each residence.
  • Create a line feature connecting the residence to the nearest business point and append those features to an existing line feature class that is in the layout.
  • Create a line feature class that dissolves the buffer and the line made above so that we can have an extent for the output PDF map in situations when the business is farther away from the residence than 25 miles. Append that dissolved line to a line feature class that is in the layout.
  • Then for each new residence point, create a PDF map that has three map panes. One pane shows the residence, the nearest business point, the 25-mile buffer around the residence, and the line connecting the residence to the nearest business. The second and third panes are zoomed in to show the residence and the nearest business in detail.
  • The loop that creates each PDF uses definition queries for the feature classes in the map layout to show only the features relevant for each residence. The loop also saves out an APRX for each map request so that we can fix the PDFs if there are issues.

The problem here is that the feature classes in the map layout that are being appended to (the buffer, the distance line, and the dissolved combination of the two) are not showing up in the PDF export after the new features for the current batch of new residence points have been generated and appended to them. As soon as the script is done running, then they will show up in the map if you refresh the layout, but by that point the PDFs have already been exported and the newly created features are not showing up in those exported PDFs.

Until a few months ago, this process ran smoothly and did not need workarounds for the PDFs to be generated correctly. Now I have to open up each APRX that the mapping loop saves for each map request and export the PDF from those one-by-one.

I hope this is helpful. If not maybe I can set up a call with tech support to show the process in action.

Thanks,

Alex