depsgraph detect texts
implementing in depsgraph allows for duplication
This commit is contained in:
parent
c27cf41368
commit
10e57dd46a
1 changed files with 16 additions and 17 deletions
33
__init__.py
33
__init__.py
|
@ -1791,6 +1791,11 @@ def compare_text_object_with_object(t, o, strict=False):
|
||||||
# if
|
# if
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def link_text_object_with_new_text_properties(text_object, scene = None):
|
||||||
|
lock_depsgraph_updates(auto_unlock_s=-1)
|
||||||
|
butils.link_text_object_with_new_text_properties(text_object, scene)
|
||||||
|
unlock_depsgraph_updates()
|
||||||
|
|
||||||
|
|
||||||
def detect_text():
|
def detect_text():
|
||||||
lock_depsgraph_updates(auto_unlock_s=-1)
|
lock_depsgraph_updates(auto_unlock_s=-1)
|
||||||
|
@ -1921,10 +1926,8 @@ def are_depsgraph_updates_locked():
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
@persistent
|
@persistent
|
||||||
def on_depsgraph_update(scene, depsgraph):
|
def on_depsgraph_update(scene, depsgraph):
|
||||||
global depsgraph_updates_locked
|
|
||||||
print("DEPSGRAPH:: BEGIN")
|
print("DEPSGRAPH:: BEGIN")
|
||||||
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():
|
||||||
for u in depsgraph.updates:
|
for u in depsgraph.updates:
|
||||||
|
@ -1940,26 +1943,21 @@ def on_depsgraph_update(scene, depsgraph):
|
||||||
print(f" is {len(scene.abc3d_data.available_texts)} bigger than {text_id=} is true?")
|
print(f" is {len(scene.abc3d_data.available_texts)} bigger than {text_id=} is true?")
|
||||||
# butils.detect_texts()
|
# butils.detect_texts()
|
||||||
if len(scene.abc3d_data.available_texts) > text_id:
|
if len(scene.abc3d_data.available_texts) > text_id:
|
||||||
|
text_properties = scene.abc3d_data.available_texts[text_id]
|
||||||
print(" YES")
|
print(" YES")
|
||||||
print(" is ? text object is not u.id")
|
print(f" is ? {text_properties.text_object.name=} is {u.id.name=}")
|
||||||
if scene.abc3d_data.available_texts[text_id].text_object != u.id:
|
if text_properties.text_object == u.id.original:
|
||||||
print(" yes")
|
print(" yes by id")
|
||||||
else:
|
else:
|
||||||
print(" no")
|
# must be duplicate
|
||||||
|
link_text_object_with_new_text_properties(u.id.original, scene)
|
||||||
|
print(" no by id")
|
||||||
else:
|
else:
|
||||||
|
# must be new thing
|
||||||
|
print(" NO, LINK TO NEW TEXTOBJECT")
|
||||||
|
link_text_object_with_new_text_properties(u.id.original, scene)
|
||||||
print(" NO")
|
print(" NO")
|
||||||
print("DEPSGRAPH:: done textobject")
|
print("DEPSGRAPH:: done textobject")
|
||||||
# lock_depsgraph_updates()
|
|
||||||
|
|
||||||
# def later():
|
|
||||||
# if butils.lock_depsgraph_update_n_times <= 0:
|
|
||||||
# butils.set_text_on_curve(
|
|
||||||
# scene.abc3d_data.available_texts[text_id]
|
|
||||||
# )
|
|
||||||
# elif butils.lock_depsgraph_update_n_times <= 0:
|
|
||||||
# butils.lock_depsgraph_update_n_times -= 1
|
|
||||||
|
|
||||||
# butils.run_in_main_thread(later)
|
|
||||||
if are_depsgraph_updates_locked():
|
if are_depsgraph_updates_locked():
|
||||||
print(" L O C K E D")
|
print(" L O C K E D")
|
||||||
print("DEPSGRAPH:: done")
|
print("DEPSGRAPH:: done")
|
||||||
|
@ -1993,6 +1991,7 @@ def register():
|
||||||
butils.run_in_main_thread(butils.update_available_fonts)
|
butils.run_in_main_thread(butils.update_available_fonts)
|
||||||
butils.run_in_main_thread(load_used_glyphs)
|
butils.run_in_main_thread(load_used_glyphs)
|
||||||
butils.run_in_main_thread(butils.update_types)
|
butils.run_in_main_thread(butils.update_types)
|
||||||
|
butils.run_in_main_thread(detect_text)
|
||||||
|
|
||||||
Font.init()
|
Font.init()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue