Display error when moving 'mapsurround elements' with a script

Discussion created by tsemerad on Mar 9, 2011
Latest reply on May 13, 2011 by jbarrette-esristaff
I have a script that updates the layout to correspond to the current data driven page. Part of the script chooses the most suitable scale line for the page, based on the width of 4 different scale lines located below the layout. The best scale line is moved to the position of the previous scale line, while the previous line is removed off the page. It works fine in most cases, but in some situations the scale line doesn't display.

More specifically, whenever any 'mapsurround element' (scale line, north arrow, etc.) is moved to one location, and moved back to its original location in the same script, it seems to cause this glitch.

To reproduce the bug, open up a fresh ArcMap document and add in a scale line. Paste the below code in the Python interpreter and run it. The element should be positioned with no errors. Now run it again, then right click the layout and choose "Select All Elements". You'll see that the actual bounding box of the element is not where the graphic of the element is.

mxd = arcpy.mapping.MapDocument('current')

scaleLine = arcpy.mapping.ListLayoutElements(mxd, "MAPSURROUND_ELEMENT")[0]

scaleLine.elementPositionY = -0.5

scaleLine.elementPositionY = 0.28


This bug has caused me a lot of frustration. I run a script that exports 750 pages into a multi-page pdf binder, but about 35 of the pages don't have a scale line because of the bug. Does anyone know if they're working on fixing this?