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

    CommandData plugin catch Switching documents event

    Cinema 4D SDK
    python r23
    2
    3
    421
    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.
    • mikeudinM
      mikeudin
      last edited by mikeudin

      Hello everyone!
      I trying to use this code from here to catch switching documents event with CommandData plugin Dialog.

      def Message(self, type, data):
              
              if type == c4d.MSG_DOCUMENTINFO:
                  if data['type'] == c4d.MSG_DOCUMENTINFO_TYPE_LOAD:
                      print ("Document holding object was set active")
                      return True
              
              return True
      

      But it's seems is not working in this case. Is it possible to know when user changes active document in case of CommandData plugin?
      Thank you!

      Checkout my python tutorials, plugins, scripts, xpresso presets and more
      https://mikeudin.net

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @mikeudin
        last edited by ferdinand

        Hello @mikeudin,

        Thank you for reaching out to us.

        But it's seems is not working in this case. Is it possible to know when user changes active document in case of CommandData plugin?

        The posting you are referring to states that

        "MSG_DOCUMENTINFO is [...] a node message"

        A little bit more precise would be to say it is an atom message, i.e., it is only being sent to C4DAtom instances via C4DAtom.Message(). A CommandData plugin is not an atom and its message method is part of another message stream.

        I would recommend having a look at the Python Message System Manual, as it lines out how messages work, and what kind of messages to expect in CommandData.Message.

        Long story short, no, you will not find a message that signals the active document having been changed to a CommandData plugin. You will have to hook into other messages and manually check. The messages you could range from very broad as EVMSG_CHANGE (which is being broadcasted very often) to slightly more specific message IDs like, for example EVMSG_DOCUMENTRECALCULATED. I cannot tell you which one works best for your use case, I would have to try myself. Another approach would be to implement a NodeData plugin and broadcast the information from there to your CommandData. The problem is that Python lacks a good NodeData type for that, as is lacks the SceneHookData type which would be the natural choice in C++. You can use some of the other NodeData types in Python like ObjectData or TagData, but you should know that some atom messages are not being sent to all atoms, as Cinema 4D considers them irrelevant for these plugins. MSG_DOCUMENTINFO is one of these messages, and it is for example not being broadcasted to PreferenceData, which otherwise could serve as a replacement for a SceneHookData, as it is a node which has not to be instantiated as for example an object or tag must be.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • mikeudinM
          mikeudin
          last edited by

          @ferdinand Thank you!

          Checkout my python tutorials, plugins, scripts, xpresso presets and more
          https://mikeudin.net

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