Here is my current issue, I am writting a Python script that will update my map title on a large amount of MXDs in a folder. If I hard code my text update it will work. For example if i set (hard code my text property)
elem.txt = """<FNT size="11.5">Project Title 1\r\nProject Title 2</FNT>\r\nMap of Property\r\n<dyn type= "page" property="Map_ID"/>"""
my MXDs updates with no issues
However the end result is to be able to turn my script into a Toolbox where the user can enter the updated text as needed. However when I enter the same text into my Toolbox and run the script my MXD formatting is off. i.e. the new line character is no longer inserted.
Anyone have an idea on how I can do this in the Toolbox so it doesn't throw my formatting off?
Solved! Go to Solution.
The problem is that parameters are usually passed in GP using a string representation so your newline is not getting across unmolested. I have run into this with the Calculate Value tool, where I have had to use chr(10) instead of "\n".
An approach that may work would be to instruct the user to insert a normal character ("@" for example) and replace it with the real deal in Python:
title = title.replace("@", "\n")
title = title.replace("@", chr(10))
Let's see the Toolbox code.
The problem is that parameters are usually passed in GP using a string representation so your newline is not getting across unmolested. I have run into this with the Calculate Value tool, where I have had to use chr(10) instead of "\n".
An approach that may work would be to instruct the user to insert a normal character ("@" for example) and replace it with the real deal in Python:
title = title.replace("@", "\n")
title = title.replace("@", chr(10))
Worked like a charm!! Thanks Curtis, it was the piece I was missing.
Cheers