<< January 13, 2020 | Home | January 15, 2020 >>

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"

    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

Export this post as PDF document  Export this post to PDF document

Social Bookmarks :  Add this post to Slashdot    Add this post to Digg    Add this post to Reddit    Add this post to Delicious    Add this post to Stumble it    Add this post to Google    Add this post to Technorati    Add this post to Bloglines    Add this post to Facebook    Add this post to Furl    Add this post to Windows Live    Add this post to Yahoo!
<< January 13, 2020 | Home | January 15, 2020 >>