Select to view content in your preferred language

Handling rotation of a group in a Layout using arcpy

119
1
a week ago
HamzaMerini
Occasional Contributor

Hello,

I have some issues with setting the rotation of a a group in a Layout

HamzaMerini_0-1759220659683.png

So here from my python code, I am trying to rotate the whole Angle_0 group, its works when I do it from Pro, but when setting it from python, it does not work !

Here's the python code part that does it

HamzaMerini_2-1759220903104.png


Do you know why I have this weird result ?
Thanks

0 Kudos
1 Reply
AlfredBaldenweck
MVP Regular Contributor

I think the issue is that you're using "rotation" instead of "elementRotation". For some reason, this does not throw an error, although my guess is it is assumed you're adding a new property to the layoutElement that just nothing knows how to read.

AlfredBaldenweck_5-1759253235415.png

import arcpy
aprx = arcpy.mp.ArcGISProject("CURRENT")
lay = aprx.listLayouts()[0]
grp = lay.listElements(wildcard = "Group Element")[0]
for sub in grp.elements:
    if sub.name == "nestedGrp":
        sub.setAnchor("LEFT_MID_POINT")
        sub.elementRotation = 90
        
    else:
        sub.setAnchor("CENTER_POINT")
        sub.elementRotation = 0
    

AlfredBaldenweck_6-1759253268686.png

 

 

0 Kudos