Annoying Dynamic Text Glitch (Document Path)

3220
5
06-18-2012 06:33 AM
BennettMorris1
New Contributor
Hi Everyone,

I found a small, annoying problem in Arc 10.1 regarding the document path.  Lets say that you have this document path:

C:\GIS\newFolder

If you have a folder that starts with a lowercase 'n', the document path will look like this when you insert dynamic text into your MDX:

Document Path:  C:\GIS
ewFolder

I think that ArcGIS is reading the \n as a new line within the text string instead of reading the document path as pure text.  This does not affect folders that begin with an uppercase 'N'.

-Bennett
Tags (2)
0 Kudos
5 Replies
MarkBoucher
Occasional Contributor III

I think that ArcGIS is reading the \n as a new line within the text string instead of reading the document path as pure text.



I think you are right.
0 Kudos
ToddColes
New Contributor II
Anyone have a solution to this?  I've been unable to figure out how to apply the appropriate escape code to avoid this.
0 Kudos
NathanielJohnson
New Contributor
Any chance ESRI will address 10.1 issues such as this (and many others) with a patch or service pack? Many folks and organizations have shelled out lots of money for 10.1 and made commitments to it, with the understanding that ESRI would maintain things. Perhaps not a good call? Do you mean I have to add a my own text box?
0 Kudos
KimOllivier
Occasional Contributor III
I have just done a couple of tests.

Still does it in 10.2, but fixed in 10.2.1

It is all Microsoft's fault for using the escape character as a path separator because the backslash was on the DOS keyboards near the Return (now Enter) key. The rest of the computer world has always used the backslash as an escape for ASCII control characters and something else for path separators. 😮

I could not find a workaround within the dynamic text, but you could run a python script to update the text. Give the text element a name and then use the arcpy.mapping module to access the text and fix it properly.
Here is a sample run from the Python window inside ArcMap. Note the element has been named "MXDPath" in the text element properties first. Also since I am using CURRENT, the project must be saved first, Untitled mxds would have a blank filePath.

mxd = arcpy.mapping.MapDocument("CURRENT")
mxd.filePath
# u'C:\\GIS\\newFolder\\bugtest102.mxd'
el = arcpy.mapping.ListLayoutElements(mxd,"TEXT_ELEMENT","MXDPath")[0]
el.text
# u'Document Path:  <dyn type="document" property="path"  />'
el.text = mxd.filePath.replace("\\","/") # use the universal path separator supported by Windows for POSIX compliance
el.text
# u'C:/GIS/newFolder/bugtest102.mxd'
mxd.save()
del mxd

You could make this an add-in and trigger it to run when the project is resaved.

Note that I am using two backslashes in my replace function because to write a literal backslash you have to escape it with a backslash just like the \n means a newline and \t a tab etc.
0 Kudos
CourtneyGordon1
New Contributor II

I have a somewhat related question that I am hoping someone can help me with. I was using dynamic text to create a header with the name of my mxd. I have one character at the end of the name of the mxd that I do not want to display in the header (renaming the mxd is not an option). From what I have read, there is no way to remove a character using dynamic text; however, I have read that I can use Python to insert the name of the mxd as text and then remove that last character. I have been searchign and searching the Web. Is there someone who knows how to do this by chance?

0 Kudos