[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2016] trunk/py/scripts/addons/ io_coat3D: small bug fixes.

Kalle-Samuli Riihikoski haikalle at gmail.com
Wed Jun 8 07:53:17 CEST 2011


Revision: 2016
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2016
Author:   haikalle
Date:     2011-06-08 05:53:16 +0000 (Wed, 08 Jun 2011)
Log Message:
-----------
small bug fixes. Also fixed Image None issue. Thanks to Campbell for pointing this out.

Modified Paths:
--------------
    trunk/py/scripts/addons/io_coat3D/coat.py
    trunk/py/scripts/addons/io_coat3D/tex.py

Modified: trunk/py/scripts/addons/io_coat3D/coat.py
===================================================================
--- trunk/py/scripts/addons/io_coat3D/coat.py	2011-06-07 21:05:04 UTC (rev 2015)
+++ trunk/py/scripts/addons/io_coat3D/coat.py	2011-06-08 05:53:16 UTC (rev 2016)
@@ -218,63 +218,68 @@
         obj = scene.objects[activeobj]
         coa = bpy.context.scene.objects.active.coat3D
 
-        importfile = coat3D.exchangedir
-        texturefile = coat3D.exchangedir
-        importfile += ('%simport.txt'%(os.sep))
-        texturefile += ('%stextures.txt'%(os.sep))
-        if(os.path.isfile(texturefile)):
-                os.remove(texturefile)
-        
-        checkname = coa.objectdir
-        
-        if(coa.objectdir[-4:] != '.obj'):
-            checkname += ('%s.obj'%(activeobj))
+        if(coa.objectdir == '' and (coat3D.defaultfolder)):
+            print('kalle osaa koodata')
+            coa.objectdir = coat3D.defaultfolder
+        else:
 
-        if(not(os.path.isfile(checkname)) or coat3D.exportover):
-            if(coat3D.export_pos):
-                bpy.ops.object.transform_apply(location=True,rotation=True,scale=True)
+            importfile = coat3D.exchangedir
+            texturefile = coat3D.exchangedir
+            importfile += ('%simport.txt'%(os.sep))
+            texturefile += ('%stextures.txt'%(os.sep))
+            if(os.path.isfile(texturefile)):
+                    os.remove(texturefile)
+            
+            checkname = coa.objectdir
+            
+            if(coa.objectdir[-4:] != '.obj'):
+                checkname += ('%s.obj'%(activeobj))
 
-                bpy.ops.export_scene.obj(filepath=checkname,use_selection=True,
-                use_apply_modifiers=coat3D.exportmod,use_blen_objects=False, group_by_material= True,
-                use_materials = False,keep_vertex_order = True,axis_forward='Y',axis_up='Z')
-                bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='MEDIAN')
+            if(not(os.path.isfile(checkname)) or coat3D.exportover):
+                if(coat3D.export_pos):
+                    bpy.ops.object.transform_apply(location=True,rotation=True,scale=True)
 
-                coa.export_on = True
-            else:
-                bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='MEDIAN')
-                coat3D.loca = obj.location
-                coat3D.rota = obj.rotation_euler
-                coat3D.scal = obj.scale
-                obj.location = (0,0,0)
-                obj.rotation_euler = (0,0,0)
-                obj.scale = (1,1,1)
+                    bpy.ops.export_scene.obj(filepath=checkname,use_selection=True,
+                    use_apply_modifiers=coat3D.exportmod,use_blen_objects=False, group_by_material= True,
+                    use_materials = False,keep_vertex_order = True,axis_forward='Y',axis_up='Z')
+                    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='MEDIAN')
 
-                bpy.ops.export_scene.obj(filepath=checkname,use_selection=True,
-                use_apply_modifiers=coat3D.exportmod,use_blen_objects=False, group_by_material= True,
-                use_materials = False,keep_vertex_order = True,axis_forward='Y',axis_up='Z')
+                    coa.export_on = True
+                else:
+                    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='MEDIAN')
+                    coat3D.loca = obj.location
+                    coat3D.rota = obj.rotation_euler
+                    coat3D.scal = obj.scale
+                    obj.location = (0,0,0)
+                    obj.rotation_euler = (0,0,0)
+                    obj.scale = (1,1,1)
 
-                obj.location = coat3D.loca
-                obj.rotation_euler = coat3D.rota
-                obj.scale = coat3D.scal
-                coa.export_on = False
-                    
+                    bpy.ops.export_scene.obj(filepath=checkname,use_selection=True,
+                    use_apply_modifiers=coat3D.exportmod,use_blen_objects=False, group_by_material= True,
+                    use_materials = False,keep_vertex_order = True,axis_forward='Y',axis_up='Z')
 
+                    obj.location = coat3D.loca
+                    obj.rotation_euler = coat3D.rota
+                    obj.scale = coat3D.scal
+                    coa.export_on = False
+                        
 
-        if(coat3D.exportfile == False):
-            file = open(importfile, "w")
-            file.write("%s"%(checkname))
-            file.write("\n%s"%(checkname))
-            file.write("\n[%s]"%(coat3D.type))
-            if(coa.texturefolder):
-                file.write("\n[TexOutput:%s"%(coa.texturefolder))
-            
-            
-        
 
+            if(coat3D.exportfile == False):
+                file = open(importfile, "w")
+                file.write("%s"%(checkname))
+                file.write("\n%s"%(checkname))
+                file.write("\n[%s]"%(coat3D.type))
+                if(coa.texturefolder):
+                    file.write("\n[TexOutput:%s"%(coa.texturefolder))
+                
+                
             
-            file.close()
-        coa.objectdir = checkname
 
+                
+                file.close()
+            coa.objectdir = checkname
+
         return('FINISHED')
 
 
@@ -380,7 +385,8 @@
                         for tex_slot in obj_mate.material.texture_slots:
                             if(hasattr(tex_slot,'texture')):
                                 if(tex_slot.texture.type == 'IMAGE'):
-                                                                tex_slot.texture.image.reload()
+                                    if tex_slot.texture.image is not None:
+                                        tex_slot.texture.image.reload()
                                                                 
 
                 if(coat3D.importmod):

Modified: trunk/py/scripts/addons/io_coat3D/tex.py
===================================================================
--- trunk/py/scripts/addons/io_coat3D/tex.py	2011-06-07 21:05:04 UTC (rev 2015)
+++ trunk/py/scripts/addons/io_coat3D/tex.py	2011-06-08 05:53:16 UTC (rev 2016)
@@ -65,7 +65,8 @@
             for tex_slot in mate.material.texture_slots:
                 if(hasattr(tex_slot,'texture')):
                     if(tex_slot.texture.type == 'IMAGE'):
-                        tex_slot.texture.image.reload()
+                        if tex_slot.texture.image is not None:
+                            tex_slot.texture.image.reload()
     else:
         coa = bpy.context.scene.objects.active.coat3D
         nimi = objname(coa.objectdir)
@@ -142,20 +143,28 @@
                 useold = seekco
 
 
-
         if(useold == ''):
 
-            tex_name = setgallery()
+            indexx = 0
+            tuli = False
+            lasku = False
+            while(lasku == False):
+                tuli = False
+                name_tex = ("Color_%s"%(indexx))
+                for i in bpy.data.textures:
+                    if(i.name == name_tex):
+                        tuli = True
+                        break
+                if(tuli):
+                    indexx += 1
+                else:
+                    lasku = True
+                
 
-            for num_tex in tex_name:
-                if(num_tex[:6] == 'Color_'):
-                    num.append(num_tex)
-            luku_tex = len(num)
-            name_tex = ('Color_%s'%(luku_tex))
-
             bpy.ops.image.new(name=name_tex)
             bpy.data.images[name_tex].filepath = texcoat['color'][0]
             bpy.data.images[name_tex].source = 'FILE'
+            print('name_tex: %s'%name_tex)
             
 
             bpy.data.textures.new(name_tex,type='IMAGE')
@@ -170,8 +179,10 @@
             
 
         elif(useold != ''):
+            print('useold:%s'%useold)
             
             objekti.active_material.texture_slots[index].texture = useold
+            print(objekti.active_material)
             objekti.active_material.texture_slots[index].texture.image.filepath = texcoat['color'][0]
             if(objekti.data.uv_textures.active):
                 objekti.active_material.texture_slots[index].texture_coords = 'UV'
@@ -193,14 +204,21 @@
 
         if(useold == ''):
 
-            tex_name = setgallery()
+            indexx = 0
+            tuli = False
+            lasku = False
+            while(lasku == False):
+                tuli = False
+                name_tex = ("Normal_%s"%(indexx))
+                for i in bpy.data.textures:
+                    if(i.name == name_tex):
+                        tuli = True
+                        break
+                if(tuli):
+                    indexx += 1
+                else:
+                    lasku = True
 
-            for num_tex in tex_name:
-                if(num_tex[:7] == 'Normal_'):
-                    num.append(num_tex)
-            luku_tex = len(num)
-            name_tex = ('Normal_%s'%(luku_tex))
-
             bpy.ops.image.new(name=name_tex)
             bpy.data.images[name_tex].filepath = texcoat['nmap'][0]
             bpy.data.images[name_tex].source = 'FILE'
@@ -260,14 +278,21 @@
 
         if(useold == ''):
 
-            tex_name = setgallery()
+            indexx = 0
+            tuli = False
+            lasku = False
+            while(lasku == False):
+                tuli = False
+                name_tex = ("Specular_%s"%(indexx))
+                for i in bpy.data.textures:
+                    if(i.name == name_tex):
+                        tuli = True
+                        break
+                if(tuli):
+                    indexx += 1
+                else:
+                    lasku = True
 
-            for num_tex in tex_name:
-                if(num_tex[:9] == 'Specular_'):
-                    num.append(num_tex)
-            luku_tex = len(num)
-            name_tex = ('Specular_%s'%(luku_tex))
-
             bpy.ops.image.new(name=name_tex)
             bpy.data.images[name_tex].filepath = texcoat['specular'][0]
             bpy.data.images[name_tex].source = 'FILE'
@@ -317,14 +342,21 @@
 
         if(useold == ''):
 
-            tex_name = setgallery()
+            indexx = 0
+            tuli = False
+            lasku = False
+            while(lasku == False):
+                tuli = False
+                name_tex = ("Displacement_%s"%(indexx))
+                for i in bpy.data.textures:

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list