Sunday, 8 May 2016

arcgis 10.3 - Changing part of text element using ArcPy?


I work with multi MXD, and the title in all of them start with "The plan on the" and then i write the map's subject, for example:


"The plan on the land use", etc. I need to change just the sentence from "The plan on the" into "The blueprint on the". All other words in the title will remain the same. I try using this code:


import arcpy

from arcpy import env

env.workspace = r"D:\desktop\Project"
for mxdname in arcpy.ListFiles("*.mxd"):
print mxdname
mxd = arcpy.mapping.MapDocument(r"D:\desktop\Project\\" + mxdname)
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
if elm.text == 'The plan on the*':
elm.text = 'The blueprint on the*'
print 'elm.text'

mxd.save()
del mxd

but it only print the MXD name:


>>> 
airplane noise.mxd
airplane noise2 a3.mxd
antiquities.mxd
conflicts.mxd
project.mxd

>>>


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...