[Bf-blender-cvs] [7ef2b760dc2] master: Event Simulate: and a --keep-open command line argument

Campbell Barton noreply at git.blender.org
Sun Jun 6 15:08:42 CEST 2021


Commit: 7ef2b760dc233d61a2350e20d4e65cb76dbb9311
Author: Campbell Barton
Date:   Sun Jun 6 23:05:46 2021 +1000
Branches: master
https://developer.blender.org/rB7ef2b760dc233d61a2350e20d4e65cb76dbb9311

Event Simulate: and a --keep-open command line argument

It can be useful to investigate the state of the file
after event simulation runs.

===================================================================

M	tests/python/bl_run_operators_event_simulate.py

===================================================================

diff --git a/tests/python/bl_run_operators_event_simulate.py b/tests/python/bl_run_operators_event_simulate.py
index 251d27fce90..92315d3e853 100644
--- a/tests/python/bl_run_operators_event_simulate.py
+++ b/tests/python/bl_run_operators_event_simulate.py
@@ -175,7 +175,7 @@ def mouse_location_get():
     )
 
 
-def run_event_simulate(*, event_iter):
+def run_event_simulate(*, event_iter, exit_fn):
     """
     Pass events from event_iter into Blender.
     """
@@ -188,8 +188,7 @@ def run_event_simulate(*, event_iter):
         if val is Ellipsis:
             bpy.app.use_event_simulate = False
             print("Finished simulation")
-
-            sys.exit(0)
+            exit_fn()
             return None
 
         # Run event simulation.
@@ -494,6 +493,18 @@ def argparse_create():
         formatter_class=argparse.RawTextHelpFormatter,
     )
 
+    parser.add_argument(
+        "--keep-open",
+        dest="keep_open",
+        default=False,
+        action="store_true",
+        help=(
+            "Keep the window open instead of exiting once event simulation is complete.\n"
+            "This can be useful to inspect the state of the file once the simulation is complete."
+        ),
+        required=False,
+    )
+
     # Collect doc-strings from static methods in `actions`.
     actions_docstring = []
     for action_key in ACTION_DIR:
@@ -570,7 +581,16 @@ def main():
 
     setup_default_preferences(bpy.context.preferences)
 
-    run_event_simulate(event_iter=main_event_iter(action_list=args.actions))
+    def exit_fn():
+        if not args.keep_open:
+            sys.exit(0)
+        else:
+            bpy.app.use_event_simulate = False
+
+    run_event_simulate(
+        event_iter=main_event_iter(action_list=args.actions),
+        exit_fn=exit_fn,
+    )
 
 
 if __name__ == "__main__":



More information about the Bf-blender-cvs mailing list