I am trying to run one of Blenders modal operators from within an addon / self written operator. Is it possible to do this in a way so the user will be able to benefit from the modal style of that operator? Example: Within my own operator I would like the user to add an on the fly python defined node group in the node editor. When you do this the standard way (Shift A + click on a node) Blender attaches the node to the mouse cursor and allows to drop it in a specific location which the user can decide by moving the mouse and then clicking. Can I call the operator bpy.ops.node.add_node() from Python in a way that it will add a custom node group I created, but remain in the modal function until the user clicks? Is this possible at all?


1 Answer 1


Adding a node and moving a node are two different actions. You will find that the two operators invoked when adding a node are bpy.ops.node.add_node() and bpy.ops.node.translate_attach_remove_on_cancel()

Using an example from a small addon I wrote a while ago -

def execute(self, context):
    if context.active_object.type == 'ARMATURE' \
            and context.active_object.mode == 'EDIT':
        for b in context.selected_bones:
            b.parent = None
    return bpy.ops.transform.translate('INVOKE_DEFAULT')

you can see that the object gets duplicated, with a different operator used for armatures that are being edited, then the parent info gets cleared and the translate operator is called at the end.

  • 1
    $\begingroup$ thanks man, your answer made it clear. The fact that it is two different operators was known, but the bit that makes it work the way I wanted is the ('INVOKE_DEFAULT') part. $\endgroup$
    – aliasguru
    Commented Mar 24, 2016 at 9:54

You must log in to answer this question.

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