Select to view content in your preferred language

arcpy pan to the selected point in layout ArcPRO 3.1

03-11-2023 11:25 PM
New Contributor III

i have Stand alon Script that save html reports  that include location map 

the pan to the selected point dont wotk

in older versoins befor the 3.0 i was able to do it  now i can't, 

this function works if i run it  inside notebook  with

set to current  its not working with aprx file path 


def export_location_map(aprx_path,GlobalID,ws):
    aprx =
    m = aprx.listMaps('ReportsMap')[0]
    lyt = aprx.listLayouts("Layout*")[0]
    point_layer = m.listLayers()[0]

    GlobalID = '5130b789-9065-46e7-90b4-2cdc9cbebdc9'
    point_layer.definitionQuery = None
    point_layer.definitionQuery = f"GlobalID = '{{{GlobalID}}}'"
    selected_point,count= arcpy.SelectLayerByAttribute_management(point_layer, 'NEW_SELECTION',f"GlobalID = '{{{GlobalID}}}'")
    mf = lyt.listElements("mapframe_element", "Map Frame")[0]
    mf.panToExtent(mf.getLayerExtent(selected_point, True, False)), True, False))
    arcpy.SelectLayerByAttribute_management(point_layer, 'CLEAR_SELECTION',f"GlobalID = '{{{GlobalID}}}'")
    jpg = os.path.join(ws, 'test.jpg')
    lyt.exportToJPEG (jpg,clip_to_elements=True)



Tags (1)
0 Kudos
2 Replies
New Contributor

I have the same issue.  Did you find a solution?

0 Kudos
New Contributor III

replaced the panToExtent with :

  extent =, FalseTrue))
  df.extent = extent
0 Kudos