1

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?

EDIT:

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

3 Answers 3

3

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
u'TEXT_ELEMENT'
>>> t2.text
u'Text2'
>>> 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
11.809199999999691
>>> t1.elementPositionY += 2

enter image description here

2
  • I got stuck in theory, before trying it.
    – EikeMike
    Commented May 3, 2017 at 19:22
  • @EikeMike, no worries. Glad it worked out well for you. Commented May 4, 2017 at 5:18
1

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

Accessing ArcObjects from Python?

and

ArcMap Commands

1

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 and acknowledge you have read our privacy policy.

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