Ok. I was selecting in the explorer. If I select in the viewport the
command written in the 'Selection Change' is executed.

Anyway, I think there is a bug when you register the event
siOnSelectionChange. I think It should be fired when a selection is undone.

If someone wants to reproduce...

1. Register the event.

import win32com.client
from win32com.client import constants

def XSILoadPlugin( in_reg ):
in_reg.Author = "ana.gomez"
in_reg.Name = "testEvents"
in_reg.Major = 1
in_reg.Minor = 0

in_reg.RegisterEvent("SelectionChange", constants.siOnSelectionChange)
in_reg.RegisterEvent("ValueChange", constants.siOnValueChange)
 return True

def XSIUnloadPlugin( in_reg ):
strPluginName = in_reg.Name
Application.LogMessage(str(strPluginName) + str(" has been
unloaded."),constants.siVerbose)
return True

def SelectionChange_OnEvent( in_ctxt ):
Application.LogMessage("SelectionChange_OnEvent called")
return True

def ValueChange_OnEvent( in_ctxt ):
Application.LogMessage("ValueChange_OnEvent called")
return True

2. Select several things in the viewport or in the explorer. The message
"SelectionChange_OnEvent called" is written.

3. Undo. The message is not written.

4 Change the name of an object. The message 'ValueChange_OnEvent called' is
written.

5 Undo. This time the message 'ValueChange_OnEvent called'  is written.

Reply via email to