Select to view content in your preferred language

How to to get current legend column count using arcpy?

2638
4
11-03-2015 12:44 PM
SurendranNeelakantan
Occasional Contributor

Hi

Is there anyway to get current legend column count using arcpy? like legegend.columncount   OR legend.getcolumncount ? I couldn't see these properties in documentation.

I am trying to increment  column count conditionally using  legend.adjustColumnCount

Thank you

Tags (2)
0 Kudos
4 Replies
LukeSturtevant
Frequent Contributor

If I'm understanding your question you are looking to get a total count of layers represented in the legend? If so then you could use:

mxd = arcpy.mapping.MapDocument("Current")
df = mxd.activeDataFrame
legendCount = len(arcpy.mapping.ListLayoutElements(mxd, "LEGEND_ELEMENT", "Legend")[0].items)
0 Kudos
SurendranNeelakantan
Occasional Contributor

I   want to know how many columns in the  legend element.  Not how many items in the legend.

I hope It is clear now.

0 Kudos
DarrenWiens2
MVP Honored Contributor

Can you explain why incrementing adjustColumnCount doesn't work? It seems like you should be able to:

1.) make any changes to your legend

2.) record the current (original) legend elementWidth

3.) increment the number of columns using adjustColumnCount

4.) when the incremented legend elementWidth = the original legend elementWidth, you know the number of columns

0 Kudos
WesMiller
Deactivated User

The default for column count is 1 if your trying to increment a legend simply start or reset the legend to 1

LegendElement—Help | ArcGIS for Desktop 

0 Kudos