#!BPY """ Name: 'Save Preset...' Blender: 234 Group: 'PresetRDimensions' Tooltip: 'Save current preset as a bpython script' """ __author__ = "Willian Padovani Germano & Matt Ebb" __url__ = ("blender", "elysiun") __version__ = "1.0 09/12/04" __bpydoc__ = """\ This script saves the current render dimensions (Dimensions panel in Blender) as a Blender Python script. Usage: This script gets automatically run, using the 'Save Preset...' option in the presets menu. It saves the data in a bpython script, meaning that you can simply run it to load the preset. It should then be automatically loaded into the presets menu so you can simply choose it from the list, by the name that you saved it as. To appear in the menu, a theme saved with this script must be put in your Blender's scripts dir, that's what happens by default when you save one by yourself. If you don't know where this dir is, running import Blender
print Blender.Get("scriptsdir") on the Text Editor window (use menu or ALT+P to run it) will write the path on the console. Remember to edit your exported theme's source file to put your name and some information on it before sharing it with others. """ # $Id: save_theme.py,v 1.2 2004/11/07 16:31:13 ianwill Exp $ # # -------------------------------------------------------------------------- # save_theme version 2.34 Sep 20, 2004 # Copyright (C) 2004: Willian P. Germano, wgermano _at_ ig.com.br # -------------------------------------------------------------------------- # Released under the Blender Artistic License (BAL): # http://download.blender.org/documentation/html/x21254.html # # The scripts generated by this script are put under Public Domain by # default, but you are free to edit the ones you generate with this script # and change their license to another one of your choice. # -------------------------------------------------------------------------- import Blender from Blender import Scene, Draw from Blender.Window import FileSelector from types import * scn = Scene.GetCurrent() context = scn.getRenderingContext() # default filename: theme's name + '_theme.py' in user's scripts dir: default_presetnamebasic = str(context.imageSizeX()) + 'x' + str(context.imageSizeY()) default_presetname = Blender.Draw.PupStrInput("Name:", default_presetnamebasic, 32) if default_presetname == None: default_presetname = default_presetnamebasic else: # remove quote marks from the name string (used for both filename and bpymenu 'Name' field) default_presetname = default_presetname.replace("""'""",'') default_fname = Blender.Get("scriptsdir") default_fname = Blender.sys.join(default_fname, 'pre_rdim_' + default_presetname + '.py') default_fname = default_fname.replace(' ','_') def write_theme(filename): "Write the current preset as a bpython script" if filename.find('.py', -3) <= 0: filename += '.py' fout = file(filename, "w") fout.write("""#!BPY # \"\"\" # Name: '%s' # Blender: 232 # Group: 'PresetRDimensions' # Tooltip: 'Set a new render dimensions preset' # \"\"\" __%s__ = "????" __%s__ = "1.0" __%s__ = [""] __%s__ = \"\"\"\\ You can edit this section to write something about your script that can be read then with the Scripts Help Browser script in Blender. Remember to also set author, version and possibly url(s) above. You can also define an __email__ tag, check some bundled script's source for examples. \"\"\" # This script was automatically generated by the pre_rdim_save.py bpython script. # By default, these generated scripts are released as Public Domain, but you # are free to change the license of the scripts you generate with # save_theme.py before releasing them. import Blender from Blender import Scene scn = Scene.GetCurrent() context = scn.getRenderingContext() """ % (default_presetname, "author", "version", "url", "bpydoc")) # We do these one by one, since we don't want to save the complete renderdata, # just the relevant ones to render dimensions fout.write("context.imageSizeX(%s)\n" % (context.imageSizeX())) fout.write("context.imageSizeY(%s)\n\n" % (context.imageSizeY())) fout.write("context.aspectRatioX(%s)\n" % (context.aspectRatioX())) fout.write("context.aspectRatioY(%s)\n\n" % (context.aspectRatioY())) fout.write("context.framesPerSec(%s)\n\n" % (context.framesPerSec())) # fout.write("context.enableFieldRendering(%s)\n" % (context.enableFieldRendering())) # fout.write("context.enableFieldTimeDisable(%s)\n" % (context.enableFieldTimeDisable())) # fout.write("context.enableOddFieldFirst(%s)\n" % (context.enableOddFieldFirst())) fout.close() FileSelector(write_theme, "Save Dimensions Preset", default_fname)