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?
Adding a node and moving a node are two different actions. You will find that the two operators invoked when adding a node are
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': bpy.ops.armature.duplicate() for b in context.selected_bones: b.parent = None else: bpy.ops.object.duplicate() bpy.ops.object.parent_clear(type='CLEAR') 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.