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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    detect if undo was pressed [SOLVED]

    SDK Help
    0
    5
    528
    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
      Helper
      last edited by

      On 14/09/2014 at 03:50, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:    
      Platform:      
      Language(s) :     C++  ;

      ---------
      Hi,

      quick question:

      in a c++ plugin, is it possible to detect if the user has pressed the undo button ?

      i tried like this, but it does not detect undo's :

      Bool WinGen::Message(GeListNode *node, LONG type, void *t_data){
      .
      .
      	switch(type)
      	{			
      		case MSG_DOCUMENTINFO:	
      			info = (DocumentInfoData* )t_data;
      			if(info!=NULL && info->type == MSG_DOCUMENTINFO_TYPE_UNDO){
      				GePrint("undo!");
      			}
      			break;
        
      	}
        
      
      

      is it possible at all to detect undo's ?

      thanks,
        Daniel

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

        On 14/09/2014 at 06:12, xxxxxxxx wrote:

        Howdy,

        It seems to work in a SceneHookData plugin, but not in a ToolData or TagData plugin. With what kind of plugin did you try to use it?

        Adios,
        Cactus Dan

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

          On 14/09/2014 at 07:33, xxxxxxxx wrote:

          Hello Dan, thanks for the info.

          I tried it in an Object Generator Plugin and it did not work.
          I guess i could write a scenehook plugin that 'listens' for undo actions and then notify my generator.. but i'd actually prefer a simpler solution with less effort, especially since i have no experience with scene hooks 😉

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

            On 14/09/2014 at 08:40, xxxxxxxx wrote:

            Nothing difficult about them. You just have to keep in mind that they run above the document level, near to C4D level, therefore your SceneHook should do its thing (if there is anything to be done) and get out fast.  Here a basic example of a SceneHook:

            MySceneHook.h

            #pragma once
            ////////////////////////////////////////////////////////////////
            // MySceneHook.h
            ////////////////////////////////////////////////////////////////
              
            // CLASS: MySceneHook
            class MySceneHook : public SceneHookData
            {
            	INSTANCEOF(MySceneHook, SceneHookData)
              
            	public:
            		// General
            		MySceneHook();
            		~MySceneHook();
            		// SceneHookData
            		Bool	Message(GeListNode* node, LONG type, void* data);
            		// - Alloc
            		static NodeData*		Alloc() { return gNew MySceneHook; }
            };
            

            MySceneHook.cpp

            ////////////////////////////////////////////////////////////////
            // MySceneHook.cpp
            ////////////////////////////////////////////////////////////////
              
            #include "c4d.h"
            #include "MySceneHook.h"
              
            // METHODS: MySceneHook ==================================================================================================
            // Constructor
            //*---------------------------------------------------------------------------*
            MySceneHook::MySceneHook()
            //*---------------------------------------------------------------------------*
            {
            }
            // Destructor
            //*---------------------------------------------------------------------------*
            MySceneHook::~MySceneHook()
            //*---------------------------------------------------------------------------*
            {
            }
            // NodeData.Message
            //*---------------------------------------------------------------------------*
            Bool MySceneHook::Message(GeListNode* node, LONG type, void* data)
            //*---------------------------------------------------------------------------*
            {
            	if (type != MSG_DOCUMENTINFO)
            		return TRUE;
            	DocumentInfoData*	pDocumentInfo =	static_cast<DocumentInfoData*>(data);
            	if (!pDocumentInfo)
            		return FALSE;
            	if (pDocumentInfo->type == MSG_DOCUMENTINFO_TYPE_UNDO)
            	{
            		// Do whatever - as quickly as possible
            	}
            	return SUPER::Message(node,type,data);
            }
              
            // Global Registrant Method for MySceneHook plugin
            //*---------------------------------------------------------------------------*
            Bool RegisterMySceneHook()
            //*---------------------------------------------------------------------------*
            {
            	return RegisterSceneHookPlugin(ID_MYSCENEHOOK, "SceneHook", PLUGINFLAG_HIDE|PLUGINFLAG_HIDEPLUGINMENU|PLUGINFLAG_SCENEHOOK_NOTDRAGGABLE, MySceneHook::Alloc, EXECUTIONPRIORITY_INITIAL, 0L, NULL);
            }
            
            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              On 14/09/2014 at 09:06, xxxxxxxx wrote:

              cool man, thanks for the head start.
               I'll just go ahead then and try it out!

              thanks for your help guys !Thumbs Up[URL-REMOVED]


              [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

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