Select to view content in your preferred language

Automatize layer display in data layout

632
3
08-15-2010 01:47 PM
JoseFunes
Emerging Contributor
Dear all,
Within the table of content, I do have a group of layers that I would like to manipulate in terms of displaying them on/off. I wrote a simple code but does not work. Please see code below. Suggestions will be appreciated.
Jose Funes
0 Kudos
3 Replies
ChrisMathers
Deactivated User
When you change layer visibility you need to refresh the map with arcpy.refreshactiveview() to see any changes. Any changes made to an mxd, as far as display goes, occur in memory and arent visible until you refresh the display.
0 Kudos
JoseFunes
Emerging Contributor
i did include the arcpy.refreshactiveview() command but it does not change. if i close it and then open it, it works!, suggestions? thanks, jose
0 Kudos
ChrisMathers
Deactivated User
Are you running this outside of arcmap or from the python window? If you are running this in IDLE or something it may not work properly. To make this work, run the script from within arcmap and set the mxd to 'current'. This will give you the ability to refresh what you are actually looking at. The way you were doing it, you were editing the visibility of layers in a copy of the mxd that had been opened in memory by python.

mxd=arcpy.mapping.MapDocument('CURRENT')
0 Kudos