I have a Python assignment where I have to write a script to change the style of the north arrow from “ESRI North 4” to “ESRI North 1”. I wrote the following code:
import arcpy
mxd = arcpy.mapping.MapDocument(r"F:/Lab9/Georgia.mxd")
for elm in arcpy.mapping.ListLayoutElements(mxd, "MAPSURROUND_ELEMENT"):
if elm.name == "North Arrow":
elm.style = "ESRI North 1"
mxd.save()
del mxd
It gave me no error, but It didn't change the existing style to the one I required.
Best Answer
I ran the test code below which is near identical to yours.
What you will notice is that the
print elm.style
reports:So the reason your code achieves nothing is that it simply sets a Python variable called
elm.style
to the value "ESRI North 1" rather than setting a non-existent property calledstyle
of an ArcPy MapSurroundElement object.I do not know of a way to change the style of a North Arrow using ArcPy so, if no one else does either, then I recommend that someone create an ArcGIS Idea to have ArcPy provided with a writable property on its MapSurroundElement objects.