Custom NodeTree init

MotionTools uses a Begin node which captures the current frame with modifiers and passes it along. You are not limited to the number of Begin nodes.
In blender or cycles materials, compositor you are not allowed more than 1 final output node!
I’m looking to instantiate a CustomNodeTree where there would only be one final output created and no other output could be created unless that output was first deleted, I guess I’m talking about a Singleton class linked with the selected Object.

I would conclude that this would be blender independent and primarily a coding issue, having never used a Singleton class, I find it confusing, any enlightenment would be greatly appreciated, Thanks!

Did you try using

poll_instance

?

The following would prevent a second node from the same being added I imagine.




def poll_instance(self, node_tree):
    if any(n.bl_idname == self.bl_idname for n in node_tree.nodes):
        return False
    return True

Okay doesn’t seem to work…

http://www.blender.org/documentation/blender_python_api_2_71_release/bpy.types.Node.html?highlight=poll_instance#bpy.types.Node.poll_instance

Okay doesn’t seem to work…

Try poll() then:


    @classmethod
    def poll(cls, ntree):
        if any(n.bl_idname == cls.bl_idname for n in ntree.nodes):
            return None
        return True