I have a problem updating a map element text (named
element1) in a map document using the following code:
a1 = '"' + ("element" + str(1)) + '"' for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"): if elm.name == a1: elm.text = str("new text") elm.elementPositionX = 0.6046 elm.elementPositionY = 6.4636
The code above does not update the
element1 with the
new text value.
It looks like the following part does not work:
if elm.name == a1:
Because when using the below hard coded approach:
if elm.name == "element1":
It worked, but I need to have it as variable.
What am I doing wrong here?