Skip to content

Instantly share code, notes, and snippets.

poor p2or

Block or report user

Report or block p2or

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View formatnumbers.py
#http://stackoverflow.com/questions/733454/best-way-to-format-integer-as-string-with-leading-zeros
def formatNumbers(number, length):
return '%0*d' % (length, number)
@p2or
p2or / functions.php
Created Jul 17, 2014
wordpress - add class to the_post_thumbnail
View functions.php
<?php the_post_thumbnail('post-thumbnail', array( 'class' => "grid_4 img-max attachment-post-thumbnail")); ?>
View typecheck.py
def typecheck(obj):
return hasattr(obj, '__iter__') and not isinstance(obj, str)
@p2or
p2or / randomGroupObject.py
Last active Jul 16, 2019
blender-selectRandomObjectInGroup
View randomGroupObject.py
import bpy
from random import choice
scene = bpy.context.scene
ob = bpy.context.object
random_group = choice(ob.users_group)
obs = random_group.objects[:]
obs.remove(ob)
@p2or
p2or / enum_GroupsInScene.py
Last active Jul 6, 2019
blender_EnumProperty-groupsInScene
View enum_GroupsInScene.py
bl_info = {
"name": "tester",
"description": "",
"author": "",
"version": (0, 0, 3),
"blender": (2, 70, 0),
"location": "3D View > Toolbox",
"warning": "", # used for warning icon and text in addons panel
"wiki_url": "",
"tracker_url": "",
View blender-add-and-apply-subsurf.py
import bpy
obj = bpy.context.object
bpy.ops.object.modifier_add(type='SUBSURF')
for mod in obj.modifiers:
if mod.type == "SUBSURF":
obj.modifiers[mod.name].levels = 1
bpy.ops.object.modifier_apply(apply_as='DATA', modifier=mod.name)
View blender-anisotropic-shader.py
# for http://blender.stackexchange.com/questions/32787/example-of-creating-and-setting-a-cycles-material-node-with-the-python-api
import bpy
# get the material
mat = bpy.data.materials['Material']
# get the nodes
nodes = mat.node_tree.nodes
# clear all nodes to start clean
@p2or
p2or / debug.css
Last active Jul 15, 2016
css-debug
View debug.css
* {
background: #000 !important;
color: #0f0 !important;
outline: solid #f00 1px !important;
}
View blender-random-xy-animation.py
import bpy
import random
def random_floats(min, max, size):
return [random.uniform(min, max) for _ in range(size)]
# define a animation length
length = 10
# create a list, which contains 10 random x values
View blender-check-modifiers.py
# for http://blender.stackexchange.com/questions/42080/check-if-active-object-has-a-modifier
# check for specific modifier using any()
print ([m for m in bpy.context.object.modifiers if m.type == "SUBSURF"])
# or as function
def check_modifier(obj, modifier_type):
for modifier in obj.modifiers:
if modifier.type == modifier_type:
return True
You can’t perform that action at this time.