Arcmap Python add-in wizard run code on start-up/open document

المشرف العام

Administrator
طاقم الإدارة
I have the following code that I want to run each time a Arcmap is open:

Windows 7ArcMap 10.3.1

I have followed the instructions here: http://resources.arcgis.com/en/help/main/10.1/index.html#//014p00000018000000

It's suppose to run on an OpenDocument event. However the code does not run. If I copy paste into the python window in Arcmap it works fine, any ideas?

import arcpyimport pythonaddinsimport getpassclass OnOpen(object): """Implementation for RunOnOpen_addin.OnStart (Extension)""" def __init__(self): # For performance considerations, please remove all unused methods in this class. self.enabled = True OnOpen.openDocument(self) def openDocument(self): mxd = arcpy.mapping.MapDocument("CURRENT") text_elements = arcpy.mapping.ListLayoutElements(mxd,"TEXT_ELEMENT") username = getpass.getuser() initial = username[0] lastname = username[1:] name = initial.title() + ". " + lastname.title() for element in text_elements: if element.name == 'Producer': element.text = "Producer: " + nameOnOpen()

أكثر...
 
أعلى