[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2797] contrib/py/scripts/addons/ io_import_BrushSet.py: replaced tabs with spaces
dan grauer
thespiderdan at yahoo.de
Wed Dec 21 11:59:09 CET 2011
Revision: 2797
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2797
Author: kromar
Date: 2011-12-21 10:59:02 +0000 (Wed, 21 Dec 2011)
Log Message:
-----------
replaced tabs with spaces
Modified Paths:
--------------
contrib/py/scripts/addons/io_import_BrushSet.py
Modified: contrib/py/scripts/addons/io_import_BrushSet.py
===================================================================
--- contrib/py/scripts/addons/io_import_BrushSet.py 2011-12-19 20:36:52 UTC (rev 2796)
+++ contrib/py/scripts/addons/io_import_BrushSet.py 2011-12-21 10:59:02 UTC (rev 2797)
@@ -16,104 +16,129 @@
#
# ***** END GPL LICENCE BLOCK *****
+# ----------------------------------------------------------------------------#
+
'''
todo:
- add file selection for single and multiple files
changelog:
- "version": (1,1,4),
- filename will be used as texture name (still limited by stringlength)
+ "version": (1,1,4),
+ filename will be used as texture name (still limited by stringlength)
- "version": (1,1,3),
- fixed operator and registration
- added tracker and wiki url\
-
+ "version": (1,1,3),
+ fixed operator and registration
+ added tracker and wiki url\
+
version": (1,1,2)
- replaced image.new() with image.load()
- changed addon category
- removed some unused/old code
-
+ replaced image.new() with image.load()
+ changed addon category
+ removed some unused/old code
+
version":1.11:
- added type arg to texture.new() [L48]
- cleared default filename
+ added type arg to texture.new() [L48]
+ cleared default filename
'''
+# ----------------------------------------------------------------------------#
+
import bpy
import os
from bpy.props import *
#addon description
bl_info = {
- "name": "import BrushSet",
- "author": "Daniel Grauer",
- "version": (1,1,4),
- "blender": (2, 5, 6),
- "api": "",
- "category": "Import-Export",
- "location": "File > Import > BrushSet",
- "description": "imports all image files from a folder",
- "warning": '', # used for warning icon and text in addons panel
- "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/Scripts/Import-Export/BrushSet",
- "tracker_url": "http://projects.blender.org/tracker/index.php?func=detail&aid=25702&group_id=153&atid=467",
- }
+ "name": "import BrushSet",
+ "author": "Daniel Grauer",
+ "version": (1, 1, 4),
+ "blender": (2, 5, 6),
+ "category": "VirtaMed",
+ "location": "File > Import > BrushSet",
+ "description": "imports all image files from a folder",
+ "warning": '', # used for warning icon and text in addons panel
+ "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/Scripts/Import-Export/BrushSet",
+ "tracker_url": "http://projects.blender.org/tracker/index.php?func=detail&aid=25702&group_id=153&atid=467",
+ }
+print(" ")
+print("*------------------------------------------------------------------------------*")
+print("* initializing BrushSet import *")
+print("*------------------------------------------------------------------------------*")
+print(" ")
+
#extension filter (alternative use mimetypes)
-ext_list = ['jpg','bmp', 'iris', 'png', 'jpeg', 'targa', 'tga'];
+ext_list = ['jpg',
+ 'bmp',
+ 'iris',
+ 'png',
+ 'jpeg',
+ 'targa',
+ 'tga'];
def LoadBrushSet(filepath, filename):
- for file in os.listdir(filepath):
- path=(filepath+file)
- #get folder name
- (f1,f2) = os.path.split(filepath)
- (f3,foldername) = os.path.split(f1)
-
- texturename = foldername # file "texture" foldername
-
- #filter ext_list
- if file.split('.')[-1].lower() in ext_list:
- #create new texture
- texture = bpy.data.textures.new(texturename, 'IMAGE') #watch it, string limit 21 ?!
+ for file in os.listdir(filepath):
+ path = (filepath + file)
+ #get folder name
+ (f1, f2) = os.path.split(filepath)
+ (f3, foldername) = os.path.split(f1)
+
+ texturename = foldername # file "texture" foldername
+
+ #filter ext_list
+ if file.split('.')[-1].lower() in ext_list:
+ #create new texture
+ texture = bpy.data.textures.new(texturename, 'IMAGE') #watch it, string limit 21 ?!
- #create new image
- image = bpy.data.images.load(path)
- image.source = "FILE"
- image.filepath = path
- bpy.data.textures[texture.name].image = image
-
- print("imported: "+file)
- print("Brush Set imported!")
+ #create new image
+ image = bpy.data.images.load(path)
+ image.source = "FILE"
+ image.filepath = path
+ bpy.data.textures[texture.name].image = image
+
+ print("imported: " + file)
+ print("Brush Set imported!")
+# ----------------------------------------------------------------------------#
+
class BrushSetImporter(bpy.types.Operator):
- '''Load Brush Set'''
- bl_idname = "import_image.brushset"
- bl_label = "Import BrushSet"
+ '''Load Brush Set'''
+ bl_idname = "import_image.brushset"
+ bl_label = "Import BrushSet"
- filename = StringProperty(name="File Name", description="filepath", default="", maxlen=1024, options={'ANIMATABLE'}, subtype='NONE')
- filepath = StringProperty(name="File Name", description="filepath", default="", maxlen=1024, options={'ANIMATABLE'}, subtype='NONE')
-
- def execute(self, context):
- LoadBrushSet(self.properties.filepath, self.properties.filename)
- return {'FINISHED'}
+ filename = StringProperty(name="File Name", description="filepath", default="", maxlen=1024, options={'ANIMATABLE'}, subtype='NONE')
+ filepath = StringProperty(name="File Name", description="filepath", default="", maxlen=1024, options={'ANIMATABLE'}, subtype='NONE')
+
+ def execute(self, context):
+ LoadBrushSet(self.properties.filepath, self.properties.filename)
+ return {'FINISHED'}
- def invoke(self, context, event):
- wm = context.window_manager
- wm.fileselect_add(self)
- return {'RUNNING_MODAL'}
+ def invoke(self, context, event):
+ wm = context.window_manager
+ wm.fileselect_add(self)
+ return {'RUNNING_MODAL'}
+# ----------------------------------------------------------------------------#
+
def menu_func(self, context):
- #clear the default name for import
- default_name = ""
+ #clear the default name for import
+ default_name = ""
- self.layout.operator(BrushSetImporter.bl_idname, text="Brush Set").filename = default_name
+ self.layout.operator(BrushSetImporter.bl_idname, text="Brush Set").filename = default_name
+# ----------------------------------------------------------------------------#
+
def register():
- bpy.utils.register_module(__name__)
- bpy.types.INFO_MT_file_import.append(menu_func)
+ bpy.utils.register_module(__name__)
+ bpy.types.INFO_MT_file_import.append(menu_func)
def unregister():
- bpy.utils.unregister_module(__name__)
- bpy.types.INFO_MT_file_import.remove(menu_func)
+ bpy.utils.unregister_module(__name__)
+ bpy.types.INFO_MT_file_import.remove(menu_func)
if __name__ == "__main__":
- register()
+ register()
+
+print(" ")
+print("*------------------------------------------------------------------------------*")
+print(" ")
More information about the Bf-extensions-cvs
mailing list