Skip to content

Instantly share code, notes, and snippets.

View adhihargo's full-sized avatar

Adhi Hargo adhihargo

View GitHub Profile
@adhihargo
adhihargo / playback_once.py
Created March 14, 2015 06:07
Tiny addon to show minimal amount of steps needed to make non-looping animation playback in Blender.
import bpy
from bpy.app.handlers import persistent
bl_info = {
"name": "Playback Once",
"author": "Adhi Hargo",
"version": (1, 0, 0),
"blender": (2, 67, 3),
"location": "",
"description": "Playback once.",
@adhihargo
adhihargo / add_group_instance_array.py
Last active December 21, 2015 15:19
For a selected object, create an array of instances of the object's group.
import bpy
from itertools import product
from mathutils import Vector
def get_enum_items(self, context):
obj = context.active_object
groups = obj.users_group
group_names = [g.name for g in groups]
return [(gn, gn, 'Instance group "%s"'%gn) for gn in group_names]
@adhihargo
adhihargo / add_quarter_curve.py
Created July 23, 2013 14:36
Add a new quarter curve object.
import bpy
import math
from mathutils import Vector
class OBJECT_OT_quarter_circle(bpy.types.Operator):
"""Create one fourth of a circle."""
bl_idname = 'curve.quarter_circle_add'
bl_label = 'Quarter Circle'
bl_options = {'REGISTER', 'UNDO'}
@adhihargo
adhihargo / custom_object_add.py
Created July 9, 2013 23:09
Blender script to add primitive object with low initial vertex count. Uncomment `bl_info` block to turn into an addon.
import bpy
# bl_info = {
# "name": "Low Vertex Count Objects",
# "author": "",
# "version": (1, 0),
# "blender": (2, 63, 0),
# "location": "View3D > Add",
# "description": "Add primitive object with low initial vertex count",
# "warning": "",
@adhihargo
adhihargo / gist:5842868
Last active December 18, 2015 20:48
Bone snapping tool. Works for parented bone, only if there's no Child Of constraint involved, and all parent's scale are uniform across all axis.
import bpy
class VIEW3D_OT_BoneSnapToObject(bpy.types.Operator):
"""Snap active bone to selected object."""
bl_idname = 'object.snap_to_object'
bl_label = 'Snap Bone to Object'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(self, context):
@adhihargo
adhihargo / camera_add_title_safe.py
Last active January 11, 2017 08:16
Add Camera Title Safe: A Blender Python operator for adding a mesh-based title-safe frame to a 3D camera. The frame's size adjusts automatically to active scene's render resolution and aspect ratio, and is independent to the 3D camera's own scale.
# Author: Adhi Hargo (cadmus.sw@gmail.com)
# License: GPL v2
import bpy
class CameraAddTitleSafe(bpy.types.Operator):
bl_idname = 'object.camera_add_title_safe'
bl_label = 'Add Camera Title Safe'
bl_options = {'REGISTER', 'UNDO'}