[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4545] contrib/py/scripts/addons/ io_directx_bel/bel: 2.67 tests
Jerome Mahieux
jerome.le.chat at free.fr
Tue May 21 19:32:38 CEST 2013
Revision: 4545
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4545
Author: littleneo
Date: 2013-05-21 17:32:38 +0000 (Tue, 21 May 2013)
Log Message:
-----------
2.67 tests
Modified Paths:
--------------
contrib/py/scripts/addons/io_directx_bel/bel/__init__.py
contrib/py/scripts/addons/io_directx_bel/bel/fs.py
contrib/py/scripts/addons/io_directx_bel/bel/material.py
contrib/py/scripts/addons/io_directx_bel/bel/mesh.py
Added Paths:
-----------
contrib/py/scripts/addons/io_directx_bel/bel/group.py
Modified: contrib/py/scripts/addons/io_directx_bel/bel/__init__.py
===================================================================
--- contrib/py/scripts/addons/io_directx_bel/bel/__init__.py 2013-05-21 07:20:13 UTC (rev 4544)
+++ contrib/py/scripts/addons/io_directx_bel/bel/__init__.py 2013-05-21 17:32:38 UTC (rev 4545)
@@ -1,3 +1,4 @@
+
# set a given name to a unique
# blender data name in its collection
def bpyname(name,collection,limit=63,suffix=4) :
Modified: contrib/py/scripts/addons/io_directx_bel/bel/fs.py
===================================================================
--- contrib/py/scripts/addons/io_directx_bel/bel/fs.py 2013-05-21 07:20:13 UTC (rev 4544)
+++ contrib/py/scripts/addons/io_directx_bel/bel/fs.py 2013-05-21 17:32:38 UTC (rev 4545)
@@ -35,6 +35,7 @@
## returns a list of every absolute filepath
# to each file within the 'ext' extensions
# from a folder and its subfolders
+# warning, in windows filename are returned in lowercase.
def scanDir(path,ext='all') :
files = []
fields = os_listdir(path)
@@ -44,8 +45,8 @@
#print(' file %s'%item)
files.append(path + '/' + item)
elif os_path.isdir(path + '/' + item) :
- print('folder %s/%s :'%(path,item))
- files.extend(scanDir(path + '/' + item))
+ #print('folder %s/%s :'%(path,item))
+ files.extend(scanDir(path + '/' + item,ext))
return files
def saveOptions(op,operator_name, tokens, filename='last_run'):
Added: contrib/py/scripts/addons/io_directx_bel/bel/group.py
===================================================================
--- contrib/py/scripts/addons/io_directx_bel/bel/group.py (rev 0)
+++ contrib/py/scripts/addons/io_directx_bel/bel/group.py 2013-05-21 17:32:38 UTC (rev 4545)
@@ -0,0 +1,75 @@
+import bpy
+'''
+given name < 21
+if material name exists :
+naming_method = 0 blender default (increment name)
+naming_method = 1 do nothing, abort creation and use existing
+naming_method = 2 create new, rename existing,
+naming_method = 3 create new, replace existing
+'''
+
+def new(name,naming_method):
+ if name in bpy.data.groups and naming_method :
+ grp = bpy.data.groups[name]
+ # if naming_method == 1 return existing
+ if naming_method == 2 :
+ grp = bpy.data.groups.new(name)
+ grp.name = name
+ elif naming_method == 3 :
+ bpy.data.groups.remove(grp)
+ grp = bpy.data.groups.new(name)
+ else :
+ grp = bpy.data.groups.new(name)
+ return grp
+
+## TODO
+# @param ob 'all', 'active', 'selected', <object>, 'objectname'
+# @return a list of objects or an empty list
+def get(grp) :
+ if type(ob) == str :
+ if ob == 'all' : return bpy.context.scene.objects
+ elif ob == 'active' : return [bpy.context.active_object] if bpy.context.active_object != None else []
+ elif ob == 'selected' : return bpy.context.selected_objects
+ else :
+ try : return [bpy.data.objects[ob]]
+ except : return []
+ return [ob]
+
+
+## TODO remove an object from blender internal
+def remove(ob,with_data=True) :
+ objs = get(ob)
+ #if objs :
+ # if type(objs) == bpy.types.Object : objs = [objs]
+ for ob in objs :
+ data = ob.data
+ #and_data=False
+ # never wipe data before unlink the ex-user object of the scene else crash (2.58 3 770 2)
+ # if there's more than one user for this data, never wipeOutData. will be done with the last user
+ # if in the list
+ and_data = with_data
+ try :
+ if data.users > 1 :
+ and_data=False
+ except :
+ and_data=False # empties
+
+ # odd (pre 2.60) :
+ # ob=bpy.data.objects[ob.name]
+ # if the ob (board) argument comes from bpy.data.groups['aGroup'].objects,
+ # bpy.data.groups['board'].objects['board'].users_scene
+ ob.name = '_dead'
+ for sc in ob.users_scene :
+ sc.objects.unlink(ob)
+
+ #try :
+ #print(' removing object %s...'%(ob.name)),
+ bpy.data.objects.remove(ob)
+ #print(' done.')
+ #except :
+ # print('removing failed, but renamed %s and unlinked'%ob.name)
+
+ # never wipe data before unlink the ex-user object of the scene else crash (2.58 3 770 2)
+ if and_data :
+ wipeOutData(data)
+
Modified: contrib/py/scripts/addons/io_directx_bel/bel/material.py
===================================================================
--- contrib/py/scripts/addons/io_directx_bel/bel/material.py 2013-05-21 07:20:13 UTC (rev 4544)
+++ contrib/py/scripts/addons/io_directx_bel/bel/material.py 2013-05-21 17:32:38 UTC (rev 4545)
@@ -30,3 +30,4 @@
matslot.material = mat
bpy.data.materials.remove(prevmat)
return mat
+
Modified: contrib/py/scripts/addons/io_directx_bel/bel/mesh.py
===================================================================
--- contrib/py/scripts/addons/io_directx_bel/bel/mesh.py 2013-05-21 07:20:13 UTC (rev 4544)
+++ contrib/py/scripts/addons/io_directx_bel/bel/mesh.py 2013-05-21 17:32:38 UTC (rev 4545)
@@ -3,6 +3,7 @@
import bpy
import mathutils
from mathutils import *
+import bmesh
from . import uv as buv
from . import ob as bob
@@ -21,6 +22,33 @@
for now, and mesh data, 0 2 or 3
'''
+'''
+given name < 21
+if material name exists :
+naming_method = 0 blender default (increment name)
+naming_method = 1 do nothing, abort creation and use existing
+naming_method = 2 create new, rename existing,
+naming_method = 3 create new, replace existing
+'''
+
+def new(name, naming_method=0) :
+ if name not in bpy.data.meshes or naming_method == 0:
+ return bpy.data.meshes.new(name=name)
+
+ if naming_method == 1 :
+ return bpy.data.meshes[name]
+
+ if naming_method == 2 :
+ me = bpy.data.meshes.new(name=name)
+ me.name = name
+ return me
+
+ # naming_method = 3 : replace, keep users
+ me = bpy.data.meshes[name]
+ bm = bmesh.new()
+ bm.to_mesh(me)
+ return me
+
## material listed in matslots must exist before creation of material slots
def write(obname,name,
More information about the Bf-extensions-cvs
mailing list