1
$\begingroup$

I am currently trying to create a gizmo for the transform effect in Blender's VSE (2.8). However, I can't seem to get it to work. In fact, even though I call window_manager.gizmo_group_type_ensure() in various places without and exception resulting from it, it seems like none of my class's functions are ever called. Could it be that it is not possible (yet) to create custom gizmos in the VSE or am I missing something really obvious?

Here is my code (most of it, calls to window_manager.gizmo_group_type_ensure() not included because they occur elsewhere in a larger project. Note that actual method code is untested because it never seems to be called):

class TransformEffectGroup(bpy.types.GizmoGroup):
    bl_idname = 'CS_GGT_transform_effect'
    bl_space_type = 'SEQUENCE_EDITOR'
    bl_region_type = 'WINDOW'
    bl_label = 'Transform Effect Gizmo'

    @classmethod
    def poll(cls, context):
        print("Transform effect gizmo polled")
        active_strip = context.scene.sequence_editor.active_strip
        return not active_strip is Null and active_strip.type == 'TRANSFORM'

    def setup(self, context):
        active_strip = context.scene.sequence_editor.active_strip
        gizmo = self.gizmos.new("GIZMO_GT_cage_2d")
        gizmo.target_set_handler("matrix", get=self.get_matrix, set=self.set_matrix)
        gizmo.dimensions = (100, 100)
        gizmo.transform = { 'SCALE_UNIFORM', 'TRANSLATE', 'ROTATE' }

    def refresh(self, context):
        active_strip = context.scene.sequence_editor.active_strip
        if not active_strip is Null and active_strip.type == 'TRANSFORM':
            self.strip = active_strip

    def get_matrix(self):
        m  = Matrix.Scale(self.strip.scale_start_x, 4, Vector(1, 0, 0))
        m *= Matrix.Scale(self.strip.scale_start_y, 4, Vector(0, 1, 0))
        m *= Matrix.Rotation(self.strip.rotation_start, 4, 'Z')
        m *= Matrix.Translation(Vector(self.strip.translate_start_x, self.strip.translate_start_y, 0))
        return m

    def set_matrix(self, matrix):
        t = matrix.to_translation()
        self.strip.translate_start_x = t[0]
        self.strip.translate_start_y = t[1]
        s = matrix.to_scale()
        self.strip.scale_start_x = s[0]
        self.strip.scale_start_x = s[1]
        self.strip.rotation_start = matrix.to_euler('ZYX')[0]
$\endgroup$
1
$\begingroup$

This is a bug as acknowledged by the developers here: https://developer.blender.org/T70768 But basically it works if you set bl_region_type = 'PREVIEW'

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.