More features!
Context
When making videos in Blender’s VSE I use a lot of text sequences for captions and the like. Doing common operations — like changing colour, location, size etc — can be slow when using the GUI, so I am writing an addon called QTE (Quicker Text Editing, pronounced ‘cutie’) to make the process faster. This series of posts outlines the process and tries to explain parts of the Blender API that I interacted with along the way.
Show all parts (click to expand)
Parts:- Part 1: What We Want To Do & Proof of Concept
- Part 2: Operators, Dynamic Classes & a Basic Script
- Part 3: Keymaps
- Part 4: User Preferences (& Panels)
- Part 5: QTE Alpha Release
- Part 6: Preferences and the right keymap
- Part 7: QTE Beta Release (& ‘Remove Binding’ Operator)
- Part 8: Bugs & Features
- Part 9: Prototyping Appearing Text
- Interlude: Why is my Blender addon panel property read only? (Solved)
- Part 10: Beta 2 Release (+ Development Hurdles)
- Part 11: Reflection and Next Steps
- Part 12: Preferences + Properties = Bugs
- Part 13: CollectionProperty, KeyMapItem ID, Preferences Pitfalls
Release
You can get the beta2 release of QTE from its GitHub page.
Split on Words Demo
You want to split a single text strip into individual strips for each word, and have those appear over time? This release is for you!
I wanted this feature for doing a promo video for ‘A Great Bunch of Lads’, a coop CK3 campaign I did a few months back.
Summary
I’ve been adding more to QTE, in particular a big feature that I would like to have for my own use: make a sentence appear one word at a time. There was also a bug in how the ‘remove preset’ keymap items reference was being accessed, so I fixed that bug too.
There were a few stumbling blocks with the API along the way to this beta release, which I’ll mention briefly below.
Development Hurdles
My operator properties Panel is frozen?!
I mentioned this in its own post:
The long and short of it is although you might think (as I did) that defining the options for the operator in the operator itself would suffice, in fact: both the panel and the operator need access to the properties.
There is a link at the end of that post to a follow-up discussion on BlenderArtists.
Getting the size of a Text Strip / TextSequence
Discussions:
- Is there a way to determine the size of a text sequence?
- Getting a font from fontid, or fontid from VectorFont / TextSequence?
To figure out how far apart the created text strips should be, we need either a heuristic or an exact measurement of how wide words and spaces are. The preferable approach is the latter, but while I was pointed at blf
, there didn’t seem to be any user-accessible link between the fonts used in TextSequences (VectorFonts) and the fonts loaded by blf. I spent some time and created a debugging operator that wrote font info to a file trying to figure out if there was a link. I’m not the first to ask about this!
Workaround: Re-load the same font to get the same `fontid`, by massaging the filepath
property to give an absolute path (as opposed to the ‘absolute relative path’ (??!) returned by bpy.path.abspath()
)
I’m not exactly thrilled with the workaround as it feels like it might break or leak ids if the underlying blender code is changed. If the latter happens I can implement my own fontid ‘cache’, but for now it works.
Updating properties without creating a circular reference
I wanted the user to be able to specify the time offset in terms of either seconds or frames, rather than forcing one or the other. Blender *-Property
types have the ability to specify a callback by supplying a reference to update
; so I used this to change the frame offset when the user specifies a time and vice-versa. While this ostensibly worked, it caused console complaints:
Thanks to this answer by BYOB, this is achievable via accessing properties as self["property"]
instead of self.property
in the update()
callbacks.