Pro 3.5
Continuing in the general theme of this post: Why is layout rendering so slow? - Esri Community
Why is resizing a map frame (in arcpy) so rough?
I'm working with a mapframe in arcpy, and I can create it at literally any size with no issues. Pro might stutter a bit, but I did my math wrong at one point and had it literally 1 billion inches tall and it was fine, zippy even.
However, part of the same code is resizing the frame. When this happens, memory usage spikes and Pro frequently crashes.
I understand that the camera has to redraw, etc., but 1) the scale isn't changing and 2) the camera always stays focused on the center of its extent during a resize, so it really shouldn't matter.
Honestly, even querying the dimensions of the newly added map frame causes problems; I did an addMessage of the math to get the new dimensions and it just completely fell apart (the math being current dimension multiplied by two different numbers). Not even enacting the new dimensions; just figuring out what they should be. Pro crashed (with a memory error popup!), as did everything else I had open on the desktop.
What's going that makes resizing so difficult? I'm seriously considering just deleting and recreating with the right dimensions and stuff instead of adjusting them, if it's going to be this unreliable.
This is the code that causes it to explode (the am() function is AddMessage())
mf = layout.createMapFrame(polymf,inMap)
# am((mf.elementHeight*width*pgMult)/ mf.elementWidth)
# am( width * pgMult)
mf.elementHeight = (mf.elementHeight*width*pgMult)/ mf.elementWidth
mf.elementWidth = width * pgMult
mf.camera.setExtent(poly.extent)
mf.elementPositionX = 0
mf.elementPositionY = 0As you can see, it's a very straightforward "make the map frame, resize it, set extent, move map frame" operation. Nothing fancy at all.
How can this be gotten around? Frontloading the math fixes things (again, the initial size doesn't matter, but resizing does), but there exist conditions in which I have to resize the output, and if I can't trust Pro to not crash, I can't get this done.