diff --git a/__init__.py b/__init__.py index ff043fa..b696df8 100644 --- a/__init__.py +++ b/__init__.py @@ -372,7 +372,7 @@ class ABC3D_PT_TextManagement(bpy.types.Panel): continue remove_me = True for c in t.text_object.children: - if len(c.users_collection) > 0 and (c.get('linked_textobject')) != type(None) and c.get('linked_textobject') == t.text_id: + if len(c.users_collection) > 0 and (c.get(f"{utils.prefix()}_linked_textobject")) != type(None) and c.get(f"{utils.prefix()}_linked_textobject") == t.text_id: remove_me = False # not sure how to solve this reliably atm, # we need to reassign the glyph, but also get the proper properties from glyph_properties @@ -394,6 +394,14 @@ class ABC3D_PT_TextManagement(bpy.types.Panel): remove_list.append(i) for i in remove_list: + if type(abc3d_data.available_texts[i].text_object) != type(None): + del mom[f"{utils.prefix()}_linked_textobject"] + del mom[f"{utils.prefix()}_font_name"] + del mom[f"{utils.prefix()}_face_name"] + del mom[f"{utils.prefix()}_font_size"] + del mom[f"{utils.prefix()}_letter_spacing"] + del mom[f"{utils.prefix()}_orientation"] + del mom[f"{utils.prefix()}_translation"] abc3d_data.available_texts.remove(i) for i, t in enumerate(abc3d_data.available_texts): @@ -531,7 +539,13 @@ class ABC3D_OT_LoadInstalledFonts(bpy.types.Operator): scene = bpy.context.scene butils.load_installed_fonts() + butils.ShowMessageBox("Loading Fonts", + 'INFO', + "Updating Data Structures.") butils.update_available_fonts() + butils.ShowMessageBox("Loading Fonts", + 'INFO', + "Done loading installed fonts.") return {'FINISHED'} @@ -612,6 +626,20 @@ class ABC3D_OT_PlaceText(bpy.types.Operator): bl_label = "Place Text" bl_options = {'REGISTER', 'UNDO'} + # t.font_name = font_name + # t.face_name = face_name + # t.text_object = selected + # t.text = scene.abc3d.text + # t.letter_spacing = scene.abc3d.letter_spacing + # t.font_size = scene.abc3d.font_size + # t.translation = scene.abc3d.translation + # t.orientation = scene.abc3d.orientation + # t.distribution_type = distribution_type + + # def invoke(self, context, event): + # wm = context.window_manager + # return wm.invoke_props_dialog(self) + def execute(self, context): global shared scene = bpy.context.scene diff --git a/butils.py b/butils.py index d4d0476..945ca3a 100644 --- a/butils.py +++ b/butils.py @@ -407,7 +407,6 @@ def load_font_from_filepath(filepath): o_exists = True try: o, o.name - except ReferenceError as e: o_exists = False if o_exists and o.name not in allObjectsBefore: @@ -449,10 +448,13 @@ def load_font_from_filepath(filepath): # f.font_name = font_name # f.face_name = face_name # print(f"{__name__} added {font_name} {face_name}") - else: + elif o_exists: remove_list.append(o) for o in remove_list: - bpy.data.objects.remove(o, do_unlink=True) + try: + bpy.data.objects.remove(o, do_unlink=True) + except ReferenceError as e: + print(f"{__name__} could not remove object, because it doesn't exist") print(f"{__name__}: loaded font from {filepath}") update_available_fonts() @@ -600,8 +602,8 @@ def set_text_on_curve(text_properties): regenerate = True elif len(text_properties.text) > i and g.glyph_id != text_properties.text[i]: regenerate = True - elif len(text_properties.text) > i and (g.glyph_object['font_name'] != text_properties.font_name - or g.glyph_object['face_name'] != text_properties.face_name): + elif len(text_properties.text) > i and (g.glyph_object[f"{utils.prefix()}_font_name"] != text_properties.font_name + or g.glyph_object[f"{utils.prefix()}_face_name"] != text_properties.face_name): regenerate = True if len(text_properties.text) != len(text_properties.glyphs): @@ -660,9 +662,9 @@ def set_text_on_curve(text_properties): ob = None if regenerate: ob = bpy.data.objects.new(f"{glyph_id}", glyph.data) - ob['linked_textobject'] = text_properties.text_id - ob['font_name'] = text_properties.font_name - ob['face_name'] = text_properties.face_name + ob[f"{utils.prefix()}_linked_textobject"] = text_properties.text_id + ob[f"{utils.prefix()}_font_name"] = text_properties.font_name + ob[f"{utils.prefix()}_face_name"] = text_properties.face_name else: ob = text_properties.glyphs[i].glyph_object @@ -732,6 +734,13 @@ def set_text_on_curve(text_properties): if regenerate: mom.select_set(True) + mom[f"{utils.prefix()}_linked_textobject"] = text_properties.text_id + mom[f"{utils.prefix()}_font_name"] = text_properties.font_name + mom[f"{utils.prefix()}_face_name"] = text_properties.face_name + mom[f"{utils.prefix()}_font_size"] = text_properties.font_size + mom[f"{utils.prefix()}_letter_spacing"] = text_properties.letter_spacing + mom[f"{utils.prefix()}_orientation"] = text_properties.orientation + mom[f"{utils.prefix()}_translation"] = text_properties.translation bpy.context.view_layer.objects.active = mom bpy.ops.object.parent_set(type='OBJECT') diff --git a/common/utils.py b/common/utils.py index 975842b..4e2ccec 100644 --- a/common/utils.py +++ b/common/utils.py @@ -1,3 +1,15 @@ + +def get_version_major(): + return 0 +def get_version_minor(): + return 0 +def get_version_patch(): + return 1 +def get_version_string(): + return f"{get_version_major()}.{get_version_minor()}.{get_version_patch}" +def prefix(): + return "ABC3D" + import time import datetime from mathutils import (