Select to view content in your preferred language

Use arcpy to set height and width for map frames in an ArcGIS Pro project

300
0
02-28-2024 02:10 PM
Labels (1)
NSamu
by
Regular Contributor

This snippet of code is to try and automatically update the borders and dimensions of all map frames within an ArcGIS Pro project, but I cannot figure out how to get the heights and widths of the map frames to update. The code updates the borders and does not generate any errors but nothing happens to the map frame dimensions--any input on how to do that would be appreciated.

p = arcpy.mp.ArcGISProject('current')

for lyt in p.listLayouts():
    print('getting definition')
    lyt_cim = lyt.getDefinition('V2')
    mf = lyt.listElements('mapframe_element', 'Map Frame')[0]
    mf.elementWidth=6.5
    mf.elementHeight=6.5
    for elm in lyt_cim.elements:
        if type(elm).__name__ == 'CIMMapFrame':
            if elm.graphicFrame.borderSymbol.symbol.symbolLayers:
                sym = elm.graphicFrame.borderSymbol.symbol.symbolLayers[0]
                sym.width = 0
                print('setting definition')
                lyt.setDefinition(lyt_cim)
        else:
            print(elm.name + ' has NO symbol layers')
p.save()

 

Tags (3)
0 Kudos
0 Replies