0

I am trying to change the text in my map layout for numerous map series. I wanted to do this via Python but am running into an issue with ArcGIS Pro's new format. I used the code from other sites but for some reason I get the error

title.text = "A"
'list' object has not attribute text

This is my code

import arcpy

aprx = arcpy.mp.ArcGISProject(r'J:\238\07_MS4\GIS\NorthHaven_MS4_GIS\NorthHaven_MS4_GIS1.aprx')
layout = aprx.listLayouts('Layout1')[0]
title = layout.listElements('TEXT_ELEMENT', 'Title')
title.text = "A"
aprx.save()
del aprx

1 Answer 1

1

You just need to change:

title = layout.listElements('TEXT_ELEMENT', 'Title')

to:

title = layout.listElements('TEXT_ELEMENT', 'Title')[0]

That way you create a single TextElement object (the first from a list) instead of a list of TextElement objects.

A TextElement object has a text property while a list object does not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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