bpy.types.Macro ignores next operator if the previous has .invoke #108736

Open
opened 2023-06-08 07:27:21 +02:00 by Andrej · 1 comment
Contributor

Blender 3.5.1

Short description of error

If I define a bpy.types.Macro that runs two operators and the first one has .invoke then the second one will never be executed.

Is there any workaround to this for now? What I was trying to accomplish is to make an operator that invokes another operator, wait until it's over and then execute it's code. Which didn't worked - operator's executed before invoked operator is finished. I tried to use Macro but run into another issue.

class TestOperator(bpy.types.Operator):
    bl_idname = "object.new_test_operator"
    bl_label = "Test Operator"
    bl_options = {"REGISTER", "UNDO"}

    def execute(self, context):
        bpy.ops.object.delay_operator('INVOKE_DEFAULT')
        print('after')
        return {'FINISHED'}

Exact steps for others to reproduce the error
Run the code below from Scripting in the default blender scene, then F3 - TestMacro

import bpy
import time

class DelayOperator(bpy.types.Operator):
    bl_idname = "object.delay_operator"
    bl_label = "Delay Operator"
    bl_options = {"REGISTER", "UNDO"}

    def invoke(self, context, event):
        context.window_manager.fileselect_add(self)
        return {"RUNNING_MODAL"}

    def execute(self, context):
        print('delay ops starts')
        time.sleep(1)
        print('delay ops middle')
        time.sleep(1)
        print('delay ops ends')
        return {'FINISHED'}

class TestOperator(bpy.types.Operator):
    bl_idname = "object.new_test_operator"
    bl_label = "Test Operator"
    bl_options = {"REGISTER", "UNDO"}

    def execute(self, context):
        print('-------------------> after')
        return {'FINISHED'}

class TestMacro(bpy.types.Macro):
    bl_idname = "bim.test_macro"
    bl_label = "TestMacro"
    bl_options = {"REGISTER", "UNDO"}

def register():
    bpy.utils.register_class(DelayOperator)
    bpy.utils.register_class(TestOperator)
    bpy.utils.register_class(TestMacro)
    TestMacro.define("OBJECT_OT_delay_operator")
    TestMacro.define("OBJECT_OT_new_test_operator")


def unregister():
    bpy.utils.unregister_class(TestOperator)
    bpy.utils.unregister_class(DelayOperator)
    bpy.utils.unregister_class(TestMacro)

if __name__ == "__main__":
    register()
Blender 3.5.1 **Short description of error** If I define a bpy.types.Macro that runs two operators and the first one has `.invoke` then the second one will never be executed. Is there any workaround to this for now? What I was trying to accomplish is to make an operator that invokes another operator, wait until it's over and then execute it's code. Which didn't worked - operator's executed before invoked operator is finished. I tried to use Macro but run into another issue. ```python class TestOperator(bpy.types.Operator): bl_idname = "object.new_test_operator" bl_label = "Test Operator" bl_options = {"REGISTER", "UNDO"} def execute(self, context): bpy.ops.object.delay_operator('INVOKE_DEFAULT') print('after') return {'FINISHED'} ``` **Exact steps for others to reproduce the error** Run the code below from Scripting in the default blender scene, then F3 - TestMacro ```python import bpy import time class DelayOperator(bpy.types.Operator): bl_idname = "object.delay_operator" bl_label = "Delay Operator" bl_options = {"REGISTER", "UNDO"} def invoke(self, context, event): context.window_manager.fileselect_add(self) return {"RUNNING_MODAL"} def execute(self, context): print('delay ops starts') time.sleep(1) print('delay ops middle') time.sleep(1) print('delay ops ends') return {'FINISHED'} class TestOperator(bpy.types.Operator): bl_idname = "object.new_test_operator" bl_label = "Test Operator" bl_options = {"REGISTER", "UNDO"} def execute(self, context): print('-------------------> after') return {'FINISHED'} class TestMacro(bpy.types.Macro): bl_idname = "bim.test_macro" bl_label = "TestMacro" bl_options = {"REGISTER", "UNDO"} def register(): bpy.utils.register_class(DelayOperator) bpy.utils.register_class(TestOperator) bpy.utils.register_class(TestMacro) TestMacro.define("OBJECT_OT_delay_operator") TestMacro.define("OBJECT_OT_new_test_operator") def unregister(): bpy.utils.unregister_class(TestOperator) bpy.utils.unregister_class(DelayOperator) bpy.utils.unregister_class(TestMacro) if __name__ == "__main__": register() ```
Andrej added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2023-06-08 07:27:21 +02:00
Member

Can confirm that the second one is never executed.

I believe in current bpy API you probably need to call the second operator directly in the exec of the first operator.

Can confirm that the second one is never executed. I believe in current bpy API you probably need to call the second operator directly in the `exec` of the first operator.
YimingWu added
Module
Python API
Status
Confirmed
and removed
Status
Needs Triage
labels 2023-06-08 09:51:44 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#108736
No description provided.