From 222948915025b2bb2ae6aac5ea56c798df62ed64 Mon Sep 17 00:00:00 2001 From: gandalf3 Date: Mon, 23 Mar 2020 07:40:40 -0700 Subject: [PATCH 1/2] Fix animation render with keyframed typewriter properties We need to explicitly evaluate the object as described here: https://wiki.blender.org/wiki/Reference/Release_Notes/2.81/Python_API#Handlers in order to get all current value of any fcurve-animated properties. --- __init__.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/__init__.py b/__init__.py index c6f8dbe..23e4922 100644 --- a/__init__.py +++ b/__init__.py @@ -48,7 +48,7 @@ def randomize(t,width): return(nt) -def uptext(text): +def uptext(text, eval_text): ''' slice the source text up to the character_count ''' @@ -68,29 +68,32 @@ def uptext(text): t = source #randomize - if text.use_randomize and len(t) > text.character_count: - t = randomize(t[:text.character_count], text.randomize_width) + if eval_text.use_randomize and len(t) > eval_text.character_count: + t = randomize(t[:eval_text.character_count], eval_text.randomize_width) prefix = '' - if text.preserve_newline and text.character_start > 0: - prefix = '\n' * t.count('\n', 0, text.character_start) - if text.preserve_space and text.character_start > 0: - prefix += ' ' * (text.character_start - (t.rfind('\n', 0, text.character_start) + 1)) + if eval_text.preserve_newline and eval_text.character_start > 0: + prefix = '\n' * t.count('\n', 0, eval_text.character_start) + if eval_text.preserve_space and eval_text.character_start > 0: + prefix += ' ' * (eval_text.character_start - (t.rfind('\n', 0, eval_text.character_start) + 1)) - new_text = prefix + t[text.character_start:text.character_count] - count = text.character_count + new_text = prefix + t[eval_text.character_start:eval_text.character_count] + count = eval_text.character_count text.body = new_text @persistent -def typewriter_text_update_frame(scene): +def typewriter_text_update_frame(scene, depsgraph): ''' sadly we need this for frame change updating ''' + for text in scene.objects: if text.type == 'FONT' and text.data.use_animated_text: - uptext(text.data) + eval_text = text.evaluated_get(depsgraph) + uptext(text.data, eval_text.data) + def update_func(self, context): ''' @@ -207,7 +210,7 @@ def register(): register_class(cls) # add the frame change handler - bpy.app.handlers.frame_change_pre.append(typewriter_text_update_frame) + bpy.app.handlers.frame_change_post.append(typewriter_text_update_frame) def unregister(): @@ -215,7 +218,7 @@ def unregister(): addon unregistration function ''' # remove the frame change handler - bpy.app.handlers.frame_change_pre.remove(typewriter_text_update_frame) + bpy.app.handlers.frame_change_post.remove(typewriter_text_update_frame) # remove the panel from bpy.utils import unregister_class From 42491576386c1e6afc8f246b8765dcbb3fb6116a Mon Sep 17 00:00:00 2001 From: gandalf3 Date: Mon, 23 Mar 2020 07:44:48 -0700 Subject: [PATCH 2/2] add gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bee8a64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__