forked from bartvdbraak/blender
render presets, select from a directory, button to add own presets
This commit is contained in:
parent
d875f4927e
commit
5e7debcecf
@ -107,3 +107,43 @@ class Operator(StructRNA, metaclass=OrderedMeta):
|
|||||||
Only defined so operators members can be used by accessing self.order
|
Only defined so operators members can be used by accessing self.order
|
||||||
'''
|
'''
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Menu(StructRNA):
|
||||||
|
|
||||||
|
def path_menu(self, searchpath, operator):
|
||||||
|
layout = self.layout
|
||||||
|
|
||||||
|
'''
|
||||||
|
Unrelated to the class above, add menu items from the filesystem.
|
||||||
|
|
||||||
|
hard coded to set the operators 'path' to the filename.
|
||||||
|
'''
|
||||||
|
import os
|
||||||
|
|
||||||
|
def path_to_name(f):
|
||||||
|
''' Only capitalize all lowercase names, mixed case use them as is.
|
||||||
|
'''
|
||||||
|
f_base = os.path.splitext(f)[0]
|
||||||
|
|
||||||
|
# string replacements
|
||||||
|
f_base = f_base.replace("_colon_", ":")
|
||||||
|
|
||||||
|
f_base = f_base.replace("_", " ")
|
||||||
|
|
||||||
|
if f_base.lower() == f_base:
|
||||||
|
return ' '.join([w[0].upper() + w[1:] for w in f_base.split()])
|
||||||
|
else:
|
||||||
|
return f_base
|
||||||
|
|
||||||
|
layout = self.layout
|
||||||
|
|
||||||
|
for f in sorted(os.listdir(searchpath)):
|
||||||
|
|
||||||
|
if f.startswith("."):
|
||||||
|
continue
|
||||||
|
|
||||||
|
path = os.path.join(searchpath, f)
|
||||||
|
path = os.path.normpath(path)
|
||||||
|
layout.item_stringO(operator, "path", path, text=path_to_name(f))
|
||||||
|
|
||||||
|
@ -109,5 +109,3 @@ DynMenu.add = add
|
|||||||
# dont ever use this directly!
|
# dont ever use this directly!
|
||||||
bpy.types.register(DynMenu)
|
bpy.types.register(DynMenu)
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
66
release/scripts/op/render.py
Normal file
66
release/scripts/op/render.py
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
# ##### 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
# ##### END GPL LICENSE BLOCK #####
|
||||||
|
|
||||||
|
import bpy
|
||||||
|
import os
|
||||||
|
|
||||||
|
class AddPreset(bpy.types.Operator):
|
||||||
|
'''Add a torus mesh.'''
|
||||||
|
bl_idname = "render.preset_add"
|
||||||
|
bl_label = "Add Render Preset"
|
||||||
|
|
||||||
|
name = bpy.props.StringProperty(name="Name", description="Name of the preset, used to make the path name", maxlen= 64, default= "New Preset")
|
||||||
|
|
||||||
|
_preset_values = [
|
||||||
|
"bpy.context.scene.render_data.resolution_x",
|
||||||
|
"bpy.context.scene.render_data.resolution_y",
|
||||||
|
"bpy.context.scene.render_data.pixel_aspect_x",
|
||||||
|
"bpy.context.scene.render_data.pixel_aspect_x",
|
||||||
|
"bpy.context.scene.render_data.fps",
|
||||||
|
"bpy.context.scene.render_data.fps_base",
|
||||||
|
"bpy.context.scene.render_data.resolution_percentage",
|
||||||
|
]
|
||||||
|
|
||||||
|
_last_preset = "" # hack to avoid remaking
|
||||||
|
|
||||||
|
def _as_filename(self, name): # could reuse for other presets
|
||||||
|
for char in " !@#$%^&*(){}:\";'[]<>,./?":
|
||||||
|
name = name.replace('.', '_')
|
||||||
|
return name.lower()
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
|
||||||
|
filename = self._as_filename(self.properties.name) + ".py"
|
||||||
|
|
||||||
|
target_path = os.path.join(os.path.dirname(__file__), os.path.pardir, "presets", "render", filename)
|
||||||
|
print(target_path)
|
||||||
|
file_preset = open(target_path, 'w')
|
||||||
|
|
||||||
|
for rna_path in self._preset_values:
|
||||||
|
file_preset.write("%s = %s\n" % (rna_path, eval(rna_path)))
|
||||||
|
|
||||||
|
file_preset.close()
|
||||||
|
|
||||||
|
return ('FINISHED',)
|
||||||
|
|
||||||
|
def invoke(self, context, event):
|
||||||
|
wm = context.manager
|
||||||
|
wm.invoke_props_popup(self, event)
|
||||||
|
return ('RUNNING_MODAL',)
|
||||||
|
|
||||||
|
bpy.ops.add(AddPreset)
|
5
release/scripts/presets/render/HDTV_1080p.py
Normal file
5
release/scripts/presets/render/HDTV_1080p.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
bpy.context.scene.render_data.resolution_x = 1920
|
||||||
|
bpy.context.scene.render_data.resolution_y = 1080
|
||||||
|
bpy.context.scene.render_data.resolution_percentage = 100
|
||||||
|
bpy.context.scene.render_data.pixel_aspect_x = 1
|
||||||
|
bpy.context.scene.render_data.pixel_aspect_y = 1
|
5
release/scripts/presets/render/HDTV_720p.py
Normal file
5
release/scripts/presets/render/HDTV_720p.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
bpy.context.scene.render_data.resolution_x = 1280
|
||||||
|
bpy.context.scene.render_data.resolution_y = 720
|
||||||
|
bpy.context.scene.render_data.resolution_percentage = 100
|
||||||
|
bpy.context.scene.render_data.pixel_aspect_x = 1
|
||||||
|
bpy.context.scene.render_data.pixel_aspect_y = 1
|
7
release/scripts/presets/render/TV_NTSC.py
Normal file
7
release/scripts/presets/render/TV_NTSC.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
bpy.context.scene.render_data.resolution_x = 720
|
||||||
|
bpy.context.scene.render_data.resolution_y = 480
|
||||||
|
bpy.context.scene.render_data.resolution_percentage = 100
|
||||||
|
bpy.context.scene.render_data.pixel_aspect_x = 10
|
||||||
|
bpy.context.scene.render_data.pixel_aspect_y = 11
|
||||||
|
bpy.context.scene.render_data.fps = 30
|
||||||
|
bpy.context.scene.render_data.fps_base = 1.001
|
6
release/scripts/presets/render/TV_PAL.py
Normal file
6
release/scripts/presets/render/TV_PAL.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
bpy.context.scene.render_data.resolution_x = 720
|
||||||
|
bpy.context.scene.render_data.resolution_y = 576
|
||||||
|
bpy.context.scene.render_data.resolution_percentage = 100
|
||||||
|
bpy.context.scene.render_data.pixel_aspect_x = 54
|
||||||
|
bpy.context.scene.render_data.pixel_aspect_y = 51
|
||||||
|
bpy.context.scene.render_data.fps = 25
|
6
release/scripts/presets/render/TV_PAL_16_colon_9.py
Normal file
6
release/scripts/presets/render/TV_PAL_16_colon_9.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
bpy.context.scene.render_data.resolution_x = 720
|
||||||
|
bpy.context.scene.render_data.resolution_y = 576
|
||||||
|
bpy.context.scene.render_data.resolution_percentage = 100
|
||||||
|
bpy.context.scene.render_data.pixel_aspect_x = 64
|
||||||
|
bpy.context.scene.render_data.pixel_aspect_y = 45
|
||||||
|
bpy.context.scene.render_data.fps = 25
|
@ -22,6 +22,18 @@ import bpy
|
|||||||
narrowui = 180
|
narrowui = 180
|
||||||
|
|
||||||
|
|
||||||
|
class RENDER_MT_presets(bpy.types.Menu):
|
||||||
|
'''
|
||||||
|
Creates the menu items by scanning scripts/templates
|
||||||
|
'''
|
||||||
|
bl_label = "Render Presets"
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
import os
|
||||||
|
template_dir = os.path.join(os.path.dirname(__file__), os.path.pardir, "presets", "render")
|
||||||
|
self.path_menu(template_dir, "script.python_file_run")
|
||||||
|
|
||||||
|
|
||||||
class RenderButtonsPanel(bpy.types.Panel):
|
class RenderButtonsPanel(bpy.types.Panel):
|
||||||
bl_space_type = 'PROPERTIES'
|
bl_space_type = 'PROPERTIES'
|
||||||
bl_region_type = 'WINDOW'
|
bl_region_type = 'WINDOW'
|
||||||
@ -502,6 +514,11 @@ class RENDER_PT_dimensions(RenderButtonsPanel):
|
|||||||
sub.itemR(rd, "fps")
|
sub.itemR(rd, "fps")
|
||||||
sub.itemR(rd, "fps_base", text="/")
|
sub.itemR(rd, "fps_base", text="/")
|
||||||
|
|
||||||
|
sub = col.split(percentage=0.75)
|
||||||
|
sub.itemM("RENDER_MT_presets", text="Presets")
|
||||||
|
sub.itemO("render.preset_add", text="Add")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class RENDER_PT_stamp(RenderButtonsPanel):
|
class RENDER_PT_stamp(RenderButtonsPanel):
|
||||||
bl_label = "Stamp"
|
bl_label = "Stamp"
|
||||||
@ -548,6 +565,9 @@ class RENDER_PT_stamp(RenderButtonsPanel):
|
|||||||
sub.active = rd.stamp_note
|
sub.active = rd.stamp_note
|
||||||
sub.itemR(rd, "stamp_note_text", text="")
|
sub.itemR(rd, "stamp_note_text", text="")
|
||||||
|
|
||||||
|
|
||||||
|
bpy.types.register(RENDER_MT_presets)
|
||||||
|
|
||||||
bpy.types.register(RENDER_PT_render)
|
bpy.types.register(RENDER_PT_render)
|
||||||
bpy.types.register(RENDER_PT_layers)
|
bpy.types.register(RENDER_PT_layers)
|
||||||
bpy.types.register(RENDER_PT_dimensions)
|
bpy.types.register(RENDER_PT_dimensions)
|
||||||
|
@ -177,22 +177,8 @@ class TEXT_MT_templates(bpy.types.Menu):
|
|||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
import os
|
import os
|
||||||
|
|
||||||
def path_to_name(f):
|
|
||||||
f_base = os.path.splitext(f)[0]
|
|
||||||
f_base = f_base.replace("_", " ")
|
|
||||||
return ' '.join([w[0].upper() + w[1:] for w in f_base.split()])
|
|
||||||
|
|
||||||
layout = self.layout
|
|
||||||
template_dir = os.path.join(os.path.dirname(__file__), os.path.pardir, "templates")
|
template_dir = os.path.join(os.path.dirname(__file__), os.path.pardir, "templates")
|
||||||
|
self.path_menu(template_dir, "text.open")
|
||||||
for f in sorted(os.listdir(template_dir)):
|
|
||||||
|
|
||||||
if f.startswith("."):
|
|
||||||
continue
|
|
||||||
|
|
||||||
path = os.path.join(template_dir, f)
|
|
||||||
layout.item_stringO("text.open", "path", path, text=path_to_name(f))
|
|
||||||
|
|
||||||
|
|
||||||
class TEXT_MT_edit_view(bpy.types.Menu):
|
class TEXT_MT_edit_view(bpy.types.Menu):
|
||||||
|
Loading…
Reference in New Issue
Block a user