How to set the layout scale from a list of scales using arcpy

202
0
05-20-2024 03:40 AM
Abhinav_Cherukat
New Contributor

Hi,

I'm trying to change the map frame scale (or layout scale) to match the scale given in the list of scales.

For some reason, it isn't changing the layout scale, but if I print this code, it shows the scale (in my case it is a change from 13800 to 15000)

 

Please find the code below: 

 

Main_Map = lyt.listElements('MapFrame_Element', "Main Frame Map Frame")[0]

#Main_Map.camera.setExtent(Main_Map.getLayerExtent(lyr,True, True))

scales = [2500, 5000, 10000, 15000, 20000, 25000]

current_scale = Main_Map.camera.scale

next_scale = min([scale for scale in scales if scale > current_scale], default=None)

if next_scale:
mf_extent = Main_Map.getLayerExtent(lyr)
mf_extent.scale = next_scale
Main_Map.camera.setExtent(mf_extent)

Tags (3)
0 Kudos
0 Replies