[Bf-python] Python nodes API having issues with inheritance

Paul Kilgo paulkilgo at gmail.com
Mon May 20 19:52:46 CEST 2013


Hello

I am using the new Python API for node editor extensions to hopefully add a
my own volume renderer to Blender.

I'm struggling with finding a convenient way to add NodeSockets to a lot of
different nodes. I eventually settled with an inheritance hierarchy that
looks like this:

bpy.types.Node -> VolumeNode -> ScalarFieldNode -> SphereNode

I was defining a method ScalarFieldNode.init(self, context) to add some
sockets which will be common for scalar fields. However, it seems like
whenever I inherit from one of my nodes, the base class's init() method
does not carry over to the child class.

I poked around in bpy_types.py and found this perhaps relevant block of
code (in __new__ of RNAMetaNode):

  init_base = classdict.get('init', None)
  if init_base:
      def init_node(self, context):
          create_sockets(self)
          init_base(self, context)
  else:
      def init_node(self, context):
          create_sockets(self)
  classdict['init'] = init_node

So I see that maybe I should be using input_templates and output_templates
to do what I am trying to do. I don't know Python that well so I don't know
if this is somehow breaking inheritance in the way I am trying to use it
(or even if I should use it) but I thought I would bring this to attention.

I've attached a simplified version of my script if it helps.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20130520/466f232c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: basic_example.py
Type: application/octet-stream
Size: 734 bytes
Desc: not available
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20130520/466f232c/attachment.obj>


More information about the Bf-python mailing list