I am working on a Python script that I am running through a toolbox and ArcGIS Pro interface and am running into a problem with getting the camera extent correct. From what I can tell the setExtent
function should be looking at the selected record and take the extent and apply it to the camera. This works when I manually select the record from the attribute table. But when I leave the attribute table unselected and let the code run as it should I get the feature selected, but the setExtent
function considers the whole feature class. Where am I going wrong? I assume its an easy fix, but after scouring countless stack exchanges and ESRI help forums I cannot find a solution.
mapFrame=Layout.listElements("MAPFRAME_ELEMENT","MapFrame")[0]
Parcel=dataFrame.listLayers()[0]
Parcel.definitionQuery = "LandParcelArea.landParcelAreaIDPK = '" + LandParcelAreaIDPK + "'"
arcpy.SelectLayerByAttribute_management(Parcel,"NEW_SELECTION","LandParcelArea.landParcelAreaIDPK = '" + LandParcelAreaIDPK + "'")
new_extent = mapFrame.camera.setExtent(mapFrame.getLayerExtent(Parcel, True, True))
mapFrame.camera.scale *= 1.5