I'm looking to shift a scale bar with Python, and as such have a small proof of concept script happening in a python console window. Using the below code, no matter the location given with elementPositionY, the scale bar does not seem to change location at all.
- My current mxd has a single scale bar named "ScaleBar1"
- My data frame has a geographic coordinate system set (not sure if this matters).
- I'm attempting to access the scale bar this way because ultimately I'll extend the for and if statements to work with multiple bars and some logic.
- I'm not a python coder, so please be gentle.
My code:
mxd = arcpy.mapping.MapDocument(r"C:\users\I5-Desktop\Documents\untitled.mxd") #current mxd
scaleBar = arcpy.mapping.ListLayoutElements(mxd,"MAPSURROUND_ELEMENT","ScaleBar1") #enforce working on "ScaleBar1". Can use wildcards when we have more.
for item in scaleBar:
print item.name #confirm that we are working on the only scalebar that's currently in the document
if item.name == "ScaleBar1":
item.elementPositionY = 1
print item.name #reconfirm we have entered the if statement with the name
What reason might there be for the scalebar not changing location? I can resolve its name, and enter a loop based on its name, etc.