Get list of maps referenced in layout

470
3
09-16-2022 01:57 PM
Status: Already Offered
Labels (1)
macbeer
New Contributor II

I would like to be able to identify map(s) referenced by a layout.

I have a workflow where I will be importing one or more mxd documents into a Pro project.

I would like to manipulate map layers (datasources, layer names, symbol properties, etc) for maps that are referenced by a specific layout.

Note: In my workflow a map is never referenced by more than one layout.

for lyt in aprx.listLayouts():
for map in lyt.listMaps():
...

 

3 Comments
JeffBarrette

Hello Macbeer,

 

This could be accomplished by iterating through the MapFrames on a layout.  Once you have a MapFrame, then you can get to its associated Map.  And then you can get to the layers.

Here is a snippet:

p = arcpy.mp.ArcGISProject('current')
for lyt in p.listLayouts():
for mf in lyt.listElements('MapFrame_Element'):
m = mf.map
print(f"Layout: {lyt.name}, MapFrame: {mf.name}, Map: {m.name}")

Here is a screenshot that includes the indents:

Capture.PNG

 Jeff - Layout and arcpy.mp teams

macbeer

Thanks Jeff - glad to see my request already exists in the current product.

I will do more research in the future to see if my 'idea' is already possible.

JeffBarrette
Status changed to: Already Offered

This can be accomplished using arcpy.mp.  A sample was provided.