Select to view content in your preferred language

error in setting text

355
2
12-29-2011 05:11 AM
SamanthaEdwards
Deactivated User
I am trying to generate a map book with the following code that I downloaded but I keep getting an errror: 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


I know it has to do with titleText.text = title, I'm just not sure how to fix it.

Thanks for your help,
S
Tags (2)
0 Kudos
2 Replies
StephanieWendel
Esri Contributor
This snippet of code works. When you run the script in say PythonWin, are you inserting text into the arugment section of the "Run Script" dialog? I got this error only when I didn't give an arugment. The text in the argument would then be assigned to the variable title since you have the GetParameterAsText option setup here. This would then get propagated down to where you want to change the title's text, titleText.text = title. You can also hard code what you want the title variable to be until you are ready to make this into a script tool.
0 Kudos
SamanthaEdwards
Deactivated User
Ok, I figured out that I need to run the script through a script tool, which allows me to enter the needed arguments.

Thanks for your reply.

S
0 Kudos