Implementation of an ArcMap Auto-Refresh Function

1153
1
10-22-2017 03:17 AM
Sven_Harpering
Esri Contributor

Hey @ALL,

a customer of us is asking for a function that refreshes automatically the active view and the TOC in ArcMap every minute (or similiar). 

As there is no existing function we were thinking about developing a python add-in. These were our steps:

(1) Starting the Python-Add-In Wizard

(2) Setting the project settings

(3) Setting an extension as an Add-In content

(4) Writing the python code:

import arcpy
import pythonaddins
import time

class ArcMapRefresh(object):
    """Implementation for ArcMap_auto_refresh_addin.refresh (Extension)"""
    def __init__(self):
        # For performance considerations, please remove all unused methods in this class.
        self.enabled = False
    def newDocument(self):
        i = 0
        k = 0
        while i == 0:
            txt1 = open(r"C:\Users\xy\Desktop\test2.txt", "a")
            arcpy.RefreshActiveView()
            arcpy.RefreshTOC()
            k+=1
            txt1.write(str(k))
            txt1.close()
            time.sleep(10)
    def openDocument(self):
        i = 0
        l = 0
        while i == 0:
            txt2 = open(r"C:\Users\xy\Desktop\test3.txt", "a")
            arcpy.RefreshActiveView()
            arcpy.RefreshTOC()
            l+=1
            txt2.write(str(l))
            txt2.close()
            time.sleep(10)

We were thinking about a while-loop including an endless-loop so that the functions is running until ArcMap is closed. The *.txt-files are only implemented to see if the script is running. 

(5) Creating the Add-In and use it in ArcMap.

The result is that the script is running and refreshes the active view and the TOC in ArcMap every 10 seconds. The problem: while the script is running (and the script runs until ArcMap will be closed) nothing else can be done in ArcMap (e.g. zooming, panning or spatial analysis). 

Do you have any idea to solve this problem, or is there maybe an exisiting tool that refreshes ArcMap in a given time period? I have found this tool, but it seems that it doesn´t work anymore.

Best

Sven

Passionate about GIS and on the journey as an instructor for analytical insights.
0 Kudos
1 Reply
DanPatterson_Retired
MVP Emeritus

There are lots of 'refreshing' ideas on the ArcGIS Ideas site...

Pick the ones that interest you the most and vote one up

0 Kudos