Skip to content

Instantly share code, notes, and snippets.

@p2or
p2or / blender-supressOperatorOutput-II.py
Last active May 22, 2023 14:08
Supress Operator output II #Blender #BSE
# for http://blender.stackexchange.com/questions/56087/check-if-an-operation-can-be-applied-without-runtime-errors
import bpy
if bpy.ops.mesh.fill_grid.poll():
print("correct context")
try:
bpy.ops.mesh.fill_grid()
except RuntimeError as exception:
@p2or
p2or / blender-snippetsystem.py
Last active May 21, 2023 18:20
SnippedSystem #Blender
# for https://blenderartists.org/forum/showthread.php?312819-Snippet-System-for-Text-Editor
bl_info = {
"name": "Snippet System for Text Editor",
"author": "CoDEmanX, poor",
"version": (1, 0, 1),
"blender": (2, 75, 0),
"location": "Text Editor (> Templates) > Snippets",
"description": "Create snippets from text selection easily",
"warning": "",
@p2or
p2or / blender-importMultipleObjsParent.py
Created July 15, 2016 15:07
IO - Batch import obj and parent to null #Blender
# ##### 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
@p2or
p2or / blender-expand-enum.py
Last active May 22, 2023 16:11
UI - Expand Enum #Blender #BSE
# for http://blender.stackexchange.com/questions/58171/how-to-create-a-boolean-vector-property-that-is-single-selection
bl_info = {
"name": "Add-on Template",
"description": "",
"author": "",
"version": (0, 0, 1),
"blender": (2, 70, 0),
"location": "3D View > Tools",
"warning": "", # used for warning icon and text in addons panel
@p2or
p2or / cpp2011.sublime-build
Created July 21, 2016 16:56
Sublime Build #Cpp
{
"cmd": ["g++", "-std=c++0x", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[
{
"name": "Run",
"cmd":["bash", "-c", "g++ -std=c++0x '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
@p2or
p2or / blender-custom-scene-duplication.py
Last active May 21, 2023 18:37
Custom scene duplication #Blender
bl_info = {
"name": "Duplicate Scene",
"description": "",
"author": "poor",
"version": (0, 0, 1),
"blender": (2, 70, 0),
"location": "3D View > Spacebar > Duplicate Scene",
"category": "3D View"
}
@p2or
p2or / blender-custom-toggle-shortcut.py
Last active May 22, 2023 16:11
Custom Shortcut Toggle #Blender #BSE
# for http://blender.stackexchange.com/questions/58486/add-toggle-hotkey-to-custom-checkbox
bl_info = {
"name": "Add-on Template",
"description": "",
"author": "poor",
"version": (0, 0, 2),
"blender": (2, 70, 0),
"location": "3D View > Tools",
"warning": "", # used for warning icon and text in addons panel
@p2or
p2or / print_github_bitbucket.js
Created July 24, 2016 19:27 — forked from markov00/print_github_bitbucket.js
Github print styling #Bookmarlet
javascript:void%20function(){(function(e,o,i,a,n,r,t,d){(!(n=e.jQuery)||i%3En.fn.jquery||a(n))%26%26(r=o.createElement(%22script%22),r.type=%22text/javascript%22,r.src=%22http://ajax.googleapis.com/ajax/libs/jquery/%22+i+%22/jquery.min.js%22,r.onload=r.onreadystatechange=function(){t||(d=this.readyState)%26%26%22loaded%22!=d%26%26%22complete%22!=d||(a((n=e.jQuery).noConflict(1),t=1),n(r).remove())},o.documentElement.childNodes[0].appendChild(r))})(window,document,%221.3.2%22,function(e,o){e(%22%23header,%20.header,.gh-header-actions,.repo-nav,.site-footer,%20.pagehead,%20.breadcrumb,%20.commit,%20.meta,%20%23footer,%20%23footer-push,%23wiki-rightbar%22).remove(),e(%22%23files,%20.file%22).css({background:%22none%22,border:%22none%22}),e(%22.aui-group,.aui-sidebar,.aui-header,%23wiki%20header,footer,.revision-date%22).css({display:%22none%22}),e(%22%23wiki%20.wiki-content%22).css({border:%22none%22,overflow:%22hidden%22}),e(%22.aui-page-panel%22).css({%22padding-left%22:0}),e(%22link%22).removeAttr(%22media%22
@p2or
p2or / blender-operator-catch-error-and-report.py
Last active May 21, 2023 18:38
Catch operator error report #Blender
# http://blender.stackexchange.com/q/63347/3710
import bpy
class CustomDissolveEdgeOperator(bpy.types.Operator):
bl_idname = 'custom.dissolve_edges'
bl_label = 'Custom Edge Dissolve'
bl_options = {'REGISTER', 'UNDO'}
'''
@p2or
p2or / blender-access-pixel-data-of-movie-clip.py
Last active May 21, 2023 18:18
Operator example which inverts the red channel of certain frames in the UV/Image Editor #Blender
# http://blender.stackexchange.com/q/63561 and http://blender.stackexchange.com/q/3527
import bpy
import os
# format integer with leading zeros
def format_numbers(number, length):
return '_%0*d' % (length, number)
def create_image_and_save_as_jpg(pixels, clp_name, clp_size, clp_frame):