Automate addAllValues arcpy function

531
1
01-28-2019 11:36 AM
RamseyJeff
New Contributor III

Hi there,

Very new to python, and trying to have my map symbology dynamically update when any changes are made (instead of going to Properties - Symbology - Add All Values), following the code in this post: UniqueValuesSymbology—Help | ArcGIS for Desktop 

The script works great, but I don't understand how I can get it to just run all the time whenever I make an edit. Otherwise, it saves me no time to run the script, rather than go in and click "Add all values". Below is the code I'm using. Is there no way to just have it just run all the time, whenever an edit to that layer is made?

Thanks!!

>>> import arcpy
... mxd = arcpy.mapping.MapDocument("current")
... lyr = arcpy.mapping.ListLayers(mxd, "Planting Spaces")[0]
... if lyr.symbologyType == "UNIQUE_VALUES":
... lyr.symbology.valueField = "AGS_MAINT_PARKS.PARKS_ADMIN.uf_park_tree_inventory_Species_lookup_table.Common_name"
... lyr.symbology.addAllValues()
... arcpy.RefreshActiveView()
... arcpy.RefreshTOC()
... del mxd
...
>>>

0 Kudos
1 Reply
DanPatterson_Retired
MVP Emeritus

This posted in the python section, so no. scheduled tasks, tools in toolboxes etc is what python is good at.  

If you are changing things that often, delaying the update until you are done seems prudent.  For automagic….perhaps  arcobjects, 

0 Kudos