update types automatically

This commit is contained in:
themancalledjakob 2024-10-31 19:33:49 +01:00
parent e5e8a1b053
commit b6d76ae958
2 changed files with 21 additions and 0 deletions

View file

@ -1504,6 +1504,7 @@ def register():
butils.run_in_main_thread(butils.clear_available_fonts) butils.run_in_main_thread(butils.clear_available_fonts)
# butils.run_in_main_thread(butils.load_installed_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_available_fonts)
butils.run_in_main_thread(butils.update_types)
# bpy.ops.abc3d.load_installed_fonts() # bpy.ops.abc3d.load_installed_fonts()

View file

@ -605,9 +605,21 @@ def is_mesh(o):
return type(o.data) == bpy.types.Mesh return type(o.data) == bpy.types.Mesh
def is_metrics_object(o): 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) 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): def is_glyph(o):
if f"{utils.prefix()}_type" in o:
return o[f"{utils.prefix()}_type"] == 'glyph'
try: try:
return type(o.parent) is not type(None) \ return type(o.parent) is not type(None) \
and "glyphs" in o.parent.name \ and "glyphs" in o.parent.name \
@ -616,6 +628,14 @@ def is_glyph(o):
except ReferenceError as e: except ReferenceError as e:
return False 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 # blender bound_box vertices
# #
# 3------7. # 3------7.