Skip to content

Instantly share code, notes, and snippets.

@tin2tin
tin2tin / __init__.py
Created January 16, 2025 10:45
Threading
import bpy
import subprocess
import threading
import re
# Function to parse progress from subprocess output
def parse_progress(line):
"""
Parses progress information from a line of output.
@tin2tin
tin2tin / __init__.py
Created January 15, 2025 09:18
Export a Frame for Each Shot
bl_info = {
"name": "Export a Frame for Each Shot",
"author": "tintwotin",
"version": (1, 0),
"blender": (3, 00, 0),
"location": "Strip > Export a Frame for Each Shot",
"description": "",
"warning": "",
"doc_url": "",
"category": "Sequencer",
@tin2tin
tin2tin / __init__.py
Created November 24, 2024 04:54
Update text strip content, when changing text-block
import bpy
# Store the last synced text block content to detect changes
LAST_SYNCED_TEXT = {"content": None, "name": None}
# Add properties to the Text Strip
def add_text_strip_properties():
bpy.types.Sequence.text_sync_enabled = bpy.props.BoolProperty(
name="Sync with Text Block",
description="Enable syncing with a specific text block",
@tin2tin
tin2tin / __init__.py
Last active November 18, 2024 22:28
OCR for the Text Editor
bl_info = {
"name": "OCR Add-on",
"blender": (3, 0, 0),
"category": "Text Editor",
"author": "Your Name",
"version": (1, 0, 0),
"location": "Text Editor > Sidebar",
"description": "Add-on for OCR with specified models"
}
@tin2tin
tin2tin / __init__.py
Created September 29, 2024 20:31
Does operator exist?
import bpy
def operator_exists(idname):
# Split the idname string into the operator type and the operator function
idname_parts = idname.split(".")
if len(idname_parts) != 2:
return False # The idname is not properly formatted
operator_type, operator_func = idname_parts
@tin2tin
tin2tin / dl_md5_json.py
Last active August 15, 2024 14:42
Download, get md5 and produce json, for GPT4ALL models
import requests
from tqdm import tqdm
from pathlib import Path
import hashlib
import json
def download_file_with_progress(url, save_path):
"""
Downloads a file from a URL with a progress bar.
@tin2tin
tin2tin / space_sequencer.py
Last active August 10, 2024 11:13
Text panel for the Blender VSE
# SPDX-FileCopyrightText: 2009-2023 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
import bpy
from bpy.types import (
Header,
Menu,
Panel,
)
@tin2tin
tin2tin / __init__.py
Created June 27, 2024 14:50
Audio sync
bl_info = {
"name": "Robust Audio Sync",
"author": "tintwotin",
"version": (1, 8),
"blender": (2, 80, 0),
"location": "Sequencer > Strip > Transform > Robust Audio Sync",
"description": "Sync similar audio recordings",
"warning": "",
"doc_url": "",
"category": "Sequencer",
@tin2tin
tin2tin / retime_ui.py
Created April 26, 2024 10:29
Retime UI
import bpy
class RETIMING_PT_panel(bpy.types.Panel):
bl_label = "Retiming"
bl_idname = "RETIMING_PT_panel"
bl_space_type = 'SEQUENCE_EDITOR'
bl_region_type = 'UI'
bl_category = 'Strip'
@tin2tin
tin2tin / forward_of_sdxl_original_unet.py
Created January 12, 2024 21:42 — forked from kohya-ss/forward_of_sdxl_original_unet.py
SDXLで高解像度での構図の破綻を軽減する
def forward(self, x, timesteps=None, context=None, y=None, **kwargs):
# broadcast timesteps to batch dimension
timesteps = timesteps.expand(x.shape[0])
hs = []
t_emb = get_timestep_embedding(timesteps, self.model_channels) # , repeat_only=False)
t_emb = t_emb.to(x.dtype)
emb = self.time_embed(t_emb)
assert x.shape[0] == y.shape[0], f"batch size mismatch: {x.shape[0]} != {y.shape[0]}"