Python add-in extension event handling issue

2589
3
10-18-2011 02:53 AM
MarkCorbin
New Contributor III
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
Tags (2)
0 Kudos
3 Replies
JasonPardy
New Contributor
Hi Szymon,

Thanks for reporting this. I was able to replicate the behavior you are reporting. I will log an incident for our developer to look into this. As you suggest, turning off the extension and turning it back on, all events work as expected.

Jason Pardy
Esri
0 Kudos
JasonPardy
New Contributor
Nimbus ID for this is: NIM074358
0 Kudos
PatrickJurgens
New Contributor III
Were the issues brought up in the root of this post ever resolved? It's 2014 now, and I seem to be having the same problem with my Python Addin extension; some events are listened to, others are ignored.
closing and re-opening the extension is not a viable solution for my work because the process needs to remain more or less transparent to the end user.
0 Kudos