Communicating data between two plugins
-
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? -
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..
-
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 -
On 14/04/2015 at 08:11, xxxxxxxx wrote:
Hi Niklas,
How would yo use your function get_api()?
-
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 -
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?
-
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
-
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