arcpy pan to the selected point in layout ArcPRO 3.1

319
2
03-11-2023 11:25 PM
OrrGvili
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  arcpy.mp.ArcGISProject(aprx_path)

set to current  its not working with aprx file path 

 

def export_location_map(aprx_path,GlobalID,ws):
    aprx = arcpy.mp.ArcGISProject(aprx_path)
    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))
    mf.camera.setExtent(mf.getLayerExtent(selected_point, True, False))
    arcpy.SelectLayerByAttribute_management(point_layer, 'CLEAR_SELECTION',f"GlobalID = '{{{GlobalID}}}'")
    aprx.save()
    jpg = os.path.join(ws, 'test.jpg')
    lyt.exportToJPEG (jpg,clip_to_elements=True)

 

  

Tags (1)
0 Kudos
2 Replies
JayPalmer_FNDC_NZ
New Contributor

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

0 Kudos
OrrGvili
New Contributor III

replaced the panToExtent with :

  extent = mf.camera.setExtent(mf.getLayerExtent(Origin, FalseTrue))
  df.extent = extent
0 Kudos