[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3737] contrib/py/scripts/addons/ quickPrefs.py: Moving quickprefs addon to contrib
Sean Olson
shatter98 at hotmail.com
Thu Sep 13 02:26:49 CEST 2012
Revision: 3737
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3737
Author: liquidape
Date: 2012-09-13 00:26:48 +0000 (Thu, 13 Sep 2012)
Log Message:
-----------
Moving quickprefs addon to contrib
Added Paths:
-----------
contrib/py/scripts/addons/quickPrefs.py
Added: contrib/py/scripts/addons/quickPrefs.py
===================================================================
--- contrib/py/scripts/addons/quickPrefs.py (rev 0)
+++ contrib/py/scripts/addons/quickPrefs.py 2012-09-13 00:26:48 UTC (rev 3737)
@@ -0,0 +1,885 @@
+# ##### 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": "QuickPrefs",
+ "author": "Sean Olson",
+ "version": (2,1),
+ "blender": (2, 6, 4),
+ "api": 50515,
+ "location": "3DView->Properties Panel (N-Key)",
+ "description": "Add often changed User Preference options to Properties panel.",
+ "warning": "",
+ "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/3D_interaction/QuickPrefs",
+ "tracker_url": "http://projects.blender.org/tracker/index.php?func=detail&aid=27822&group_id=153&atid=467",
+ "category": "3D View"}
+
+import os
+
+import bpy
+from bpy.types import Menu, Panel
+from rna_prop_ui import PropertyPanel
+from bpy.app.handlers import persistent
+
+import bpy_extras
+
+#Global Variables
+recursive = False
+renaming = True
+lastindex = 0
+lastname = ""
+debug = 0
+defaultfilepath=os.path.join(bpy.utils.script_paths(subdir="addons")[0], "quickprefpresets")
+
+
+##########################################
+####### Import/Export Functions ##########
+##########################################
+
+#import all grabs all files in the given directory and imports them
+ at persistent
+def gllightpreset_importall():
+ path = bpy.context.scene.gllightpreset_importdirectory
+ directorylisting = os.listdir(path)
+
+ for infile in directorylisting:
+ if not os.path.isdir(infile): #check if the file is a directory
+ if '.preset' in infile: #check that this is a .preset file
+ thefile=os.path.join(path, infile) #join the filename with the path
+ gllightpreset_importsingle(thefile) #import it!
+
+#import single takes a given filename and imports it
+def gllightpreset_importsingle(filename):
+
+ if not os.path.isdir(filename): #check if the file is a directory
+ if '.preset' in filename: #check to make sure this is a preset file
+ readfile=open(filename, 'r')
+
+ name=readfile.readline()
+ name=name[:-1]
+
+ illuminationString0=readfile.readline()
+ illuminationString0=illuminationString0[:-1]
+
+ if illuminationString0=="True":
+ illumination0=True
+ else:
+ illumination0=False
+
+ illuminationString1=readfile.readline()
+ illuminationString1=illuminationString1[:-1]
+ if illuminationString1=="True":
+ illumination1=True
+ else:
+ illumination1=False
+
+ illuminationString2=readfile.readline()
+ illuminationString2=illuminationString2[:-1]
+ if illuminationString2=="True":
+ illumination2=True
+ else:
+ illumination2=False
+
+ #convert strings to booleans
+
+ str=readfile.readline()
+ strArray=str.split()
+ direction0x=strArray[0]
+ direction0y=strArray[1]
+ direction0z=strArray[2]
+
+ str=readfile.readline()
+ strArray=str.split()
+ direction1x=strArray[0]
+ direction1y=strArray[1]
+ direction1z=strArray[2]
+
+ str=readfile.readline()
+ strArray=str.split()
+ direction2x=strArray[0]
+ direction2y=strArray[1]
+ direction2z=strArray[2]
+
+ str=readfile.readline()
+ strArray=str.split()
+ diffuse0r=strArray[0]
+ diffuse0g=strArray[1]
+ diffuse0b=strArray[2]
+
+ str=readfile.readline()
+ strArray=str.split()
+ diffuse1r=strArray[0]
+ diffuse1g=strArray[1]
+ diffuse1b=strArray[2]
+
+ str=readfile.readline()
+ strArray=str.split()
+ diffuse2r=strArray[0]
+ diffuse2g=strArray[1]
+ diffuse2b=strArray[2]
+
+ str=readfile.readline()
+ strArray=str.split()
+ spec0r=strArray[0]
+ spec0g=strArray[1]
+ spec0b=strArray[2]
+
+ str=readfile.readline()
+ strArray=str.split()
+ spec1r=strArray[0]
+ spec1g=strArray[1]
+ spec1b=strArray[2]
+
+ str=readfile.readline()
+ strArray=str.split()
+ spec2r=strArray[0]
+ spec2g=strArray[1]
+ spec2b=strArray[2]
+
+ #set the variables
+ system=bpy.context.user_preferences.system
+ system.solid_lights[0].use=illumination0
+ system.solid_lights[1].use=illumination1
+ system.solid_lights[2].use=illumination2
+
+ system.solid_lights[0].direction = (float(direction0x), float(direction0y), float(direction0z))
+ system.solid_lights[1].direction = (float(direction1x), float(direction1y), float(direction1z))
+ system.solid_lights[2].direction = (float(direction2x), float(direction2y), float(direction2z))
+
+ system.solid_lights[0].diffuse_color=(float(diffuse0r), float(diffuse0g), float(diffuse0b))
+ system.solid_lights[1].diffuse_color=(float(diffuse1r), float(diffuse1g), float(diffuse1b))
+ system.solid_lights[2].diffuse_color=(float(diffuse2r), float(diffuse2g), float(diffuse2b))
+
+ system.solid_lights[0].specular_color=(float(spec0r), float(spec0g), float(spec0b))
+ system.solid_lights[1].specular_color=(float(spec1r), float(spec1g), float(spec1b))
+ system.solid_lights[2].specular_color=(float(spec2r), float(spec2g), float(spec2b))
+ gllightpreset_add(name)
+ gllightpreset_save()
+
+#Export all exports the entire contents of your presets list to the given file
+ at persistent
+def gllightpreset_exportall(context):
+ for i in range(len(bpy.context.scene.gllightpreset)):
+ gllightpreset_exportsingle(i, True)
+
+
+def gllightpreset_exportsingle(index, multiimport):
+ scn=bpy.context.scene
+ name=scn.gllightpreset[index].name
+
+ illuminatedBool0=scn.gllightpreset[index].illuminated0
+ illuminatedBool1=scn.gllightpreset[index].illuminated1
+ illuminatedBool2=scn.gllightpreset[index].illuminated2
+
+ #illuminations
+ if illuminatedBool0==True:
+ illuminated0="True"
+ else:
+ illuminated0="False"
+
+ if illuminatedBool1==True:
+ illuminated1="True"
+ else:
+ illuminated1="False"
+
+ if illuminatedBool2==True:
+ illuminated2="True"
+ else:
+ illuminated2="False"
+
+ #direction light0
+ dirx=str(scn.gllightpreset[index].direction0[0])
+ diry=str(scn.gllightpreset[index].direction0[1])
+ dirz=str(scn.gllightpreset[index].direction0[2])
+ direction0=dirx + " " + diry + " " + dirz + " "
+
+ #direction light1
+ dirx=str(scn.gllightpreset[index].direction1[0])
+ diry=str(scn.gllightpreset[index].direction1[1])
+ dirz=str(scn.gllightpreset[index].direction1[2])
+ direction1=dirx + " " + diry + " " + dirz + " "
+
+ #direction light2
+ dirx=str(scn.gllightpreset[index].direction2[0])
+ diry=str(scn.gllightpreset[index].direction2[1])
+ dirz=str(scn.gllightpreset[index].direction2[2])
+ direction2=dirx + " " + diry + " " + dirz + " "
+
+ #diffuse light0
+ difr=str(scn.gllightpreset[index].diffuse0[0])
+ difg=str(scn.gllightpreset[index].diffuse0[1])
+ difb=str(scn.gllightpreset[index].diffuse0[2])
+ diffuse0=difr + " " + difg + " " + difb + " "
+
+ #diffuse light1
+ difr=str(scn.gllightpreset[index].diffuse1[0])
+ difg=str(scn.gllightpreset[index].diffuse1[1])
+ difb=str(scn.gllightpreset[index].diffuse1[2])
+ diffuse1=difr + " " + difg + " " + difb + " "
+
+ #diffuse light2
+ difr=str(scn.gllightpreset[index].diffuse2[0])
+ difg=str(scn.gllightpreset[index].diffuse2[1])
+ difb=str(scn.gllightpreset[index].diffuse2[2])
+ diffuse2=difr + " " + difg + " " + difb + " "
+
+ #specular light 0
+ specr=str(scn.gllightpreset[index].specular0[0])
+ specg=str(scn.gllightpreset[index].specular0[1])
+ specb=str(scn.gllightpreset[index].specular0[2])
+ specular0=specr + " " + specg + " " + specb + " "
+
+ #specular light 1
+ specr=str(scn.gllightpreset[index].specular1[0])
+ specg=str(scn.gllightpreset[index].specular1[1])
+ specb=str(scn.gllightpreset[index].specular1[2])
+ specular1=specr + " " + specg + " " + specb + " "
+
+ #specular light 2
+ specr=str(scn.gllightpreset[index].specular2[0])
+ specg=str(scn.gllightpreset[index].specular2[1])
+ specb=str(scn.gllightpreset[index].specular2[2])
+ specular2=specr + " " + specg + " " + specb + " "
+
+ printstring=name+"\n"
+ printstring+=illuminated0 +"\n"+ illuminated1 +"\n"+ illuminated2+"\n"
+ printstring+=direction0 +"\n"+ direction1 +"\n"+ direction2 +"\n"
+ printstring+=diffuse0+"\n"+diffuse1 +"\n"+ diffuse2 +"\n"
+ printstring+=specular0+"\n"+specular1+"\n"+specular2+"\n"
+
+ if multiimport==True:
+ filepath = scn.gllightpreset_exportdirectory
+ else:
+ filepath = scn.gllightpreset_exportfile
+
+ if not os.path.exists(filepath):
+ os.mkdir(filepath)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list