Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Detect undo in ToolData.Message

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 420 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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:
      7
      200000096
      14
      1001078

      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.

      Thanks

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

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

        Write a SceneHook and check for MSG_DOCUMENTINFO_TYPE_UNDO.

        See this post also: https://developers.maxon.net/forum/topic/8134/10595_detect-if-undo-was-pressed-solved

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

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

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

          Hi,

          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.

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

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

            Thanks Yannick.

            Got it working.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post