Skip to content

Quicker Text Editing in Blender (Part 7): QTE Beta Release

Add, remove- we’ve got both!

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 Parts:
  1. Part 1: What We Want To Do & Proof of Concept
  2. Part 2: Operators, Dynamic Classes & a Basic Script
  3. Part 3: Keymaps
  4. Part 4: User Preferences (& Panels)
  5. Part 5: QTE Alpha Release
  6. Part 6: Preferences and the right keymap
  7. Part 7: QTE Beta Release (& ‘Remove Binding’ Operator)

Prerequisite: Add a ‘Remove Binding’ Operator

For preferences, there is a keyitem_remove() method for removing keymap items. However, it seems to remove from another keymap, and so doesn’t work for this addon’s purposes. This is a shame, as I like to avoid reimplementing functionality. At least it’s relatively simple to do:

class QTERemoveKeyMapItem(bpy.types.Operator):
    """Remove a kemapitem by id"""
    bl_idname = "qte.remove_keymapitem"
    bl_label = "Remove KeyMapItem (by id)"

    id: bpy.props.IntProperty(
        name="ID",
    )

    _kmi = bpy.context.window_manager.\
        keyconfigs.user.keymaps['SequencerCommon'].keymap_items

    def execute(self, context):
        if self.id is None:
            raise ValueError("Please supply an id to remove!")
        self._kmi.remove(self._kmi.from_id(self.id))

        return {'FINISHED'}

It can be cleaned up a bit, like the rest of this pre-release beta, but my intent is to get something out the door to actually use in the process of editing so that it can be tested.

Removing KeyMapItems works as expected:

Move ‘Name’ data out of Preferences

As we obviated storing presets in preferences in the last part (Part 6 – Which keymap is the right keymap?), we lost the *_name properties for the various presets. These aren’t used for anything in particular at the moment, other than being an optional user-defined note when looking at the presets; but I have a use in mind for them to be implemented later so I included a property definition (bpy.types.StringProperty) for them in the operator class definitions.

Unexpected Benefits: No duplicates & no need to update!

Another side ‘benefit’ of moving key bindings to the user keymap is that there seems to be some code for detection of duplicate KeyMapItems, so adding a duplicate has no effect:

Changing any of the associated data lets another item be added. While this is beneficial, I can see a very minor downside- if you know you want, say, 4 colour presets you might want to add them all right away and then define them, rather than add -> define -> add -> define.

The other benefit is that changes to the KeyMapItems (eg change of hotkey, change of colour etc) happens right away, so the ‘update keymaps’ button we worked to add is no longer needed!

Beta Release

I’ve got thoughts on how to tidy up the code a bit, and there are features that I plan to add; but fundamentally this is functionally where I’d like the addon to be, at a minimum.

QTE can be found on GitHub: Quicker Text Editing for Blender VSE

2 thoughts on “Quicker Text Editing in Blender (Part 7): QTE Beta Release”

  1. Pingback: Quicker Text Editing in Blender (Part 8): Bugs & Features – Rob's Blog

  2. Pingback: Quicker Text Editing in Blender (Part 9): Prototyping Appearing Text – Rob's Blog

Tell us what's on your mind

Discover more from Rob's Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading