NodeTree(ID)

Poll Function

The NodeTree.poll function determines if a node tree is visible in the given context (similar to how Panel.poll and Menu.poll define visibility). If it returns False, the node tree type will not be selectable in the node editor.

A typical condition for shader nodes would be to check the active render engine of the scene and only show nodes of the renderer they are designed for.

import bpy


class CyclesNodeTree(bpy.types.NodeTree):
    """ This operator is only visible when Cycles is the selected render engine"""
    bl_label = "Cycles Node Tree"
    bl_icon = 'NONE'

    @classmethod
    def poll(cls, context):
        return context.scene.render.engine == 'CYCLES'


bpy.utils.register_class(CyclesNodeTree)

base classes — bpy_struct, ID

subclasses — CompositorNodeTree, GeometryNodeTree, ShaderNodeTree, TextureNodeTree

class bpy.types.NodeTree(ID)

Node tree consisting of linked nodes used for shading, textures and compositing

animation_data

Animation data for this data-block

Type:

AnimData, (readonly)

bl_description
Type:

string, default “”, (never None)

bl_icon

The node tree icon

Type:

enum in Icon Items, default ‘NODETREE’

bl_idname
Type:

string, default “”, (never None)

bl_label

The node tree label

Type:

string, default “”, (never None)

bl_use_group_interface

Determines the visibility of some UI elements related to node groups

Type:

boolean, default True

color_tag

Color tag of the node group which influences the header color

  • NONE None – Default color tag for new nodes and node groups.

  • ATTRIBUTE Attribute.

  • COLOR Color.

  • CONVERTER Converter.

  • DISTORT Distort.

  • FILTER Filter.

  • GEOMETRY Geometry.

  • INPUT Input.

  • MATTE Matte.

  • OUTPUT Output.

  • SCRIPT Script.

  • SHADER Shader.

  • TEXTURE Texture.

  • VECTOR Vector.

  • PATTERN Pattern.

  • INTERFACE Interface.

  • GROUP Group.

Type:

enum in [‘NONE’, ‘ATTRIBUTE’, ‘COLOR’, ‘CONVERTER’, ‘DISTORT’, ‘FILTER’, ‘GEOMETRY’, ‘INPUT’, ‘MATTE’, ‘OUTPUT’, ‘SCRIPT’, ‘SHADER’, ‘TEXTURE’, ‘VECTOR’, ‘PATTERN’, ‘INTERFACE’, ‘GROUP’], default ‘NONE’

default_group_node_width

The width for newly created group nodes

Type:

int in [40, 700], default 140

description

Description of the node tree

Type:

string, default “”, (never None)

grease_pencil

Grease Pencil data-block

Type:

GreasePencil

interface

Interface declaration for this node tree

Type:

NodeTreeInterface, (readonly)

Type:

NodeLinks bpy_prop_collection of NodeLink, (readonly)

nodes
Type:

Nodes bpy_prop_collection of Node, (readonly)

type

Node Tree type (deprecated, bl_idname is the actual node tree type identifier)

  • UNDEFINED Undefined – Undefined type of nodes (can happen e.g. when a linked node tree goes missing).

  • CUSTOM Custom – Custom nodes.

  • SHADER Shader – Shader nodes.

  • TEXTURE Texture – Texture nodes.

  • COMPOSITING Compositing – Compositing nodes.

  • GEOMETRY Geometry – Geometry nodes.

Type:

enum in [‘UNDEFINED’, ‘CUSTOM’, ‘SHADER’, ‘TEXTURE’, ‘COMPOSITING’, ‘GEOMETRY’], default ‘SHADER’, (readonly)

view_center

The current location (offset) of the view for this Node Tree

Type:

mathutils.Vector of 2 items in [-inf, inf], default (0.0, 0.0), (readonly)

interface_update(context)

Updated node group interface

contains_tree(sub_tree)

Check if the node tree contains another. Used to avoid creating recursive node groups.

Parameters:

sub_tree (NodeTree, (never None)) – Node Tree, Node tree for recursive check

Returns:

contained

Return type:

boolean

classmethod poll(context)

Check visibility in the editor

Return type:

boolean

update()

Update on editor changes

classmethod get_from_context(context)

Get a node tree from the context

Return (result_1, result_2, result_3):

result_1, Active node tree from context, NodeTree

result_2, ID data-block that owns the node tree, ID

result_3, Original ID data-block selected from the context, ID

classmethod valid_socket_type(idname)

Check if the socket type is valid for the node tree

Parameters:

idname (string, (never None)) – Socket Type, Identifier of the socket type

Return type:

boolean

debug_lazy_function_graph()

Get the internal lazy-function graph for this node tree

Returns:

Dot Graph, Graph in dot format

Return type:

string

classmethod bl_rna_get_subclass(id, default=None)
Parameters:

id (str) – The RNA type identifier.

Returns:

The RNA type or default when not found.

Return type:

bpy.types.Struct subclass

classmethod bl_rna_get_subclass_py(id, default=None)
Parameters:

id (str) – The RNA type identifier.

Returns:

The class or default when not found.

Return type:

type

Inherited Properties

Inherited Functions

References