<< docker: get rid of images and containers | Home | GGJ '20 : Preparations >>

Blender-Addons: Get Nodetree of current node_editor panel

If you want to access data from the selected nodetree inside a node_editor panel:

class UrhoExportNodetreePanel(bpy.types.Panel):
    bl_space_type = 'NODE_EDITOR'
    bl_region_type = 'UI'
    bl_label = "Urho3d-Nodetree"
    bl_category = "Urho3D"

    @classmethod
    def poll(cls, context):
        return True

    def draw(self, context):
        if bpy.context.active_object:
            obj = bpy.context.active_object
            
            # nodetree type of space 
            # (use this to check for current type, as nodetrees can be None)
            space_treetype = context.space_data.tree_type 

            ctx_nodetree = context.space_data.node_tree # the nodetree-obj
            ctx_nodetree_name = ctx_nodetree.name       # name of the selected nodetree  
            ctx_nodetree_type = ctx_nodetree.bl_idname  # type of the nodetree



Home