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.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Oct 11, 2018 at 6:29
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
answered Oct 11, 2018 at 10:58

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.