Return character string from dynamic text?

05-22-2014 05:43 PM
New Contributor III

Is there a way to use to dynamic text to return a number of characters from a different dynamic text string in the same map document?

For example the title of my mxd might be 00051_BaseMap
I'd like to return the first five characters of this string dynamically so that I could have:

File Name: 00051_BaseMap
Project Number: 00051

Ie the project number is drawn out of the file name dynamic text string.

Tags (2)
0 Kudos
1 Reply
MVP Regular Contributor
I do not see a way to do it within the text box.
You could give the text element a name, and then access that text element within a python script and change it with string / list functions.
I use the following snippet to alter  a text element in my layout view:
for el in arcpy.mapping.ListLayoutElements(mxd,"TEXT_ELEMENT","SSPA_Tag"):
            ToPoint = string.find(el.text,"_",5)
            el.text = "SSPA_" + + "_" + ChemName + "_" + Today.strftime("%m/%d/%Y")
            OutText = el.text

You could similarly use el.txt = el.text[:5] to return the first 5 characters.
Best Regards,
0 Kudos