Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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_book\9_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\Output\1_TitlePage.pdf")
del titleMXD
share|improve this question
    
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" –  dmahr Dec 30 '11 at 0:02
    
Also, make sure that your Text Element has the name Title. –  PolyGeo Feb 27 '12 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 –  Czed Feb 19 '13 at 15:51

1 Answer 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.