I want to alter text elements in a layout. This text elements were grouped. Grouped elements behave like GraphicElement and it is possible to query the property isGroup. I can not alter these text elements before ungrouping.

enter image description here

Is it possible to ungroup these GraphicElements using arcpy?


My reasoning for this question is false. As Alex Tereshenkov points out: you can alter grouped text elements.


This could be done using python script to call arcobject LayoutTools_Ungroup command using comtypes, see:

Accessing ArcObjects from Python?


ArcMap Commands


I have tested the code on 10.3.1 and 10.5. You don't need to ungroup the graphic element in order to change the text of the group's items.

In other words, you should be able to alter the properties (eg text) of a TEXT_ELEMENT even if it is grouped and is a part of a GRAPHIC_ELEMENT.

The original image:

enter image description here

>>> import arcpy.mapping as mp
>>> mxd = mp.MapDocument('current')
>>> elems = mp.ListLayoutElements(mxd)
>>> t2 = elems[1]
>>> t2.type
>>> t2.text
>>> t2.text = 'Changed text 1'
>>> t2.text
'Changed text 1'

The text elements remain grouped after the changes are performed.

enter image description here

You can also move the items around:

>>> t1.elementPositionY
>>> t1.elementPositionY += 2

enter image description here

  • I got stuck in theory, before trying it. – EikeMike May 3 '17 at 19:22
  • @EikeMike, no worries. Glad it worked out well for you. – Alex Tereshenkov May 4 '17 at 5:18

If there were a way to do this from ArcPy then I would expect to see ungroup amongst the methods on the GraphicElement class.

As you can see from its documentation there is not one.

Consequently, you may want to consider looking for or submitting an ArcGIS Idea.

There is no ungroup method for the GraphicElement class for ArcPy with ArcGIS Pro either.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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