I am creating a script that creates node in the node editor. I need to accept some properties from the user after creating the node. So I wrote a draw method.

But looks like operator.draw is not being called when the context is the node editor. I have put a print statement inside draw(self, context) to verify this. If I change the space type to 'VIEW_3D', the draw method is called.

Is the operator draw method only available in 3d view?

Edited with example:

In example below the message "inside op draw" is called on click of panel in 3d view not in node view:

import bpy

bl_info = {
    'name': 'test node editor op',
    'category': 'Object',
    'blender': (2, 80, 0),

class my_op(bpy.types.Operator):
    bl_idname = 'object.test_op'
    bl_label = 'test node op'
    bl_options = {'REGISTER', 'UNDO'}

    x : bpy.props.FloatProperty(name='X')
    y : bpy.props.FloatProperty(name='Y')

    def execute(self, context):
        if(context.area.type == 'VIEW_3D'):
            bpy.ops.mesh.primitive_cube_add(enter_editmode=False, align='WORLD', location=(0, 0, 0), scale=(1, 1, 1))
                if(bpy.context.active_object.active_material == None):
                    m=bpy.data.materials.new('my material')
                bpy.context.active_object.active_material.use_nodes = True
                n = bpy.context.active_object.active_material.node_tree.nodes.new('ShaderNodeValue')
                n.location = (self.x, self.y)
        return {'FINISHED'}

    def draw(self, context):
        print('inside op draw')
        col = self.layout.column()
        col.prop(self, 'x')
        col.prop(self, 'y')
class simple_3dview_panel(bpy.types.Panel):
    bl_label = 'simple 3d'
    bl_idname = 'simple_3d_panel'

    bl_space_type = 'VIEW_3D'

    bl_region_type = 'UI'
    bl_category = 'My View 3D Panel'

    def draw(self, context):
        col = self.layout.column()

class simple_node_panel(bpy.types.Panel):
    bl_label = 'simple node'
    bl_idname = 'simple_node_panel'

    bl_space_type = 'NODE_EDITOR'

    bl_region_type = 'UI'
    bl_category = 'My Node Panel'

    def draw(self, context):
        col = self.layout.column()

def register():

def unregister():

if(__name__ == '__main__'):
  • $\begingroup$ What do you'd like to draw? A pop-up to dial in values? Draw is an operator method and should work on all editors. Also, you only can set the space type for panels. Any sketch or a minimal code example would help. $\endgroup$
    – brockmann
    Oct 23, 2020 at 8:54
  • $\begingroup$ @brockmann I want to shift the node based on the location property from draw method. Updated the post with example. $\endgroup$
    – blunder
    Oct 24, 2020 at 8:32
  • $\begingroup$ Still unclear what you'd like to do. Can you please elaborate a bit on "shift the nodes based on loc"? Do you'd like to allow the user to do that for only one or multiple nodes? Also your class names are not valid and most importantly col is not defined so the call and thus the script won't work anyway... Further reading: What do operator methods do? (poll, invoke, execute, draw & modal) $\endgroup$
    – brockmann
    Oct 24, 2020 at 13:02
  • $\begingroup$ @brockmann added a working code now. pls check. $\endgroup$
    – blunder
    Oct 25, 2020 at 17:58
  • $\begingroup$ Get it. Confusion comes from the idea of the so called 'Redo Panel' in 3d View (F6). No other area (Outliner, Node Editor etc.) supports the redo panel so you have to declare an 'invoke' method to call a popup or just display the properties in the panel. Corrected your code: pastebin.pl/view/b3340134 Notice that you already have a context reference passed by each method (def draw(self, context):) so I replaced bpy.context.* by context.* in your entire script. Also, as mentioned there are conventions for class names eg. _PT_, otherwise you'll get a warning in the console. $\endgroup$
    – brockmann
    Oct 26, 2020 at 10:40

1 Answer 1


Yes, you are right. The operator draw method is only available in 3d view and not in node editor.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .