Skip to content

Instantly share code, notes, and snippets.

@JT-a
Last active December 14, 2015 13:48
Show Gist options
  • Save JT-a/5095624 to your computer and use it in GitHub Desktop.
Save JT-a/5095624 to your computer and use it in GitHub Desktop.
Blender Python addon for a separate Render Test settings panel
# ##### 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
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
bl_info = {
"name": "Render Test",
"author": "JTa with help from FergusL & Intracube",
"version": (0, 1),
"blender": (2, 66, 0),
"location": "Properties > Render > Render Test",
"description": "This script, applies a temporary material to all objects"\
" of the scene.",
"wiki_url": "",
"tracker_url": "", "category": ""}
# Render Test - rough draft 0.1.3a, UI only at this point...
import bpy
from bpy.props import *
#Setup Radio Button Enum Props
bpy.types.Scene.rtSizeEnum = bpy.props.EnumProperty( \
items = [('Half', 'Half', 'Half the size of the render rez'),\
('Quarter', 'Quarter', 'Quarter the size of the render rez'),\
('Thumbnail', 'Thumbnail', 'Thumbnail size of the render rez')],\
name = 'trSize', default = 'Quarter')
class RenderTestPanel(bpy.types.Panel):
bl_label = "Render Test"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "render"
def draw(self, context):
layout = self.layout
scn = bpy.context.scene
rd = scn.render
# Size selection
row = layout.row()
row.label(text="Reduce resolution to:")
row = layout.row(align=True)
row.alignment = 'EXPAND'
layout.row().prop(context.scene,'rtSizeEnum', expand=True)
# draw ui, grab a copy of x/y rez and % then populate my adjusters via radio button setting
# dynamically change then when radio button is pressed
split = layout.split()
col = split.column()
sub = col.column(align=True)
sub.label(text="Resolution:")
sub.prop(rd, "resolution_x", text="X")
sub.prop(rd, "resolution_y", text="Y")
sub.prop(rd, "resolution_percentage", text="")
# Segment range set, default all
# grab default segment range and copy, allowing change for rt
layout.label(text="Segment Range:")
row = layout.row(align=True)
row.prop(scn, "frame_start")
row.prop(scn, "frame_end")
# Call render
row = layout.row()
#row.operator( "render.render" )
row.operator( "bpt.render_test_op" )
#if context.scene.rtSizeEnum == 'Half':
class RenderTestOperator(bpy.types.Operator):
bl_idname = "bpt.render_test_op"
bl_label = "Render Test"
def execute(self, context):
self.report({'INFO'}, "Test Render initiated! ")
print(context.scene.rtSizeEnum)
# quick outline of new code to add
# copy actual render settings including path, we may want to override this to a RAMdisk and eventually RAM/VSE
# maybe setup for linux only and RAMdisks?
# substute render test settings, add filename to output edit box
# run render routine below
# restore original settings, have a full proof incase of oopse or cancel
# additional features to add after this, every 10th frame toggle, all|current layer selection
#bpy.ops.render.view_show()
# NOTE: set output path edit box with a filename other wise it will write .png as a hidden file
#scn = bpy.context.window.screen.scene
#bpy.ops.render.render(animation=False, write_still=True, layer="", scene=scn.name)
#bpy.ops.render.view_show()
# below works also all filled in...
# this works w/o setting context, but you must put in a filename, otherwise the file is .png and hidden
bpy.ops.render.render(animation=False, write_still=True, layer="", scene="")
return {'FINISHED'}
def register():
bpy.utils.register_class( RenderTestPanel )
bpy.utils.register_class( RenderTestOperator )
def unregister():
bpy.utils.register_class( RenderTestPanel )
bpy.utils.register_class( RenderTestOperator )
if __name__ == "__main__":
register()
@JT-a
Copy link
Author

JT-a commented Mar 6, 2013

Ferg made me do it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment