- aspectx wasnt saved in the render preset
- define a preset base class - cleanup some comments and whitespace
This commit is contained in:
@@ -41,14 +41,14 @@ sys.stdin = None
|
|||||||
|
|
||||||
def load_scripts(reload_scripts=False):
|
def load_scripts(reload_scripts=False):
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
def test_import(module_name):
|
def test_import(module_name):
|
||||||
try:
|
try:
|
||||||
return __import__(module_name)
|
return __import__(module_name)
|
||||||
except:
|
except:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
base_path = os.path.join(os.path.dirname(__file__), "..", "..")
|
base_path = os.path.join(os.path.dirname(__file__), "..", "..")
|
||||||
base_path = os.path.normpath(base_path) # clean
|
base_path = os.path.normpath(base_path) # clean
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ def load_scripts(reload_scripts=False):
|
|||||||
mod = test_import(f)
|
mod = test_import(f)
|
||||||
else:
|
else:
|
||||||
mod = None
|
mod = None
|
||||||
|
|
||||||
if reload_scripts and mod:
|
if reload_scripts and mod:
|
||||||
print("Reloading:", mod)
|
print("Reloading:", mod)
|
||||||
reload(mod)
|
reload(mod)
|
||||||
@@ -73,10 +73,10 @@ def load_scripts(reload_scripts=False):
|
|||||||
if "-d" in sys.argv and False: # Enable this to measure startup speed
|
if "-d" in sys.argv and False: # Enable this to measure startup speed
|
||||||
import cProfile
|
import cProfile
|
||||||
cProfile.run('import bpy; bpy.load_scripts()', 'blender.prof')
|
cProfile.run('import bpy; bpy.load_scripts()', 'blender.prof')
|
||||||
|
|
||||||
import pstats
|
import pstats
|
||||||
p = pstats.Stats('blender.prof')
|
p = pstats.Stats('blender.prof')
|
||||||
p.sort_stats('cumulative').print_stats(100)
|
p.sort_stats('cumulative').print_stats(100)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
load_scripts()
|
load_scripts()
|
||||||
|
@@ -22,14 +22,14 @@ StructRNA = bpy_types.Struct.__bases__[0]
|
|||||||
|
|
||||||
|
|
||||||
class Context(StructRNA):
|
class Context(StructRNA):
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
new_context = {}
|
new_context = {}
|
||||||
generic_keys = StructRNA.__dict__.keys()
|
generic_keys = StructRNA.__dict__.keys()
|
||||||
for item in dir(self):
|
for item in dir(self):
|
||||||
if item not in generic_keys:
|
if item not in generic_keys:
|
||||||
new_context[item] = getattr(self, item)
|
new_context[item] = getattr(self, item)
|
||||||
|
|
||||||
return new_context
|
return new_context
|
||||||
|
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ def ord_ind(i1,i2):
|
|||||||
return i2,i1
|
return i2,i1
|
||||||
|
|
||||||
class Mesh(bpy_types.ID):
|
class Mesh(bpy_types.ID):
|
||||||
|
|
||||||
def _get_edge_keys(self):
|
def _get_edge_keys(self):
|
||||||
return [edge_key for face in self.faces for edge_key in face.edge_keys]
|
return [edge_key for face in self.faces for edge_key in face.edge_keys]
|
||||||
|
|
||||||
@@ -102,10 +102,9 @@ class OrderedMeta(type):
|
|||||||
def __prepare__(name, bases, **kwargs):
|
def __prepare__(name, bases, **kwargs):
|
||||||
return collections.OrderedDict()
|
return collections.OrderedDict()
|
||||||
|
|
||||||
|
|
||||||
|
# Only defined so operators members can be used by accessing self.order
|
||||||
class Operator(StructRNA, metaclass=OrderedMeta):
|
class Operator(StructRNA, metaclass=OrderedMeta):
|
||||||
'''
|
|
||||||
Only defined so operators members can be used by accessing self.order
|
|
||||||
'''
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@@ -113,12 +112,8 @@ class Menu(StructRNA):
|
|||||||
|
|
||||||
def path_menu(self, searchpath, operator):
|
def path_menu(self, searchpath, operator):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
|
# hard coded to set the operators 'path' to the filename.
|
||||||
|
|
||||||
'''
|
|
||||||
Unrelated to the class above, add menu items from the filesystem.
|
|
||||||
|
|
||||||
hard coded to set the operators 'path' to the filename.
|
|
||||||
'''
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
def path_to_name(f):
|
def path_to_name(f):
|
||||||
|
@@ -32,12 +32,12 @@ def rna_idprop_ui_get(item, create=True):
|
|||||||
|
|
||||||
|
|
||||||
def rna_idprop_ui_prop_get(item, prop, create=True):
|
def rna_idprop_ui_prop_get(item, prop, create=True):
|
||||||
|
|
||||||
rna_ui = rna_idprop_ui_get(item, create)
|
rna_ui = rna_idprop_ui_get(item, create)
|
||||||
|
|
||||||
if rna_ui == None:
|
if rna_ui == None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return rna_ui[prop]
|
return rna_ui[prop]
|
||||||
except:
|
except:
|
||||||
@@ -47,7 +47,7 @@ def rna_idprop_ui_prop_get(item, prop, create=True):
|
|||||||
|
|
||||||
def rna_idprop_ui_prop_clear(item, prop):
|
def rna_idprop_ui_prop_clear(item, prop):
|
||||||
rna_ui = rna_idprop_ui_get(item, False)
|
rna_ui = rna_idprop_ui_get(item, False)
|
||||||
|
|
||||||
if rna_ui == None:
|
if rna_ui == None:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -58,21 +58,21 @@ def rna_idprop_ui_prop_clear(item, prop):
|
|||||||
|
|
||||||
|
|
||||||
def draw(layout, context, context_member, use_edit = True):
|
def draw(layout, context, context_member, use_edit = True):
|
||||||
|
|
||||||
def assign_props(prop, val, key):
|
def assign_props(prop, val, key):
|
||||||
prop.path = context_member
|
prop.path = context_member
|
||||||
prop.property = key
|
prop.property = key
|
||||||
|
|
||||||
try:
|
try:
|
||||||
prop.value = str(val)
|
prop.value = str(val)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
rna_item = eval("context." + context_member)
|
rna_item = eval("context." + context_member)
|
||||||
|
|
||||||
items = rna_item.items()
|
items = rna_item.items()
|
||||||
items.sort()
|
items.sort()
|
||||||
|
|
||||||
if use_edit:
|
if use_edit:
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
props = row.itemO("wm.properties_add", properties=True, text="Add")
|
props = row.itemO("wm.properties_add", properties=True, text="Add")
|
||||||
@@ -83,10 +83,10 @@ def draw(layout, context, context_member, use_edit = True):
|
|||||||
|
|
||||||
if key == '_RNA_UI':
|
if key == '_RNA_UI':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
convert_to_pyobject = getattr(val, "convert_to_pyobject", None)
|
convert_to_pyobject = getattr(val, "convert_to_pyobject", None)
|
||||||
|
|
||||||
val_orig = val
|
val_orig = val
|
||||||
if convert_to_pyobject:
|
if convert_to_pyobject:
|
||||||
val_draw = val = val.convert_to_pyobject()
|
val_draw = val = val.convert_to_pyobject()
|
||||||
@@ -101,23 +101,23 @@ def draw(layout, context, context_member, use_edit = True):
|
|||||||
row = split.row()
|
row = split.row()
|
||||||
else:
|
else:
|
||||||
row = box.row()
|
row = box.row()
|
||||||
|
|
||||||
row.itemL(text=key)
|
row.itemL(text=key)
|
||||||
|
|
||||||
# explicit exception for arrays
|
# explicit exception for arrays
|
||||||
if convert_to_pyobject and not hasattr(val_orig, "len"):
|
if convert_to_pyobject and not hasattr(val_orig, "len"):
|
||||||
row.itemL(text=val_draw)
|
row.itemL(text=val_draw)
|
||||||
else:
|
else:
|
||||||
row.itemR(rna_item, '["%s"]' % key, text="")
|
row.itemR(rna_item, '["%s"]' % key, text="")
|
||||||
|
|
||||||
if use_edit:
|
if use_edit:
|
||||||
row = split.row(align=True)
|
row = split.row(align=True)
|
||||||
prop = row.itemO("wm.properties_edit", properties=True, text="edit")
|
prop = row.itemO("wm.properties_edit", properties=True, text="edit")
|
||||||
assign_props(prop, val_draw, key)
|
assign_props(prop, val_draw, key)
|
||||||
|
|
||||||
prop = row.itemO("wm.properties_remove", properties=True, text="", icon='ICON_ZOOMOUT')
|
prop = row.itemO("wm.properties_remove", properties=True, text="", icon='ICON_ZOOMOUT')
|
||||||
assign_props(prop, val_draw, key)
|
assign_props(prop, val_draw, key)
|
||||||
|
|
||||||
|
|
||||||
from bpy.props import *
|
from bpy.props import *
|
||||||
|
|
||||||
@@ -138,14 +138,14 @@ class WM_OT_properties_edit(bpy.types.Operator):
|
|||||||
'''Internal use (edit a property path)'''
|
'''Internal use (edit a property path)'''
|
||||||
bl_idname = "wm.properties_edit"
|
bl_idname = "wm.properties_edit"
|
||||||
bl_label = "Edit Property!"
|
bl_label = "Edit Property!"
|
||||||
|
|
||||||
path = rna_path
|
path = rna_path
|
||||||
property = rna_property
|
property = rna_property
|
||||||
value = rna_value
|
value = rna_value
|
||||||
min = rna_min
|
min = rna_min
|
||||||
max = rna_max
|
max = rna_max
|
||||||
description = StringProperty(name="Tip", default="")
|
description = StringProperty(name="Tip", default="")
|
||||||
|
|
||||||
# the class instance is not persistant, need to store in the class
|
# the class instance is not persistant, need to store in the class
|
||||||
# not ideal but changes as the op runs.
|
# not ideal but changes as the op runs.
|
||||||
_last_prop = ['']
|
_last_prop = ['']
|
||||||
@@ -160,72 +160,72 @@ class WM_OT_properties_edit(bpy.types.Operator):
|
|||||||
value_eval = eval(value)
|
value_eval = eval(value)
|
||||||
except:
|
except:
|
||||||
value_eval = value
|
value_eval = value
|
||||||
|
|
||||||
if type(value_eval) == str:
|
if type(value_eval) == str:
|
||||||
value_eval = '"' + value_eval + '"'
|
value_eval = '"' + value_eval + '"'
|
||||||
|
|
||||||
# First remove
|
# First remove
|
||||||
item = eval("context.%s" % path)
|
item = eval("context.%s" % path)
|
||||||
|
|
||||||
rna_idprop_ui_prop_clear(item, prop_old)
|
rna_idprop_ui_prop_clear(item, prop_old)
|
||||||
exec_str = "del item['%s']" % prop_old
|
exec_str = "del item['%s']" % prop_old
|
||||||
# print(exec_str)
|
# print(exec_str)
|
||||||
exec(exec_str)
|
exec(exec_str)
|
||||||
|
|
||||||
|
|
||||||
# Reassign
|
# Reassign
|
||||||
exec_str = "item['%s'] = %s" % (prop, value_eval)
|
exec_str = "item['%s'] = %s" % (prop, value_eval)
|
||||||
# print(exec_str)
|
# print(exec_str)
|
||||||
exec(exec_str)
|
exec(exec_str)
|
||||||
|
|
||||||
prop_type = type(item[prop])
|
prop_type = type(item[prop])
|
||||||
|
|
||||||
prop_ui = rna_idprop_ui_prop_get(item, prop)
|
prop_ui = rna_idprop_ui_prop_get(item, prop)
|
||||||
|
|
||||||
if prop_type in (float, int):
|
if prop_type in (float, int):
|
||||||
|
|
||||||
prop_ui['soft_min'] = prop_ui['min'] = prop_type(self.properties.min)
|
prop_ui['soft_min'] = prop_ui['min'] = prop_type(self.properties.min)
|
||||||
prop_ui['soft_max'] = prop_ui['max'] = prop_type(self.properties.max)
|
prop_ui['soft_max'] = prop_ui['max'] = prop_type(self.properties.max)
|
||||||
|
|
||||||
prop_ui['description'] = self.properties.description
|
prop_ui['description'] = self.properties.description
|
||||||
|
|
||||||
return ('FINISHED',)
|
return ('FINISHED',)
|
||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
|
|
||||||
self._last_prop[:] = [self.properties.property]
|
self._last_prop[:] = [self.properties.property]
|
||||||
|
|
||||||
item = eval("context.%s" % self.properties.path)
|
item = eval("context.%s" % self.properties.path)
|
||||||
|
|
||||||
# setup defaults
|
# setup defaults
|
||||||
prop_ui = rna_idprop_ui_prop_get(item, self.properties.property, False) # dont create
|
prop_ui = rna_idprop_ui_prop_get(item, self.properties.property, False) # dont create
|
||||||
if prop_ui:
|
if prop_ui:
|
||||||
self.properties.min = prop_ui.get("min", -1000000000)
|
self.properties.min = prop_ui.get("min", -1000000000)
|
||||||
self.properties.max = prop_ui.get("max", 1000000000)
|
self.properties.max = prop_ui.get("max", 1000000000)
|
||||||
self.properties.description = prop_ui.get("description", "")
|
self.properties.description = prop_ui.get("description", "")
|
||||||
|
|
||||||
if 0:
|
if 0:
|
||||||
_message= "PyConsole, press Ctrl+D to unlock the BGE"
|
_message= "PyConsole, press Ctrl+D to unlock the BGE"
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
# evaluate commands in current namespace
|
# evaluate commands in current namespace
|
||||||
frame= sys._getframe()
|
frame= sys._getframe()
|
||||||
namespace = frame.f_globals.copy()
|
namespace = frame.f_globals.copy()
|
||||||
namespace.update(frame.f_locals)
|
namespace.update(frame.f_locals)
|
||||||
|
|
||||||
import code
|
import code
|
||||||
|
|
||||||
# Autocomp in python, not as comprehensive as IPython
|
# Autocomp in python, not as comprehensive as IPython
|
||||||
import rlcompleter
|
import rlcompleter
|
||||||
|
|
||||||
try: # ick, some pythons dont have this
|
try: # ick, some pythons dont have this
|
||||||
import readline
|
import readline
|
||||||
readline.parse_and_bind("tab: complete")
|
readline.parse_and_bind("tab: complete")
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
code.interact(banner=_message, local=namespace)
|
code.interact(banner=_message, local=namespace)
|
||||||
|
|
||||||
wm = context.manager
|
wm = context.manager
|
||||||
wm.invoke_props_popup(self, event)
|
wm.invoke_props_popup(self, event)
|
||||||
return ('RUNNING_MODAL',)
|
return ('RUNNING_MODAL',)
|
||||||
@@ -240,7 +240,7 @@ class WM_OT_properties_add(bpy.types.Operator):
|
|||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
item = eval("context.%s" % self.properties.path)
|
item = eval("context.%s" % self.properties.path)
|
||||||
|
|
||||||
def unique_name(names):
|
def unique_name(names):
|
||||||
prop = 'prop'
|
prop = 'prop'
|
||||||
prop_new = prop
|
prop_new = prop
|
||||||
@@ -248,14 +248,14 @@ class WM_OT_properties_add(bpy.types.Operator):
|
|||||||
while prop_new in names:
|
while prop_new in names:
|
||||||
prop_new = prop + str(i)
|
prop_new = prop + str(i)
|
||||||
i+=1
|
i+=1
|
||||||
|
|
||||||
return prop_new
|
return prop_new
|
||||||
|
|
||||||
property = unique_name(item.keys())
|
property = unique_name(item.keys())
|
||||||
|
|
||||||
item[property] = 1.0
|
item[property] = 1.0
|
||||||
return ('FINISHED',)
|
return ('FINISHED',)
|
||||||
|
|
||||||
class WM_OT_properties_remove(bpy.types.Operator):
|
class WM_OT_properties_remove(bpy.types.Operator):
|
||||||
'''Internal use (edit a property path)'''
|
'''Internal use (edit a property path)'''
|
||||||
bl_idname = "wm.properties_remove"
|
bl_idname = "wm.properties_remove"
|
||||||
@@ -267,5 +267,5 @@ class WM_OT_properties_remove(bpy.types.Operator):
|
|||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
item = eval("context.%s" % self.properties.path)
|
item = eval("context.%s" % self.properties.path)
|
||||||
del item[self.properties.property]
|
del item[self.properties.property]
|
||||||
return ('FINISHED',)
|
return ('FINISHED',)
|
||||||
|
|
||||||
|
@@ -142,7 +142,7 @@ def autocomplete(context):
|
|||||||
sc = context.space_data
|
sc = context.space_data
|
||||||
|
|
||||||
console = get_console(hash(context.region))[0]
|
console = get_console(hash(context.region))[0]
|
||||||
|
|
||||||
current_line = sc.history[-1]
|
current_line = sc.history[-1]
|
||||||
line = current_line.line
|
line = current_line.line
|
||||||
|
|
||||||
|
@@ -51,11 +51,11 @@ def execute(context):
|
|||||||
line = sc.history[-1].line
|
line = sc.history[-1].line
|
||||||
except:
|
except:
|
||||||
return ('CANCELLED',)
|
return ('CANCELLED',)
|
||||||
|
|
||||||
bpy.ops.console.scrollback_append(text=sc.prompt + line, type='INPUT')
|
bpy.ops.console.scrollback_append(text=sc.prompt + line, type='INPUT')
|
||||||
|
|
||||||
shell_run(line)
|
shell_run(line)
|
||||||
|
|
||||||
# insert a new blank line
|
# insert a new blank line
|
||||||
bpy.ops.console.history_append(text="", current_character=0,
|
bpy.ops.console.history_append(text="", current_character=0,
|
||||||
remove_duplicates=True)
|
remove_duplicates=True)
|
||||||
@@ -72,7 +72,7 @@ def autocomplete(context):
|
|||||||
|
|
||||||
def banner(context):
|
def banner(context):
|
||||||
sc = context.space_data
|
sc = context.space_data
|
||||||
|
|
||||||
shell_run("bash --version")
|
shell_run("bash --version")
|
||||||
sc.prompt = os.getcwd()+PROMPT
|
sc.prompt = os.getcwd()+PROMPT
|
||||||
|
|
||||||
|
@@ -4,12 +4,12 @@
|
|||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software Foundation,
|
# along with this program; if not, write to the Free Software Foundation,
|
||||||
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
@@ -26,12 +26,12 @@ def main(context):
|
|||||||
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
|
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
|
||||||
|
|
||||||
mesh = ob.data
|
mesh = ob.data
|
||||||
|
|
||||||
face_list = [face for face in mesh.faces]
|
face_list = [face for face in mesh.faces]
|
||||||
face_edge_keys = [face.edge_keys for face in face_list]
|
face_edge_keys = [face.edge_keys for face in face_list]
|
||||||
|
|
||||||
edge_face_count = mesh.edge_face_count_dict
|
edge_face_count = mesh.edge_face_count_dict
|
||||||
|
|
||||||
def test_interior(index):
|
def test_interior(index):
|
||||||
for key in face_edge_keys[index]:
|
for key in face_edge_keys[index]:
|
||||||
if edge_face_count[key] < 3:
|
if edge_face_count[key] < 3:
|
||||||
|
@@ -19,47 +19,28 @@
|
|||||||
import bpy
|
import bpy
|
||||||
import os
|
import os
|
||||||
|
|
||||||
class AddPreset(bpy.types.Operator):
|
from wm import AddPresetBase
|
||||||
'''Add a Render Preset'''
|
|
||||||
|
|
||||||
|
class AddPresetRender(AddPresetBase):
|
||||||
bl_idname = "render.preset_add"
|
bl_idname = "render.preset_add"
|
||||||
bl_label = "Add Render Preset"
|
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")
|
name = AddPresetBase.name
|
||||||
|
|
||||||
_preset_values = [
|
preset_values = [
|
||||||
"bpy.context.scene.render_data.resolution_x",
|
"bpy.context.scene.render_data.resolution_x",
|
||||||
"bpy.context.scene.render_data.resolution_y",
|
"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.pixel_aspect_x",
|
"bpy.context.scene.render_data.pixel_aspect_y",
|
||||||
"bpy.context.scene.render_data.fps",
|
"bpy.context.scene.render_data.fps",
|
||||||
"bpy.context.scene.render_data.fps_base",
|
"bpy.context.scene.render_data.fps_base",
|
||||||
"bpy.context.scene.render_data.resolution_percentage",
|
"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):
|
preset_path = os.path.join("presets", "render")
|
||||||
filename = self._as_filename(self.properties.name) + ".py"
|
|
||||||
|
|
||||||
target_path = os.path.join(os.path.dirname(__file__), os.path.pardir, "presets", "render", filename)
|
bpy.ops.add(AddPresetRender)
|
||||||
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)
|
|
||||||
|
@@ -175,4 +175,4 @@ class VertexPaintDirt(bpy.types.Operator):
|
|||||||
bpy.ops.add(VertexPaintDirt)
|
bpy.ops.add(VertexPaintDirt)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
bpy.ops.mesh.vertex_paint_dirt()
|
bpy.ops.mesh.vertex_paint_dirt()
|
||||||
|
@@ -4,12 +4,12 @@
|
|||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software Foundation,
|
# along with this program; if not, write to the Free Software Foundation,
|
||||||
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
# <pep8-80 compliant>
|
# <pep8-80 compliant>
|
||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
|
import os
|
||||||
|
|
||||||
from bpy.props import *
|
from bpy.props import *
|
||||||
|
|
||||||
@@ -391,6 +392,54 @@ class WM_OT_reload_scripts(bpy.types.Operator):
|
|||||||
'''
|
'''
|
||||||
return ('FINISHED',)
|
return ('FINISHED',)
|
||||||
|
|
||||||
|
class AddPresetBase(bpy.types.Operator):
|
||||||
|
'''Base preset class, only for subclassing
|
||||||
|
subclasses must define
|
||||||
|
- preset_values
|
||||||
|
- preset_path '''
|
||||||
|
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_y",
|
||||||
|
"bpy.context.scene.render_data.fps",
|
||||||
|
"bpy.context.scene.render_data.fps_base",
|
||||||
|
"bpy.context.scene.render_data.resolution_percentage",
|
||||||
|
]
|
||||||
|
|
||||||
|
preset_path = os.path.join("presets", "render")
|
||||||
|
'''
|
||||||
|
|
||||||
|
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, self.preset_path, filename)
|
||||||
|
|
||||||
|
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(MESH_OT_delete_edgeloop)
|
bpy.ops.add(MESH_OT_delete_edgeloop)
|
||||||
|
|
||||||
bpy.ops.add(WM_OT_context_set_boolean)
|
bpy.ops.add(WM_OT_context_set_boolean)
|
||||||
|
Reference in New Issue
Block a user