Skip to content

Instantly share code, notes, and snippets.

@tin2tin
tin2tin / preferences_example.py
Created April 1, 2023 04:22
preferences example
bl_info = {
"name": "VSE Strip Alignment Addon",
"author": "Your Name Here",
"version": (1, 0),
"blender": (3, 4, 0),
"location": "Video Sequence Editor > My Addon",
"description": "Aligns selected VSE strips based on user-specified alignment",
"warning": "",
"doc_url": "",
"category": "Video Editing",
@tin2tin
tin2tin / import_module.py
Created April 1, 2023 03:50
How to import a python module in Blender
import bpy, subprocess, sys, site
def import_module(module, install_module): # name for import, name/url for installation
module = str(module)
try:
exec("import " + module)
except ModuleNotFoundError:
app_path = site.USER_SITE
if app_path not in sys.path:
@tin2tin
tin2tin / install_otio_in_blender.py
Last active March 29, 2023 10:31
Install otio in blender - can also be installed as plugin
# Before running the script do this to be able to see what is happening in the console while it is running:
# Main Menu > Window > Toggle System Console
bl_info = {
"name": "OpentimelineIO Installer",
"author": "tintwotin",
"version": (1, 0),
"blender": (3, 4, 0),
"location": "Check System Console",
@tin2tin
tin2tin / Text_strip_multi_line.py
Created March 17, 2023 08:07
Text strip multi line
import bpy
from bpy.types import Panel
from bpy.utils import register_class
import textwrap
def _label_multiline(context, text, wrap_width, parent):
chars = int(context.region.width / 7)
print(chars)
chars = int(wrap_width)
print(chars)
@tin2tin
tin2tin / multiline.py
Created March 17, 2023 06:05
Multiline text panel
import bpy
from bpy.types import Panel
from bpy.utils import register_class
import textwrap
def _label_multiline(context, text, parent):
chars = int(context.region.width / 7)
wrapper = textwrap.TextWrapper(width=chars)
text_lines = [wrapped_line for line in text.splitlines() for wrapped_line in wrapper.wrap(text=line)]
[parent.label(text=text_line) for text_line in text_lines]
@tin2tin
tin2tin / seqence_menu.py
Last active March 16, 2023 09:46
Add a file related Sequence menu to the VSE header.
import bpy
class SEQUENCER_MT_SequenceMenu(bpy.types.Menu):
bl_idname = "SEQUENCER_MT_sequence_menu"
bl_label = "Sequence"
def draw(self, context):
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
@tin2tin
tin2tin / modal_template.py
Created March 1, 2023 08:19
Modal operator template
import bpy
bl_info = {
"name": "Example Addon",
"blender": (2, 80, 0),
"category": "Sequencer"
}
class ExampleOperator(bpy.types.Operator):
"""Example Operator"""
@tin2tin
tin2tin / vse_operator_template.py
Created March 1, 2023 05:40
VSE operator template
bl_info = {
"name": "My VSE Operator",
"description": "An operator for the VSE.",
"author": "Your Name",
"version": (1, 0),
"blender": (3, 0, 0),
"location": "Sequencer > Strip > My Operator",
"category": "Sequencer"
}
@tin2tin
tin2tin / copy_driver.py
Created February 27, 2023 10:50
Copy/paste driver of the font sizes of two text strips
import bpy
# Set up the scene
bpy.context.scene.sequence_editor_create()
# Add the first text strip
txt1 = bpy.context.scene.sequence_editor.sequences.new_effect(
name="First",
type="TEXT",
channel=1,
@tin2tin
tin2tin / find_clap.py
Created February 22, 2023 06:02
Find clap in active strip and offset selected strips accordingly in the Blender VSE
# by chatGPT
import bpy
import librosa
import numpy as np
def find_clap_time(audio_file):
# Load the audio file using Librosa
y, sr = librosa.load(audio_file)