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

active_input

Index of the active input

Type

int in [0, inf], default 0

active_output

Index of the active output

Type

int in [0, inf], default 0

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)

grease_pencil

Grease Pencil data-block

Type

GreasePencil

inputs

Node tree inputs

Type

NodeTreeInputs bpy_prop_collection of NodeSocketInterface, (readonly)

Type

NodeLinks bpy_prop_collection of NodeLink, (readonly)

nodes
Type

Nodes bpy_prop_collection of Node, (readonly)

outputs

Node tree outputs

Type

NodeTreeOutputs bpy_prop_collection of NodeSocketInterface, (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).

  • SHADER Shader – Shader nodes.

  • TEXTURE Texture – Texture nodes.

  • COMPOSITING Compositing – Compositing nodes.

  • GEOMETRY Geometry – Geometry nodes.

Type

enum in [‘UNDEFINED’, ‘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

classmethod bl_rna_get_subclass(id, default=None)
Parameters

id (string) – 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 (string) – The RNA type identifier.

Returns

The class or default when not found.

Return type

type

Inherited Properties

Inherited Functions

References