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 (readonly)

Type:

AnimData

annotation

Annotation data

Type:

Annotation

bl_description

(default “”, never None)

Type:

str

bl_icon

The node tree icon (default 'NODETREE')

Type:

Literal[Icon Items]

bl_idname

(default “”, never None)

Type:

str

bl_label

The node tree label (default “”, never None)

Type:

str

bl_use_group_interface

Determines the visibility of some UI elements related to node groups (default True)

Type:

bool

color_tag

Color tag of the node group which influences the header color (default 'NONE')

  • 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:

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

default_group_node_width

The width for newly created group nodes (in [60, 700], default 140)

Type:

int

description

Description of the node tree (default “”, never None)

Type:

str

interface

Interface declaration for this node tree (readonly)

Type:

NodeTreeInterface

(default None, readonly)

Type:

NodeLinks[NodeLink]

nodes

(default None, readonly)

Type:

Nodes[Node]

type

Node Tree type (deprecated, bl_idname is the actual node tree type identifier) (default 'SHADER', readonly)

  • 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:

Literal[‘UNDEFINED’, ‘CUSTOM’, ‘SHADER’, ‘TEXTURE’, ‘COMPOSITING’, ‘GEOMETRY’]

view_center

The current location (offset) of the view for this Node Tree (array of 2 items, in [-inf, inf], default (0.0, 0.0), readonly)

Type:

mathutils.Vector

interface_update(context)

Updated node group interface

Parameters:

context (Context) – (never None)

contains_tree(sub_tree)

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

Parameters:

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

Returns:

contained

Return type:

bool

classmethod poll(context)

Check visibility in the editor

Parameters:

context (Context) – (never None)

Return type:

bool

update()

Update on editor changes

classmethod get_from_context(context)

Get a node tree from the context

Parameters:

context (Context) – (never None)

Returns:

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

Return type:

tuple[NodeTree, ID, ID]

classmethod valid_socket_type(idname)

Check if the socket type is valid for the node tree

Parameters:

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

Return type:

bool

debug_lazy_function_graph()

Get the internal lazy-function graph for this node tree

Returns:

Dot Graph, Graph in dot format

Return type:

str

classmethod bl_rna_get_subclass(id, default=None, /)
Parameters:
  • id (str) – The RNA type identifier.

  • default (bpy.types.Struct | None) – The value to return when not found.

Returns:

The RNA type or default when not found.

Return type:

bpy.types.Struct

classmethod bl_rna_get_subclass_py(id, default=None, /)
Parameters:
  • id (str) – The RNA type identifier.

  • default (type | None) – The value to return when not found.

Returns:

The class or default when not found.

Return type:

type

Inherited Properties

Inherited Functions

References