Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > PYTHON Development
  New Posts New Posts
  FAQ FAQ  Forum Search

Sending a message to an objectdata plugin

Author
Message Reverse Sort Order
  Topic Search Topic Search
pgrooff View Drop Down
Member
Member


Joined: 2010 Nov 05
Online Status: Offline
Posts: 817
Direct Link To This Post Topic: Sending a message to an objectdata plugin
    Posted: 2017 Sep 27 at 5:32am
Ok, clear.
Thanks, Pim
Back to Top
gr4ph0s View Drop Down
Member
Member


Joined: 2015 Jul 07
Location: France
Online Status: Offline
Posts: 437
Direct Link To This Post Posted: 2017 Sep 27 at 3:45am
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.


Edited by gr4ph0s - 2017 Sep 27 at 3:46am
Technical lover.
Back to Top
pgrooff View Drop Down
Member
Member


Joined: 2010 Nov 05
Online Status: Offline
Posts: 817
Direct Link To This Post Posted: 2017 Sep 27 at 3:13am
"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).
Back to Top
gr4ph0s View Drop Down
Member
Member


Joined: 2015 Jul 07
Location: France
Online Status: Offline
Posts: 437
Direct Link To This Post Posted: 2017 Sep 27 at 2:59am
Thanks for correct me, was not sure about that! 

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

Edited by gr4ph0s - 2017 Sep 27 at 3:02am
Technical lover.
Back to Top
S_Bach View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2011 Jun 27
Online Status: Offline
Posts: 1379
Direct Link To This Post Posted: 2017 Sep 27 at 2:13am
Hello,

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

best wishes,
Sebastian
SDK Support Engineer
Back to Top
gr4ph0s View Drop Down
Member
Member


Joined: 2015 Jul 07
Location: France
Online Status: Offline
Posts: 437
Direct Link To This Post Posted: 2017 Sep 27 at 1:47am
Another solution could be to use CoreMessage.
http://www.plugincafe.com/forum/forum_posts.asp?TID=7564

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



Edited by gr4ph0s - 2017 Sep 27 at 1:48am
Technical lover.
Back to Top
S_Bach View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2011 Jun 27
Online Status: Offline
Posts: 1379
Direct Link To This Post Posted: 2017 Sep 27 at 1:19am
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
SDK Support Engineer
Back to Top
pgrooff View Drop Down
Member
Member


Joined: 2010 Nov 05
Online Status: Offline
Posts: 817
Direct Link To This Post Posted: 2017 Sep 26 at 3:08pm
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

Back to Top

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.109 seconds.