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

    Communicating data between two plugins

    Scheduled Pinned Locked Moved PYTHON Development
    8 Posts 0 Posters 683 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 13/04/2015 at 07:57, xxxxxxxx wrote:

      I have two plugins that live in different Python Plugin files. I know that we can use the Message system
      to pass Python objects around Python Plugins, but this only works with NodeData Plugins like Objects,
      Tags, etc.

      Plugin B provides a GUI that Plugin A needs data from. As it only implements a GUI, there is only a
      CommandData in Plugin B. How can I allow Plugin A to communicate with Plugin B and exchange
      Pythonic data?

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

        On 13/04/2015 at 15:07, xxxxxxxx wrote:

        Is it too simple/obvious or blundering to use maybe just a global basecontainer, populate that from the gui, and read from it with the nodedata plugin..

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

          On 14/04/2015 at 00:20, xxxxxxxx wrote:

          Hi Eclektrik,

          I can not just put any Python object in a BaseContainer, and I would have to place the container
          somewhere Plugin A can find it, eg. in the World or Plugin Data Container. I would prefer to exchange
          any Python objects between the Plugins.

          However, I just got the idea that I could just make an Object or Tag
          plugin, add methods it that should function as the API, and it does
          not need to be inserted in the document.

          def get_api() :
              return c4d.BaseTag(ID_MY_API_PLUGIN).GetNodeData()
          

          Cheers,
          Niklas

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

            On 14/04/2015 at 08:11, xxxxxxxx wrote:

            Hi Niklas,

            How would yo use your function get_api()?

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

              On 14/04/2015 at 08:55, xxxxxxxx wrote:

              Hi Yannick,

              my_plugin.pyp

              import c4d
                
              class MyAPI(c4d.plugins.TagData) :
                  PLUGIN_ID = 124242  # just a random ID, not registered
                
                  def get_welcome_message(self) :
                      return "Hello from my_plugin.pyp!"
                
              if __name__ == "__main__":
                  # register MyAPI as a TagPlugin ...
                  pass
              

              Script Manager

              def get_my_api() :
                  return c4d.BaseTag(124242).GetNodeData()
                
              api = get_my_api()
              print api.get_welcome_message()
              

              I'll write a blog post in a few days and will link it here.

              Cheers,
              Niklas

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

                On 14/04/2015 at 10:32, xxxxxxxx wrote:

                I wonder how

                c4d.BaseTag(124242).GetNodeData()
                

                can return a valid BaseTag there if the TagData is not registered?

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

                  On 14/04/2015 at 10:40, xxxxxxxx wrote:

                  I wanted to keep the snippet short so I only added a comment that MyAPI needs to be registered. Reread the snippet 🙂

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

                    On 14/04/2015 at 10:51, xxxxxxxx wrote:

                    Originally posted by xxxxxxxx

                    I wanted to keep the snippet short so I only added a comment that MyAPI needs to be registered. Reread the snippet 🙂

                    Ah ok 🙂. The comment for PLUGIN_ID confused me:

                    PLUGIN_ID = 124242  # just a random ID, not registered
                    
                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post