[fix] deletion fixes+

and some smaller cosmetic changes
This commit is contained in:
jrkb 2025-05-31 17:47:47 +02:00
parent 8470425d20
commit d61607c75d
2 changed files with 45 additions and 11 deletions

View file

@ -647,6 +647,17 @@ def is_glyph_used(glyph_alternates):
return False
def clean_text_properties():
abc3d_data = bpy.context.scene.abc3d_data
remove_these = []
for i, text_properties in enumerate(abc3d_data.available_texts):
if len(text_properties.text_object.users_collection) <= 0:
remove_these.append(i)
remove_these.reverse()
for i in remove_these:
abc3d_data.available_texts.remove(i)
def clean_fontcollection(fontcollection=None):
if fontcollection is None:
fontcollection = bpy.data.collections.get("ABC3D")
@ -1336,6 +1347,21 @@ def test_finding():
transfer_text_object_to_text_properties(o, t)
def is_text_object_legit(text_object):
must_have_keys = [
get_key("font_name"),
get_key("face_name"),
get_key("text"),
get_key("type"),
]
for key in must_have_keys:
if key not in text_object:
return False
if text_object[get_key("type")] != "textobject":
return False
return True
# def detect_texts():
# scene = bpy.context.scene
# abc3d_data = scene.abc3d_data
@ -1478,6 +1504,8 @@ def set_text_on_curve(
mom = text_properties.text_object
if mom.type != "CURVE":
return False
if len(mom.users_collection) < 1:
return False
distribution_type = "CALCULATE" if is_bezier(mom) else "FOLLOW_PATH"
@ -2042,8 +2070,6 @@ def add_default_metrics_to_objects(objects=None, overwrite_existing=False):
targets = []
reference_bound_box = None
for o in objects:
if not hasattr(o, "parent"):
print(f"{o.name} has not a PARENTNTNTNTNTNNTNTNTNTNTN")
is_possibly_glyph = is_glyph(o)
if is_possibly_glyph:
metrics = []