0

I have 250 maps (in separate MXD's). In each map, in the Layout view there is "aaa" text. the element name value is aaa.

enter image description here

enter image description here

I try to find a way to add serial numbers to each map, so each "aaa" text will converted to serial number. The result should be like that:

enter image description here

enter image description here

The serial number will start from 1 till 250.

I wonder if it possible to do it automatically, and not doing it manually?

I work on ArcGIS 10.3.1 with python 2.7.8 versions.

0

1 Answer 1

2

this code works perfect for me:

import arcpy
from arcpy import env

env.workspace = r"G:\desktop\Project"
counter = 0
for mxdname in arcpy.ListFiles("*.mxd"):
    print mxdname
    mxd = arcpy.mapping.MapDocument(r"G:\desktop\Project\\" + mxdname)
    for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
        if elm.text == 'aaa':
            counter = counter + 1 
            elm.text = 'serial num'+str(counter)
    mxd.save()    
del mxd

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.