alex_bn_lee

导航

[915] Implementation of zooming to layer and exporting to PDF in arcpy

ref: Camera - ArcGIS Pro

ref: Introduction to arcpy.mp


# Set the path to your project file (.aprx)
project_file = r"Map 1.3 Heritage.aprx"

# Reference the project
aprx = arcpy.mp.ArcGISProject(project_file)

# get the sitebuffer layer
m = aprx.listMaps()[0]
lyr = m.listLayers()[3]

# get the Map element of the layout
lyt = aprx.listLayouts()[0]
mf = lyt.listElements()[-1]

# set the extent to the sitebuffer layer's extent
mf.camera.setExtent(mf.getLayerExtent(lyr, False, True))

# export to PDF
lyt.exportToPDF(lyt.name)
    
del aprx

 

posted on 2023-10-20 09:48  McDelfino  阅读(29)  评论(0)    收藏  举报