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

    Revert to saved

    SDK Help
    0
    3
    420
    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 18/07/2017 at 12:37, xxxxxxxx wrote:

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

      ---------
      Hello again,

      Have searched through the online documentation, as well as the forum ... didn't find an answer to my question.
      Is there a way to detect the user selecting "Revert to saved"?
      No matter what type of plugin.
      In other words, is there a way to detect that a scene is being reloaded with its "original" content?

      Should I detect this in a SceneHook::Init ? Or is there a message sent?
      Any hint would be welcome.

      Thanks.

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

        On 19/07/2017 at 04:31, xxxxxxxx wrote:

        Hi,

        no, I don't think there is a message or any kind of notification for detecting this special case.

        There is the message MSG_DOCUMENTINFO, which can be used to detect if a document was loaded (MSG_DOCUMENTINFO_TYPE_LOAD). And there's also MSG_MULTI_DOCUMENTIMPORTED, but again, there's no info, the project got reverted.

        On the other hand, you may be able to use MSG_DOCUMENTINFO_TYPE_REMOVE in combination with one of the above. Storing the filename of the removed document and comparing it on load of a new scene. But if the user opens a scene twice, this might trigger as well.

        The NodeData::Message() Manual might also contain some context or additional information.

        May I ask, what you have in mind? Please also don't forget, a SceneHook is part of the document, so you will need some way to transport information/data from one document to the other.

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

          On 19/07/2017 at 11:21, xxxxxxxx wrote:

          Hey,
          Thanks Andreas, your answer indirectly pointed me to MSG_DOCUMENTINFO_TYPE_SETACTIVE, which seams to be the "magic solution".

          What I was trying to achieve was to track the current active object. For this I am using a MessageData plugin, and processing the EMSG_CHANGE. For each incoming EVMSG_CHANGE I check if the current active object's GUID is identical to the stored value. When value is different I know a different object is being selected, I then trigger the necessary data and store the current object's GUID, and keep listening to EVMSG_CHANGE. This seemed to work, except when user selects "Revert to saved ..." since the GUID is the same as before nothing got triggered.

          I have now investigated this MSG_DOCUMENTINFO in a SceneHookData and noticed that when a scene is loaded (or a new one is created) the SceneHook::Init can get called to 4 times. While MSG_DOCUMENTINFO_TYPE_LOAD can be posted twice. Wanting to limit the triggering, I looked for an alternative solution.
          Then I noticed that MSG_DOCUMENTINFO_TYPE_SETACTIVE only is posted once in any situation. Using this to know when the GUID of the current object can be the same as the stored one, while still need to trigger as a result of "change" in object (if you know what I mean) seems to be the solution.
          AND I also get notified when the user switches document ... for free.

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