I am trying to replace a single, 3 line text elements in ArcGIS Pro 2.8.3, with a new, single 3 line text elements. The existing text looks like this in the layout:
NATIONWIDE PERMIT 3
COD ART RANK PARK TO DEMON BRIDGE
LA PLATA COUNTY, COLORADO
and the text I want is
NATIONWIDE PERMIT 3
ANIMAS RIVER TRAIL - RANK PARK SEGMENT
LA PLATA COUNTY, COLORADO
My code does not throw any errors, but it does not change the desired text. I believe it is related to the multiple lines, since the same code works fine for single line text elements. I don't think it is finding the existing text. My code is:
aprx = arcpy.mp.ArcGISProject(r"CURRENT")
for lyt in aprx.listLayouts():
for elm in lyt.listElements("TEXT_ELEMENT"):
if elm.text == "NATIONWIDE PERMIT 3 \n COD ART RANK PARK TO DEMON BRIDGE \n LA PLATA COUNTY, COLORADO":
elm.text = "NATIONWIDE PERMIT 3 \n ANIMAS RIVER TRAIL - RANK PARK SEGMENT \n LA PLATA COUNTY, COLORADO"
aprx.save()
del aprx
I have also tried
import arcpy
aprx = arcpy.mp.ArcGISProject(r"CURRENT")
for lyt in aprx.listLayouts():
for elm in lyt.listElements("TEXT_ELEMENT"):
if elm.text == """NATIONWIDE PERMIT 3
COD ART RANK PARK TO DEMON BRIDGE
LA PLATA COUNTY, COLORADO""":
elm.text = """NATIONWIDE PERMIT 3
ANIMAS RIVER TRAIL - RANK PARK SEGMENT
LA PLATA COUNTY, COLORADO"""
aprx.save()
del aprx