Detect undo in ToolData.Message

On 27/12/2015 at 00:21, xxxxxxxx wrote:

Hi again,

I'd like to detect in my tool plugin when the user has pressed the Undo button (Ctrl+Z).
Looking at the python sdk I see there is a message of type MSG_DESCRIPTION_INITUNDO, but apparently this is not the message which is sent when an undo is performed.
When printing out the message type sent to ToolData.Message() I see that following values are printed to the console when undo is pressed:

Where can I find out what these values mean? Are there some include files which list which MSG represents what value?

The 200000096 seems to be related to the action I performed before the undo, while the 1001078 seems to be related to the current document. So I went with value 14 to detect the undo action, and that seems to be fine (for testing purposes). Still, I'd like to detect the proper undo message.


On 27/12/2015 at 11:23, xxxxxxxx wrote:

Write a SceneHook and check for MSG_DOCUMENTINFO_TYPE_UNDO.

See this post also:

But I am not 100% sure if this is possible in Python. Hope it helps though.

On 28/12/2015 at 02:37, xxxxxxxx wrote:


You can filter MSG_DOCUMENTINFO (the message type 1001078 you mention) and its more specific MSG_DOCUMENTINFO_TYPE_UNDO.
This message is sent to the tool plugins and here's how to use it:

  def Message(self, doc, data, type, t_data) :
      if type==c4d.MSG_DOCUMENTINFO:
          info = t_data
          if info['type']==c4d.MSG_DOCUMENTINFO_TYPE_UNDO:
              print "Undo Performed"
      return True

Avoid as much as possible using hard coded values. Moreover if you don't know what they really mean or refer.

On 28/12/2015 at 07:13, xxxxxxxx wrote:

Thanks Yannick.

Got it working.