yaron148

Anchor point

Discussion created by yaron148 on Mar 25, 2015

Hello everyone,

I'm trying to find a way to change ,in the legend properties, the legend's anchor point. The  default's anchor point is:

2015-03-25_093836.jpg

and i want this anchor point:

2015-03-25_093852.jpg

i use this code:

import arcpy
from arcpy import env 

env.workspace = r"C:\Project"
for mxdname in arcpy.ListFiles("*.mxd"):
    print mxdname
    mxd = arcpy.mapping.MapDocument(r"C:\Project\\" + mxdname)
    legend = arcpy.mapping.ListLayoutElements(mxd,"LEGEND_ELEMENT")[0]
    for lyr in legend.listLegendItemLayers():
        legend.elementHeight = 5
        legend.elementWidth = 5
    print mxdname
    for elm in arcpy.mapping.ListLayoutElements(mxd, "LEGEND_ELEMENT"):
        if elm.name == "Legend":
            elm.elementPositionX = 19.28
            elm.elementPositionY = 6.71
    print mxdname
    mxd.save()
del mxd

but the result is that the legend move to other places in the layout.

Thanks in advance.

Outcomes