[fix] deletion fixes+
and some smaller cosmetic changes
This commit is contained in:
parent
8470425d20
commit
d61607c75d
2 changed files with 45 additions and 11 deletions
26
__init__.py
26
__init__.py
|
@ -336,7 +336,7 @@ class ABC3D_UL_texts(bpy.types.UIList):
|
||||||
|
|
||||||
|
|
||||||
class ABC3D_PT_Panel(bpy.types.Panel):
|
class ABC3D_PT_Panel(bpy.types.Panel):
|
||||||
bl_label = f"{__name__} panel"
|
bl_label = f"{utils.prefix()} Panel"
|
||||||
bl_category = "ABC3D"
|
bl_category = "ABC3D"
|
||||||
bl_space_type = "VIEW_3D"
|
bl_space_type = "VIEW_3D"
|
||||||
bl_region_type = "UI"
|
bl_region_type = "UI"
|
||||||
|
@ -344,6 +344,9 @@ class ABC3D_PT_Panel(bpy.types.Panel):
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
|
|
||||||
|
row = layout.row()
|
||||||
|
row.label(text=f"{utils.prefix()} v{utils.get_version_string()}")
|
||||||
|
|
||||||
icon = "NONE"
|
icon = "NONE"
|
||||||
if len(context.scene.abc3d_data.available_fonts) == 0:
|
if len(context.scene.abc3d_data.available_fonts) == 0:
|
||||||
icon = "ERROR"
|
icon = "ERROR"
|
||||||
|
@ -439,11 +442,9 @@ class ABC3D_PT_FontList(bpy.types.Panel):
|
||||||
row = box.row()
|
row = box.row()
|
||||||
row.label(text="File and Memory optimization")
|
row.label(text="File and Memory optimization")
|
||||||
row = box.row()
|
row = box.row()
|
||||||
row.operator(f"{__name__}.refresh_fonts", text="Refresh Font list from disk")
|
row.operator(f"{__name__}.refresh_fonts", text="Refresh font list from disk")
|
||||||
row = box.row()
|
row = box.row()
|
||||||
row.operator(
|
row.operator(f"{__name__}.unload_unused_glyphs", text="Unload unused glyphs")
|
||||||
f"{__name__}.unload_unused_glyphs", text="Unload unused glyphs from memory"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ABC3D_PT_TextPlacement(bpy.types.Panel):
|
class ABC3D_PT_TextPlacement(bpy.types.Panel):
|
||||||
|
@ -1013,7 +1014,6 @@ class ABC3D_OT_LoadInstalledFonts(bpy.types.Operator):
|
||||||
return context.window_manager.invoke_props_dialog(self)
|
return context.window_manager.invoke_props_dialog(self)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
print("EXECUTE LOAD INSTALLED FONTS")
|
|
||||||
scene = bpy.context.scene
|
scene = bpy.context.scene
|
||||||
|
|
||||||
if self.load_into_memory:
|
if self.load_into_memory:
|
||||||
|
@ -1234,6 +1234,7 @@ class ABC3D_OT_RemoveText(bpy.types.Operator):
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
abc3d_data = context.scene.abc3d_data
|
abc3d_data = context.scene.abc3d_data
|
||||||
|
lock_depsgraph_updates(auto_unlock_s=-1)
|
||||||
if abc3d_data.active_text_index < 0:
|
if abc3d_data.active_text_index < 0:
|
||||||
butils.ShowMessageBox(
|
butils.ShowMessageBox(
|
||||||
title="No text selected",
|
title="No text selected",
|
||||||
|
@ -1269,6 +1270,7 @@ class ABC3D_OT_RemoveText(bpy.types.Operator):
|
||||||
butils.simply_delete_objects(remove_list)
|
butils.simply_delete_objects(remove_list)
|
||||||
|
|
||||||
abc3d_data.available_texts.remove(i)
|
abc3d_data.available_texts.remove(i)
|
||||||
|
unlock_depsgraph_updates()
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
@ -2033,6 +2035,7 @@ import time
|
||||||
@persistent
|
@persistent
|
||||||
def on_depsgraph_update(scene, depsgraph):
|
def on_depsgraph_update(scene, depsgraph):
|
||||||
if not bpy.context.mode.startswith("EDIT") and not are_depsgraph_updates_locked():
|
if not bpy.context.mode.startswith("EDIT") and not are_depsgraph_updates_locked():
|
||||||
|
lock_depsgraph_updates(auto_unlock_s=-1)
|
||||||
for u in depsgraph.updates:
|
for u in depsgraph.updates:
|
||||||
if (
|
if (
|
||||||
butils.get_key("text_id") in u.id.keys()
|
butils.get_key("text_id") in u.id.keys()
|
||||||
|
@ -2046,12 +2049,17 @@ def on_depsgraph_update(scene, depsgraph):
|
||||||
if text_properties.text_object == u.id.original:
|
if text_properties.text_object == u.id.original:
|
||||||
# nothing to do
|
# nothing to do
|
||||||
pass
|
pass
|
||||||
else:
|
elif butils.is_text_object_legit(u.id.original):
|
||||||
# must be duplicate
|
# must be duplicate
|
||||||
link_text_object_with_new_text_properties(u.id.original, scene)
|
link_text_object_with_new_text_properties(u.id.original, scene)
|
||||||
else:
|
elif (
|
||||||
# must be new thing
|
butils.is_text_object_legit(u.id.original)
|
||||||
|
and len(u.id.original.users_collection) > 0
|
||||||
|
):
|
||||||
|
# must be a new thing, maybe manually created or so
|
||||||
link_text_object_with_new_text_properties(u.id.original, scene)
|
link_text_object_with_new_text_properties(u.id.original, scene)
|
||||||
|
butils.clean_text_properties()
|
||||||
|
unlock_depsgraph_updates()
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
|
|
30
butils.py
30
butils.py
|
@ -647,6 +647,17 @@ def is_glyph_used(glyph_alternates):
|
||||||
return False
|
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):
|
def clean_fontcollection(fontcollection=None):
|
||||||
if fontcollection is None:
|
if fontcollection is None:
|
||||||
fontcollection = bpy.data.collections.get("ABC3D")
|
fontcollection = bpy.data.collections.get("ABC3D")
|
||||||
|
@ -1336,6 +1347,21 @@ def test_finding():
|
||||||
transfer_text_object_to_text_properties(o, t)
|
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():
|
# def detect_texts():
|
||||||
# scene = bpy.context.scene
|
# scene = bpy.context.scene
|
||||||
# abc3d_data = scene.abc3d_data
|
# abc3d_data = scene.abc3d_data
|
||||||
|
@ -1478,6 +1504,8 @@ def set_text_on_curve(
|
||||||
mom = text_properties.text_object
|
mom = text_properties.text_object
|
||||||
if mom.type != "CURVE":
|
if mom.type != "CURVE":
|
||||||
return False
|
return False
|
||||||
|
if len(mom.users_collection) < 1:
|
||||||
|
return False
|
||||||
|
|
||||||
distribution_type = "CALCULATE" if is_bezier(mom) else "FOLLOW_PATH"
|
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 = []
|
targets = []
|
||||||
reference_bound_box = None
|
reference_bound_box = None
|
||||||
for o in objects:
|
for o in objects:
|
||||||
if not hasattr(o, "parent"):
|
|
||||||
print(f"{o.name} has not a PARENTNTNTNTNTNNTNTNTNTNTN")
|
|
||||||
is_possibly_glyph = is_glyph(o)
|
is_possibly_glyph = is_glyph(o)
|
||||||
if is_possibly_glyph:
|
if is_possibly_glyph:
|
||||||
metrics = []
|
metrics = []
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue