so if you use batfingers answer in your code, it might look like this:
"""quicker-text-editing.py -- text addon for Blender VSE"""
bl_info = {
"name": "Quicker Text Editing for VSE",
"author": "bertieb",
"version": (0, 1),
"blender": (3, 3, 0),
"location": "Video Sequence Editor > Text Strip",
"description": "Quicker editing of text strips: position, colour, size, duration",
"warning": "",
"doc_url": "",
"category": "Sequencer",
}
from enum import Enum
import bpy
import random
class Colours(Enum):
"""some predefined colours - array of 4 floats (RGBA)"""
GREEN = [0.03529411926865578, 0.6117647290229797, 0.03921568766236305, 1.0]
PURPLE = [0.43800756335258484, 0.0, 0.6117647290229797, 1.0]
BLUE = [0.12156863510608673, 0.41568630933761597, 0.6117647290229797, 1.0]
class Locations(Enum):
"""predefined locations - array of 2 floats (x,y)"""
ONE = [0.5, 0.1]
TWO = [0.5, 0.22]
THREE = [0.5, 0.34]
FOUR = [0.5, 0.45]
class TextSequenceAction(bpy.types.Operator):
"""Implements operations for quickly manipulating text sequences in VSE"""
bl_idname = "sequencer.textsequenceaction"
bl_label = "Text Sequence Action"
def execute(self, context):
return {"FINISHED"}
@classmethod
def poll(cls, context):
"""Ensure we're in the VSE with at least one sequence selected"""
return (context.scene and context.scene.sequence_editor
and context.selected_editable_sequences is not None)
class SetTextColour(TextSequenceAction):
"""Set colour of text sequence[s]"""
bl_idname = "sequencer.settextcolor"
bl_label = "Set Text Colour"
color : bpy.props.FloatVectorProperty(
name = "myColor",
subtype = "COLOR",
size = 4,
min = 0.0,
max = 1.0,
default = (1.0,0.0,0.0,1.0)
)
def execute(self, context):
for strip in bpy.context.selected_editable_sequences:
if strip.type == "TEXT":
strip.color = self.color
strip.color = self.color
strip.color = self.color
strip.color = self.color
strip.color = self.color
strip.color = self.color
return {'FINISHED'}
class SetGreenTextColour(SetTextColour):
"""Set colour of text sequence[s]"""
bl_idname = "sequencer.setgreentextcolor"
bl_label = "Set Green Text Colour"
def __init__(self):
self.color = (0,1,0,1)
class SetTextLocation(TextSequenceAction):
"""Set location of text sequence[s]"""
bl_idname = "sequencer.settextlocation"
bl_label = "Set Text Location"
def execute(self, context):
for strip in bpy.context.selected_editable_sequences:
if strip.type == "TEXT":
strip.location = random.choice(list(Locations)).value
return {'FINISHED'}
class SetTextDuration(TextSequenceAction):
"""Set location of text sequence[s]"""
bl_idname = "sequencer.settextduration"
bl_label = "Set Text Duration"
def execute(self, context):
for strip in bpy.context.selected_editable_sequences:
if strip.type == "TEXT":
strip.frame_final_duration += random.randint(-10, 10)
return {'FINISHED'}
class SetTextSize(TextSequenceAction):
"""Set size of text sequence[s]"""
bl_idname = "sequencer.settextsize"
bl_label = "Set Text Size"
def execute(self, context):
for strip in bpy.context.selected_editable_sequences:
if strip.type == "TEXT":
strip.font_size += random.choice([-15, -10, -5, 5, 10, 15])
return {'FINISHED'}
REGISTER_CLASSES = [SetTextColour, SetGreenTextColour, SetTextLocation, SetTextDuration,
SetTextSize]
def register():
for classname in REGISTER_CLASSES:
bpy.utils.register_class(classname)
def unregister():
for classname in REGISTER_CLASSES:
bpy.utils.unregister_class(classname)
if __name__ == "__main__":
register()
result: