Hello,
I'm trying to get the extent of an in_memory layer from a standalone script.
However I'm having some issues running into this.
For some reason I can't add the in_memory layer to the map current map. See could below. the # are just different ways I've tried.
I keep getting an error saying
s2 = map.listLayers('parcels_lyr')[0]
IndexError: list index out of range
I'm pretty sure that it can't find the layer. When I list the layers it is not in there.
The goal is to export a map with the extent of a 2 mile buffer (in_memory layer) around the original boundary. So it will show the original boundary with some room around all sides. But I don't want to show the buffered boundary, it's just to get the extent.
arcpy.analysis.Buffer(s,r"in_memory\buffer2","2 MILE")
arcpy.MakeFeatureLayer_management(r"in_memory\buffer2", "parcels_lyr")
for lyr in map.listLayers():
arcpy.AddMessage(lyr.name)
s2 = map.listLayers('parcels_lyr')[0]
#map.addDataFromPath(r"in_memory\buffer2")
#map.insertLayer(s, r"in_memory\buffer2", "BEFORE")
#lyt.camera.setExtent(lyt.getLayerExtent(s2, False, True))
ArcPro 2.5 python 3.x
Thanks!