Dev:Ref/Release Notes/2.67/Python Nodes
Python Nodes extend the API to enable scripters to use the node editor in Blender for custom node systems, without having to modify the C code and get changes accepted for trunk. So far the primary use of this API extension has been for external render engines which use node-based material definitions inside Blender. However, the node API is very generic and not limited to any particular use. What a specific node system is used for depends entirely on the implementation.
This page is just a small overview of the main features added for python nodes. For a more detailed example of a basic set of nodes see the custom_nodes.py template (right click to download the python module) .
The API for python nodes is still subject to changes and additions. The projects listed below should be considered work-in-progress. They are just intended as examples to show what pynodes are capable of.
A few projects have already begun using the pynodes API.
- LuxRender is a physically based render engine that can be hooked into Blender. The upcoming version 1.3 will have a node interface to define materials using the Blender node editor.
- A current snapshot of the LuxRender source can be found here
- Demo video:
|LuxRender 1.3 Node editor and new features demo by Jason Clarke|
Node types can be registered by python scripts from addons like other UI types such as operators or menus. The pynodes API is comprised of 3 new registrable types:
- The node tree is the main container for nodes. Each node tree type shows up as part of the type selection buttons in the editor header. Node trees of any type can be created in the Blender data collection (bpy.data).
- Each node in a tree has a specific type, which defines basic info such as the name and a number of functions for drawing, setting up data and reacting to updates.
- Sockets are connector types shared by all nodes in a tree. They can carry their own data and draw it in the node layout if necessary.
All 3 of the above types support custom properties, which allows them to define their own properties and store data in blend files.
Custom Property Limitations
Custom properties have a few limitations atm. In particular a few of the commonly used widgets such as color ramps and curves can not yet be created with nodes. Also linking to other data blocks requires a workaround using data path strings, which is not ideal. These shortcomings will certainly be resolved soon as the need for them is becoming obvious.
Nodes and sockets can draw buttons for their properties using the layout system. This works just like drawing in panels or menus and is very intuitive for any scripter who has worked with the Blender UI before.