Skip to content

Instantly share code, notes, and snippets.

@sambler
sambler / set_origin.py
Last active October 12, 2017 08:09
Create a custom set origin menu
# made in response to https://blender.stackexchange.com/q/92105/935
bl_info = {
"name": "Test setting origin",
"author": "sambler",
"version": (1, 0),
"blender": (2, 75, 0),
"location": "blender",
"description": "test setting origin menu",
@sambler
sambler / set_image.py
Created August 9, 2017 14:56
Sample of how to set an image to be shown in the 3D viewport as a texture
# made for https://stackoverflow.com/q/45586114/2684771
# expects the current screen to have a 3dviewport and image editor visible
import bpy
bpy.context.scene.render.engine = 'BLENDER_RENDER'
for obj in bpy.data.objects:
bpy.data.objects.remove(obj)
@sambler
sambler / simplified_mesh.py
Created July 25, 2017 13:55
Simplify a mesh to be close to viewport preview drawing
# made for https://blender.stackexchange.com/q/86248/935
# duplicate a mesh to get the edges that define the shape
# skip any extra edges that are part of a flat section
import bpy
import bmesh
# source object
obj = bpy.context.object
# minimum angle between faces that will be kept.
@sambler
sambler / find_image_users.py
Created July 12, 2017 10:36
Show image usage and provide way to clear it.
# made for https://blender.stackexchange.com/q/84328/935
# show places in blender where an image is in use.
# also provide a way to clear the usage of the images.
import bpy
bl_info = {
"name": "Find image users",
"author": "sambler",
"version": (1, 0),
@sambler
sambler / set_dpi.py
Created May 10, 2017 10:53
Small blender addon to toggle the DPI settings
# made for https://blender.stackexchange.com/q/79333/935
bl_info = {
"name": "Set DPI",
"author": "sambler",
"version": (1, 0),
"blender": (2, 75, 0),
"location": "Info header",
"description": "Toggle between two DPI settings",
"category": "System",
@sambler
sambler / make_bound_box.py
Last active February 27, 2017 07:36
Create a bounding box around specific objects
# for comment at http://blender.stackexchange.com/a/14188/935
import bpy
import bmesh
from bpy.props import BoolProperty, FloatVectorProperty
import mathutils
from bpy_extras import object_utils
# from blender templates
def add_box(width, height, depth):
@sambler
sambler / multi_scene_setup.py
Last active June 7, 2021 07:47
Setup multi scene rendering
# made in answer to http://blender.stackexchange.com/q/74086/935
import bpy
master_render_scene_name = 'Multi_render'
base_path = '//renders/'
if master_render_scene_name not in bpy.data.scenes:
bpy.data.scenes.new(name=master_render_scene_name)
@sambler
sambler / satellites.py
Created November 21, 2016 17:23
Create a mesh of satellites spinning around
# made in answer to http://blender.stackexchange.com/q/67612/935
# create a mesh of satellites based on http://space.stackexchange.com/q/19055
import bpy, bpy_extras, bmesh
import math, mathutils
if False: # change to True for final test - needs about 6GB free ram
# full data
# num_planes, num_sats, radius, frames
# frames is number of frames that the orbital plane takes to rotate 360
@sambler
sambler / sub_panels.py
Created August 10, 2016 10:01
Example of creating sub panels in blender
# made in response to http://blender.stackexchange.com/q/60583/935
bl_info = {
"version": (1, 0),
"blender": (2, 75, 0),
"author": "sambler",
"name": "Sample Panel with subpanels addon",
"description": """Sample addon to demonstrate displaying sub-panels within a panel""" ,
"category": "test",
}
@sambler
sambler / test_addon.py
Created July 7, 2016 07:10
Sample test addon to show using unregister() to remove changes by the addon
bl_info = {"version": (1, 0), "blender": (2, 75, 0), "author": "myname",
"name": "testing addon", "location": "blender", "description": "test a new addon" ,
"warning": "only for testing", "category": "test", }
import bpy
# add your operators, panels .....
def register() :
bpy.types.scene.my_int_storage = bpy.props.IntProperty()
bpy.utils.register_class(myOperator)