Select to view content in your preferred language

Setting Map Document Properties

878
4
08-30-2011 10:40 AM
WarrenMedernach
Occasional Contributor III
Hello,

I am trying to update Map Document Properties, but am struggling with the syntax for a carriage return/ line feed in the description property.

If I use the Python window I can retrieve the description property and it looks something like this:
>>> mxd.description
u'Test Line 1\r\nTest Line 2'


If I set the description property with the Python window with the following string:
>>> mxd.description='New Line 1\r\nNew Line 2'


It works as expected.

However, if I try to specify that same string via a script parameter it adds an extra '\' and looks like:
u'Test Line 1\\r\\nTest Line 2'


Any ideas/suggestions would be greatly appreciated.

Thanks!

Warren M
Tags (2)
0 Kudos
4 Replies
MathewCoyle
Frequent Contributor
Should work
mxd.description= r'New Line 1\r\nNew Line 2'
0 Kudos
WarrenMedernach
Occasional Contributor III
Hi Mathew,
Thanks, but like I mentioned, everything works when I execute it from the Python window.  The problem is when I try to use an input parameter like this:
0 Kudos
MathewCoyle
Frequent Contributor
Ahh, sorry for my misunderstanding.

The only solution I can see is to have a parameter for each line you want to add, workable if you have a fixed number of lines to add each time.
0 Kudos
MathewCoyle
Frequent Contributor
Actually now that I think about it, you can have some other character that you can split on and input those as variables surrounded by the returns, something like this.

desc = arcpy.GetParameter(0)
desc = desc.split("#")
mxd.description = desc[0]+"\r\n"+desc[1]
0 Kudos