Ignore Null Values using getValue

1419
1
Jump to solution
03-10-2016 12:26 PM
StevenGraf1
Regular Contributor

I have a script that uses selected feature attributes and pushes them out to a pdf map.  The issue is that when a value is Null, the export PDF doesn't work.  I've been trying various methods to ignore Null values but I can't get it to work right.  Here is the error ArcMap is throwing:

return setattr(self._arc_object, attr_name, cval(val))

RuntimeError: TextElementObject: Error in setting text

Here's the code pushing out the attributes to the layout pdf.  It works right when the value isn't Null.

# Set the layer name from the Table of Contents
layer = arcpy.mapping.ListLayers(mxd, "Levee Centerline (Segment Only)")[0]  

 # create a cursor and grab the first row in the feature class for the layer specified above
        rows = arcpy.SearchCursor(layer)
        row = rows.next()
        
        #Change title text
        titleElement = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT","TitleText")[0]
        titleElement.text = row.getValue("FC_SYSTEM.System_Name")

Any ideas?

-Steven

0 Kudos
1 Solution

Accepted Solutions
WesMiller
Regular Contributor III

if row.getValue("FC_SYSTEM.System_Name") :

titleElement.text = row.getValue("FC_SYSTEM.System_Name")

else:

titleElement.text = "SomeOtherValue"

View solution in original post

0 Kudos
1 Reply
WesMiller
Regular Contributor III

if row.getValue("FC_SYSTEM.System_Name") :

titleElement.text = row.getValue("FC_SYSTEM.System_Name")

else:

titleElement.text = "SomeOtherValue"

0 Kudos