Hi Josh
All the objects are correct and if I run the script without the last line it doesn't return an error.
Not sure what else to try, which is a shame! I will keep searching for a solution.
I'm not sure if you interested but the below works in terms of setting the extent if you manually select the map you want for the mapframe first:
aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps("Osterley_Boundary")[0]
lyr = m.listLayers("Osterley")[0]
lyt = aprx.listLayouts("Property_Boundary")[0]
mf = lyt.listElements("MAPFRAME_ELEMENT", "Map Frame 1")[0]
mf.camera.setExtent(mf.getLayerExtent(lyr, False, True))
Is it possible to identify the selected - or active - map frame? If this is obvious, sorry, but I have not been able to find it. I have a script that creates a polygon from a map frame extent and the user has to enter the map name to make sure I am running on the right map frame (the script picks the map frame based on the map that is selected. Kind of awkward, but may be necessary).
Thank you,
Randy