On 16/03/2013 at 02:46, xxxxxxxx wrote:
It doesn't work with Python unfortunately. We do not have access to the NodeData of a plugin in
Python, or better say we can not get the NodeData from a BaseList2D object! It would be possible
with a bit of hacking, but it's not very "beautiful".
You could exchange information via a Python module or a c4dtools.library.Library class. I do
not recommend the first one. An example for the c4dtools Library to be put in your Python plugin
file:
#
# Python Plugin File
#
import c4d
import weakref
import c4dtools
class PluginTag(c4d.plugins.TagData) :
op = None
instances = []
def Init(self, op) :
self.instances.append(weakref.ref(self))
self.list_ = []
self.op = op
return True
def Free(self) :
try:
self.instances.remove(weakref.ref(self))
except ValueError:
pass
# ...
class MyLibrary(c4dtools.library.Library) :
class Meta:
# Global unique identifier!
name = 'my-super-duper-cool-library'
def get_plugin_tags(self) :
return PluginTag.instances[:]
#
# Python Tag (or just somewhere else than the plugin file)
#
import c4dtools
lib = c4dtools.load_library('my-super-duper-cool-library')
for data in lib.get_plugin_tags() :
data = data() # dereference the weakref
if not data:
continue
print data.list_
Note that this only works when you place the c4dtools module somewhere the Python Interpreter
can always find it, and not as a local distributed dependency as described in this article.