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

    Sending a message to an objectdata plugin

    Scheduled Pinned Locked Moved PYTHON Development
    8 Posts 0 Posters 1.0k 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 26/09/2017 at 15:08, xxxxxxxx wrote:

      Is it possible to send a message to a object data plugin?

      I am using this little script to trigger an object data plugin.

      def main() :
          
          plugin_2_obj = c4d.plugins.FindPlugin(plugin_id)
          MY_CUSTOM_MSG_ID = 4
          python_object_to_send = [1,2,3,4,4] 
          plugin_2_obj.Message(MY_CUSTOM_MSG_ID, python_object_to_send )
        
      if __name__=='__main__':
          main()
      

      In the object data plugin I have following:

          def Message(self, node, type, data) :
              if (type == 4) : print "type: ", type
              return True
      
      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 27/09/2017 at 01:19, xxxxxxxx wrote:

        Hello,

        a NodeData base plugin can only receive the data of special, hardcoded messages. So if you want to sent data to that plugin you must use a registered message type/ID.

        There is a message c4d.MSG_BASECONTAINER which allows to send a BaseContainer. It seems that it can be used to send arbitrary data.

          
        bc = c4d.BaseContainer()  
        bc.SetInt32(0, 100)  
        bc.SetInt32(1, 200)  
          
        op.Message(c4d.MSG_BASECONTAINER, bc)  
        
          
        def Message(self, node, type, data) :  
          
          if type == c4d.MSG_BASECONTAINER:  
              print("Data:")  
              for value in data:  
                  print(value)  
        

        But please test carefully if this has any side effects.

        BTW why are you using FindPlugin()? This is not used to access an instance of an ObjectData plugin in a document.

        best wishes,
        Sebastian

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

          On 27/09/2017 at 01:47, xxxxxxxx wrote:

          Another solution could be to use CoreMessage.
          https://developers.maxon.net/forum/topic/6808/7564_how-to-identify-different-calls-to-coremessage

          So it's the time for asking what the difference beetwen Message and Core Message?
          As I understand Message are only send to one object using node.Message()
          While CoreMessage are propagate throught all nodes

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

            On 27/09/2017 at 02:13, xxxxxxxx wrote:

            Hello,

            core messages do NOT propagate through all nodes. Please read the Core Messages Manual carefully.

            best wishes,
            Sebastian

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

              On 27/09/2017 at 02:59, xxxxxxxx wrote:

              Thanks for correct me, was not sure about that!

              So what's the difference beetween both? (I speak in term of implementation)

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

                On 27/09/2017 at 03:13, xxxxxxxx wrote:

                "BTW why are you using  FindPlugin()? This is   **not  **used to access an instance of an ObjectData plugin in a document."

                I need to send a message to the plugin. So I need the plugin object and FindPlugin() gives me the object (I thought).

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

                  On 27/09/2017 at 03:45, xxxxxxxx wrote:

                  An ObjectData return an object, so basicly you do

                  obj = doc.GetFirstObject()
                  if not obj.CheckType(YOUR_PLUGIN_ID) : return
                    
                  bc = c4d.BaseContainer()
                  bc.SetInt32(0, 100)
                  bc.SetInt32(1, 200)
                  obj.Message(c4d.MSG_BASECONTAINER, bc)
                  

                  FindPlugin only give you a BasePlugin which is not an instance of your ObjectData object

                  c4d.plugins.BasePlugin :
                  Represents a registered Cinema 4D plugin. Cannot be instantiated.

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

                    On 27/09/2017 at 05:32, xxxxxxxx wrote:

                    Ok, clear.
                    Thanks, Pim

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