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 blender-basic-ui-example-28x.py
# https://blender.stackexchange.com/q/57306/3710
bl_info = {
"name": "Add-on Template",
"description": "",
"author": "p2or",
"version": (0, 0, 3),
"blender": (2, 80, 0),
"location": "3D View > Tools",
"warning": "", # used for warning icon and text in addons panel
View blender-basic-ui-example.py
# https://blender.stackexchange.com/q/57306/3710
# https://blender.stackexchange.com/q/79779/3710
bl_info = {
"name": "Add-on Template",
"description": "",
"author": "",
"version": (0, 0, 2),
"blender": (2, 70, 0),
"location": "3D View > Tools",
View blender-render-version.py
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
View houdini-flipbooks.py
custom_range = (0,10)
filename = "~/flipbook/flip_$F4.png"
cur_desktop = hou.ui.curDesktop()
scene = cur_desktop.paneTabOfType(hou.paneTabType.SceneViewer)
flip_options = scene.flipbookSettings().stash()
flip_options.frameRange(custom_range)
flip_options.output(filename)
scene.flipbook(scene.curViewport(), flip_options)
@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)
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
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
View nodes_cycles_resetnode.py
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
You can’t perform that action at this time.