[Bf-python] Python API refactoring wiki
Joe Eagar
joeedh at gmail.com
Fri Jan 27 23:02:36 CET 2006
Campbell Barton wrote:
>> Hey JoeHeed,
What is with "JoeHeed" anyway? That's the second time someone's done that.
Maybe I'll use a different nick, like HeedJoe, or JoeIsYourGod, or
JoeHeeds[put disliked politician here] Will and So Should You. Or maybe
ObeyJoeAndYouWillBeSpared.
To add a point to this pointless email, is anyone planning on adding
support for python-defined node editors? My idea was to use a
Draw.Register system, where you register callbacks for a variety of nodes.
You could add node types to existing node editors, but what I think
would be the most useful would be adding support for python-defined node
*editors*.
This would allow making, say, logic editors for different external game
engines, or shader editors for renderman shaders. A plant-growing
system would especially benefit from this (like in Maya).
An example code using this approach might work as follows (note that the
string constants are more for clarity, they would be different can more
efficient in a real API):
from Blender import Node #import the node module
class Test (Blender.Node.NodeType): #inherit the node type class
ins = ["fVEC4", "fVALUE"] #input node points, f is for float.
outs = ["fVALUE"] #output node point
invals = [] #this is where the input node point *values* are
deposited on a run-time node.
outvals = [] #this is where the output node points *values* are put
on a run-time node.
val = 0 #this is a specific variable to run-time instances of Test.
def gui(self): #this is for drawing UI stuff, possibly using the
Draw module.
pass
#this function processes button events
def event(self, evt, val):
pass
#this function executes the node.
def exec(self):
self.outvals[0] = self.invals[0][0] + self.invals[0][1] +
self.inval[0][2] + self.inval[1]
#this is for saving node-specific data
def save(self):
return str(val)
Type = Test()
Node.NewEditor("Test")
Node.Register(Type, "OBJECT") #have options to attach node to objects,
library blocks of all types, or the global scene.
. . .then when you go to the node editor, theres a new editor (in
addition to the compositor and material nodes) called "Test." You'd
then add nodes by pressing shift-A like normal.
joeedh
More information about the Bf-python
mailing list