mcorbin-esriuk-esridist

Python add-in extension event handling issue

Discussion created by mcorbin-esriuk-esridist on Oct 18, 2011
Latest reply on Apr 8, 2014 by patrick.jurgens
Hello,

I have been examining life cycle and sequence in which events fired by ArcMap 10.1 are handled by Python extension. It turns out that some of them work properly all the time while other on some occasions fail.

For the tests i simply log into a text file execution of the method, for example like this:
    def itemAdded(self, new_item):
        logger.debug( "+itemAdded")
        self.validateLayers()      
        pass

    def beforeCloseDocument(self):
        logger.debug( "beforeCloseDocument")
        pass


What i noticed is that after opening a new document or an existing one some of events don't get fired - there are no entries in log file confirming their execution. On the other hand some methods/events keep being fired all the time. What helps is

Go to Customize->Extensions -> uncheck <tested extension> and check it back

After that the missing events start working back again.

Events that caused the problem were:

  • contentsChanged

  • itemReordered

  • itemDeleted

  • itemAdded

For testing it I've been simply adding/removing a layer and changing it's symbology, reordering order of layers in ToC. Also the events seem to be reflecting events of .NET's IActiveViewEvents Interface. On the other hand events that were always working would reflect from IDocumentEvents Interface, that is for example :

  • beforeCloseDocument

  • closeDocument

  • activeViewChanged

  • newDocument

My suspection is that there is something wrong with the way how mentioned interfaces or their area. Can this be verified?

In the attachment there is my test add-in project which consists of the extension and some small testing tool.

Thanks,
Szymon Piskula

Attachments

Outcomes