On 23/03/2016 at 12:02, xxxxxxxx wrote:
I'm interested in finding out if there is an existing method of what I'm trying to do. - Maybe I'm googling the wrong terms or maybe what I'm looking for is impractical and that's why I can't find it.
I'm trying to be able to send/pass byte arrays (or sets of data in general) from one plugin to another. I have two contexts where I'd like to achieve this:
1. Using one object (objectData) as a data cache for another.
2. To pass the data to a scene independent object which sends the data sets directly by UDP to the outside world.
I have clunky ways of doing both of these but some things make performance unbearable such as saving the data sets into bazillions of sub BaseContainers etc. I could also write to external files and read them back but I feel that this is a bit messy too.
The PyCObject looks vaguely like it might be what I'm looking for but not really sure.
Any help would be greatly appreciated.
On 24/03/2016 at 06:07, xxxxxxxx wrote:
actually you have a bunch of options, all varying in complexity and use-case (plugin type,...).
A very basic (if not the most basic) option to exchange data between plugins is GePluginMessage() and PluginMessage().
Then you can post special events via SpecialEventAdd(), which results in a CoreMessage(), most useful in conjunction with dialogs or your own MessageData plugin.
Or you could use Message() to send a special message to your other object, for example a MSG_BASECONTAINER.
These are the most common means for data exchange between plugins in Cinema 4D.
On the other hand you are pretty vague about your individual case(s).
The first one I probably do not understand. You will need to describe it in a bit more detail.
The second one sounds like you actually want something completely different. For example there's nothing to say against global variables, if used correctly. You could have a global queue, where you enter the data, that needs to be transferred via UDP. And then a thread consumes this data from the queue and transfers it via UDP. Just make sure your queue handling is thread safe.
But again, it's hard to tell, without knowing the details.
Providing plugin type and where (plugin function, like GetVirtualObjects()) can really help a lot in answering questions. Code snippets might help as well.
On 24/03/2016 at 06:16, xxxxxxxx wrote:
I haven't seem MSG_BASECONTAINER yet, thanks for pointing it out here Andreas! This looks like
a very good way to communicate between a C++ and Python plugin.
@Adam if your plugins are all Python, you can actually use Message() (with a new unique message ID)
and pass any Python object, and it will be received as a Python object on the other end.
On 24/03/2016 at 07:26, xxxxxxxx wrote:
@Andreas Thanks for that! And yes I was a bit vague about my cases here. - I'm going to be choosing my plugin types based on the learnings from this conversation. I'll look into all of the above methods you've mentioned and I'll come back when I've figured out a few more details. The global queue sounds particularly interesting.
@Niklas That sounds great! For now I'm keeping everything in python so I can keep the development fast and fluid.
Passing any python object sounds perfect for what I'd like to do. Couple of Qs:
Which Message() function in the documentation should I be looking at? (There are a few variations)
How do I set a unique message ID? (Do I just define a header at the top of each plugin or something?)
On 25/03/2016 at 04:39, xxxxxxxx wrote:
Forget the questions from my last post. I was expecting the Message() implementation to be way more complicated than it actually was. Happily throwing data between plugins now