2

I am trying to generate a map book with the following code that I downloaded but I keep getting an errror:

*File "Y:\Planning\GIS Planning Analyst\projects\county_map_book9円_GenerateMapBook.py", line 18, in <"module> titleText.text = title File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\arcobjects_base.py", line 77, in _set return setattr(self._arc_object, attr_name, ao) RuntimeError: TextElementObject: Error in setting text*

#Read values from input dialog
title = arcpy.GetParameterAsText(0)
organization = arcpy.GetParameterAsText(1)
arcpy.AddMessage(" Updating Title Page ...")
titleMXD = arcpy.mapping.MapDocument("path\county_map_book\MapBook_TitlePage.mxd")
titleText = arcpy.mapping.ListLayoutElements(titleMXD, "TEXT_ELEMENT", "Title")[0]
titleText.text = title
arcpy.mapping.ExportToPDF(titleMXD,"path\county_map_book\Output1円_TitlePage.pdf")
del titleMXD
PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Dec 29, 2011 at 19:10
3
  • The error might be in grabbing the parameter. Try replacing the text element using a string you know to be valid, like this: titleText.text = "test string" Commented Dec 30, 2011 at 0:02
  • Also, make sure that your Text Element has the name Title. Commented Feb 27, 2012 at 7:06
  • To elaborate on @PolyGeo - under the properties of the text element (right-click access), there is an option under the "size and position" tab to give it an "element name" This should match your code Commented Feb 19, 2013 at 15:51

1 Answer 1

1

I noticed that setting empty string to element text will give an error:

RuntimeError: TextElementObject: Error in setting text

So I used one space instead of empty string and that worked fine. In your code add this before setting text:

if title == '':
 title = ' '

Weird behaviour of Python geoprocessing.

answered Aug 16, 2013 at 7:40

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.