Select to view content in your preferred language

legend element issue

806
1
04-11-2012 12:23 PM
RyanKelley
Deactivated User
I have been working on a script to fit dynamic legends on the second page of a pdf. However, the legend seems to place incorrectly when I run the code.  I was writing some functions to deal with each size template... but am wondering if this is a bug or I am just using this code incorrectly.  In my script I am deleting all var's at the end and this still happens.

I stripped it down and this behavior also exists in "CURRENT" as well. Copy/paste a few times in in a row in the arcpy window and you'll see what I mean. The legend's placement and columns toggle back and forth. Perhaps if I can understand why this is happening, it may help me understand the specific issues of my script.

import arcpy
legend = MAP.ListLayoutElements(MXD, "LEGEND_ELEMENT", "Legend")[0]
legend.adjustColumnCount(4)
legend.elementHeight = 10
legend.elementWidth = 16
legend.elementPositionX = .6
legend.elementPositionY = .5
arcpy.RefreshActiveView()
0 Kudos
1 Reply
JeffBarrette
Esri Regular Contributor
Hi Ryan,

I tried to reproduce this issue using my data / mxds and could not.  I tried on 10.0 SP4 and 10.1.

I start with a legend the has 1 column and then load/run your script.  Everytime I reload the script into the Python window and run, the legend remains the same.

I did notice that you are trying to set both the elementHeight and elementWidth.  Since the aspect ratio gets locked, it only  make sense to set on.  Last one wins.

If you want to send me a map package, I'd be happy to give it a test.

Jeff
0 Kudos