diff --git a/__init__.py b/__init__.py index 43e02a6..30affd8 100644 --- a/__init__.py +++ b/__init__.py @@ -1652,15 +1652,12 @@ def on_depsgraph_update(scene, depsgraph): lock_depsgraph_updates() def later(): - if ( - "lock_depsgraph_update_ntimes" not in scene.abc3d_data - or scene.abc3d_data["lock_depsgraph_update_ntimes"] <= 0 - ): + if butils.lock_depsgraph_update_n_times <= 0: butils.set_text_on_curve( scene.abc3d_data.available_texts[linked_textobject] ) - elif scene.abc3d_data["lock_depsgraph_update_ntimes"] > 0: - scene.abc3d_data["lock_depsgraph_update_ntimes"] -= 1 + elif butils.lock_depsgraph_update_n_times <= 0: + butils.lock_depsgraph_update_n_times -= 1 butils.run_in_main_thread(later) diff --git a/butils.py b/butils.py index d3b6940..aeb8cfe 100644 --- a/butils.py +++ b/butils.py @@ -21,6 +21,7 @@ else: from .common import utils execution_queue = queue.Queue() +lock_depsgraph_update_n_times = -1 # This function can safely be called in another thread. @@ -811,6 +812,8 @@ def set_text_on_curve(text_properties, reset_timeout_s=0.1, reset_depsgraph_n=4) :type reset_depsgraph_n: int """ + global lock_depsgraph_update_n_times + # starttime = time.perf_counter_ns() mom = text_properties.text_object if mom.type != "CURVE": @@ -1040,12 +1043,12 @@ def set_text_on_curve(text_properties, reset_timeout_s=0.1, reset_depsgraph_n=4) mom[f"{utils.prefix()}_orientation"] = text_properties.orientation mom[f"{utils.prefix()}_translation"] = text_properties.translation - if "lock_depsgraph_update_ntimes" in bpy.context.scene.abc3d_data: - bpy.context.scene.abc3d_data["lock_depsgraph_update_ntimes"] += len( + if lock_depsgraph_update_n_times < 0: + lock_depsgraph_update_n_times = len( bpy.context.selected_objects ) else: - bpy.context.scene.abc3d_data["lock_depsgraph_update_ntimes"] = len( + lock_depsgraph_update_n_times += len( bpy.context.selected_objects )