From b6d76ae958c4ed670f836d872bd697547f4bae59 Mon Sep 17 00:00:00 2001 From: themancalledjakob Date: Thu, 31 Oct 2024 19:33:49 +0100 Subject: [PATCH] update types automatically --- __init__.py | 1 + butils.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/__init__.py b/__init__.py index 614142f..e10855d 100644 --- a/__init__.py +++ b/__init__.py @@ -1504,6 +1504,7 @@ def register(): butils.run_in_main_thread(butils.clear_available_fonts) # butils.run_in_main_thread(butils.load_installed_fonts) butils.run_in_main_thread(butils.update_available_fonts) + butils.run_in_main_thread(butils.update_types) # bpy.ops.abc3d.load_installed_fonts() diff --git a/butils.py b/butils.py index 50d285d..af7617d 100644 --- a/butils.py +++ b/butils.py @@ -605,9 +605,21 @@ def is_mesh(o): return type(o.data) == bpy.types.Mesh def is_metrics_object(o): + if f"{utils.prefix()}_type" in o: + return o[f"{utils.prefix()}_type"] == 'metrics' return (re.match(".*_metrics$", o.name) != None or re.match(".*_metrics.[\d]{3}$", o.name) != None) and is_mesh(o) +def is_text_object(o): + if f"{utils.prefix()}_type" in o: + return o[f"{utils.prefix()}_type"] == 'textobject' + for t in bpy.context.scene.abc3d_data.available_texts: + if o == t.text_object: + return True + return False + def is_glyph(o): + if f"{utils.prefix()}_type" in o: + return o[f"{utils.prefix()}_type"] == 'glyph' try: return type(o.parent) is not type(None) \ and "glyphs" in o.parent.name \ @@ -616,6 +628,14 @@ def is_glyph(o): except ReferenceError as e: return False +def update_types(): + scene = bpy.context.scene + abc3d_data = scene.abc3d_data + for t in abc3d_data.available_texts: + t.text_object[f"{utils.prefix()}_type"] = "textobject" + for g in t.glyphs: + g.glyph_object[f"{utils.prefix()}_type"] = "glyph" + # blender bound_box vertices # # 3------7.