Skip to content

Instantly share code, notes, and snippets.

@tamask
tamask / log.py
Created August 8, 2018 00:44
Route system output (stdout/stderr) of Blender to the app console (put in scripts/startup)
import os
import sys
import bpy
output = None
input = None
info = None
error = None
write = None
@tamask
tamask / MeshInfo.cs
Created January 15, 2019 12:34
Unity: display mesh info for selected object
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(MeshFilter))]
public class MeshInfo : Editor {
protected MeshFilter meshFilter;
protected Mesh mesh;
protected Vector3[] lines;
public void OnEnable() {
@tamask
tamask / io_export_curve.py
Created February 8, 2019 11:42
Blender: Export the active curve object (U-component only)
# This exporter just serializes Blender's bpy curve data API verbatim,
# so the exported json structure mirrors the variable names and
# arrays. The exporter only goes so far to export the U-component of
# the curve data, since we're more interested in curves and not NURBS
# surfaces for use in videogames. An asset importer in Unity need only
# look up the Blender Python API to choose how to interpret this data.
import bpy
import json
from bpy_extras.io_utils import ExportHelper
@tamask
tamask / io_export_unity_lines.py
Created May 10, 2012 13:29
Unity Lines (.js) (Blender exporter)
import os
import bpy
bl_info = {
'name': 'Unity Lines (.js)',
'author': 'Tamas Kemenczy',
'version': (0, 1),
'blender': (2, 6, 3),
'location': 'File > Import-Export > Unity Lines (.js)',
'description': 'Export loose edges of a mesh as Unity GL immediate-mode commands',
@tamask
tamask / qsort.js
Created July 13, 2011 14:51
In-place, non-recursive qsort in Javascript
function qsort(a, k, l, r) {
// a: array to sort, k: key to sort by,
// l, r: optional array index array range
// i: stack index, s: stack,
// p: pivot index, v: pivot value,
// t: temporary array item,
// x, y: partion low/high
var i, s, p, v, t, x, y;
@tamask
tamask / select_by_color.py
Created May 4, 2012 01:04
Select By Color (Blender)
import bpy
from mathutils import Color
bl_info = {
'name': 'Select By Color',
'author': 'Tamas Kemenczy',
'version': (0, 1),
'blender': (2, 6, 1),
'location': 'View3D > Specials > Select By Color',
'description': 'Select all faces with the same vertex color of the selected face',
@tamask
tamask / action_simplify.py
Created November 30, 2020 16:46
Blender addon: Use Simplify F-Curves on any action visible in the graph editor.
import bpy
import curve_simplify
bl_info = {
'name': 'Simplify Action',
'author': 'Tamas Kemenczy',
'version': (0, 1),
'blender': (2, 91, 0),
'description': 'Use Simplify F-Curves on any action visible in the graph editor.',
'category': 'Add Curve',
@tamask
tamask / fetch-iphone-photos.py
Last active November 17, 2020 19:10
Utility script for downloading photos/images from the iPhone. Optionally converts HEIC files to JPG with `heif-convert` util. Meant for Linux but could work elsewhere. `heif-convert` is available through the `libheif-examples` package on Ubuntu, for example.
#!/usr/bin/env python
# HEIC image conversion depends on the heif-convert cmd utility,
# available through the `libheif-examples` package on Ubuntu, for example.
import os
import glob
import argparse
import datetime
import shutil
@tamask
tamask / export_svg_lines.py
Last active September 18, 2019 07:23
Export xy-plane bezier/poly lines as svg outlines.
import os
import bpy
import math
import mathutils
bl_info = {
'name': 'Export SVG Lines (.svg)',
'author': 'Tamas Kemenczy',
'version': (0, 1),
'blender': (2, 6, 9),
@tamask
tamask / plot.py
Created July 28, 2019 20:29
Blender 2.80 plotter
import bpy
import bmesh
NAME = '(Plot)'
def line(gen, name=NAME):
"""Plot arbitrary x,y values as line"""
with Plotter(name) as p:
for x, y in gen:
p.extend(x, y)