Create new node type with Python

Hi Guys,
I’ve searched everywhere on the Internet without finding what I’m looking for.

Let’s say I want to create a new node type using Python; for example an image filter with an input yellow (image) socket and an output yellow (image) socket.
The filter processes the image in some ways and returns an other imag, for example like the blur node, but with a new function that doesn’t exist in any blender node.

I would like to learn how to create new node types but I don’t find any good guide/tutorial on it.

I’ve found this: http://wiki.blender.org/index.php/User:Phonybone/Python_Nodes#Basic_API_functions
I tried to register new node types, node tree types and node socket types with the code on the wiki;

class MyCustomNode(bpy.types.Node):
    # Description string
    '''A custom node'''
    # Optional identifier string. If not explicitly defined, the python class name is used.
    bl_idname = 'CustomNodeType'
    # Label for nice name display
    bl_label = 'Custom Node'
    # Icon identifier
    bl_icon = 'SOUND' class MyCustomSocket(bpy.types.NodeSocket):
    # Description string
    '''Custom node socket type'''
    # Optional identifier string. If not explicitly defined, the python class name is used.
    bl_idname = 'CustomSocketType'
    # Label for nice name display
    bl_label = 'Custom Node Socket'
    # Socket color
    bl_color = (1.0, 0.4, 0.216, 0.5)

 class MyCustomTree(bpy.types.NodeTree):
    # Description string
    '''A custom node tree type that will show up in the node editor header'''
    # Optional identifier string. If not explicitly defined, the python class name is used.
    bl_idname = 'CustomTreeType'
    # Label for nice name display
    bl_label = 'Custom Node Tree'
    # Icon identifier
    # Note: If no icon is defined, the node tree will not show up in the editor header!
    #       This can be used to make additional tree types for groups and similar nodes
    bl_icon = 'NODETREE'



I use python but in this case I’m afraid not to understand the way it works.
I try adding new types but nothing happens and I cannot find any new types in the add menu.
Is there somewhere a good tutorial/guide on how to define a new node type with its sockets (inputs and outputs), buttons, text fields number fields and functions that process the inputs and return the outputs?
Thanks in advance.

P. S.: I’m not English mothertongue. I hope my post is not too bad.

The python nodes interface is pure ui. It is then compiled and executed inside of blender with function defined in C/C++ etc. A python image filter in the compositor is not possible.

You can define your own node tree type and do the image processing there but is some work to do, basically think of the node editor as text editor and you need to implement the compiler and execution engine.
Take a look at animation nodes for a example.

Mmh…
But shader nodes (for example) can be made in Python.
Then what’s the purpose of the code I quoted?
Thanks! :slight_smile:

Shader (cycles) nodes can be made osl, in python you can create some extra ui elements that might, perhaps, interact correctly.

Consider if you want to write and exporter for another rendering engine like lux render (or something) then you can specify your materials in a node system that you create yourself for your specific needs. That is the purpose of the pynodes interface.

Ok!
Thank you very much!

Someone has done it and has a windows release. It is branched off from version 2.79. The binary release works.:

However I’m learning to apply the patch .diff file to the source code to understand how it works in case I want to build my own future Blender release. I couldn’t get it to build.