[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1367] trunk/py/scripts/addons/ io_coat3D: Update the script to work in the latest trunk.

Kalle-Samuli Riihikoski haikalle at gmail.com
Sat Jan 8 12:15:47 CET 2011


Revision: 1367
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=1367
Author:   haikalle
Date:     2011-01-08 11:15:47 +0000 (Sat, 08 Jan 2011)
Log Message:
-----------
Update the script to work in the latest trunk.

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-01-08 10:32:09 UTC (rev 1366)
+++ trunk/py/scripts/addons/io_coat3D/coat.py	2011-01-08 11:15:47 UTC (rev 1367)
@@ -91,11 +91,9 @@
         colR.prop(coat3D,"importtextures")
         row = layout.row()
         colL = row.column()
-        colM = row.column()
         colR = row.column()
         colL.operator("deltex",text="Del Tex")
         if(bpy.context.active_object):
-            colM.active = True
             if(bpy.context.active_object.coat3D.coatpath and os.path.isfile(bpy.context.active_object.coat3D.coatpath)):
                 colR.active = True
                 if(coat['active_coat'] == bpy.context.active_object.coat3D.coatpath):
@@ -106,12 +104,10 @@
                 colR.active = False
                 colR.operator("no3b",text="No 3b")
         else:
-            colM.active = False
             colR.active = False
             colR.operator("no3b",text="")
-        colM.operator("pickname",text="Object name")
         row = layout.row()
-        row.label(text="Object Path:")
+        row.label(text="Object Folder:")
         row = layout.row()
         row.prop(coat3D,"objectdir",text="")                 
         row = layout.row()
@@ -204,9 +200,8 @@
                 os.remove(texturefile)
         
         checkname = coat3D.objectdir
-        
-        if(coat3D.objectdir[-4:] != '.obj'):
-            checkname += ('%s.obj'%(activeobj))
+            
+        checkname += ('%s.obj'%(activeobj))
 
         if(not(os.path.isfile(checkname)) or coat3D.exportover):
             
@@ -232,7 +227,6 @@
             file.write("\n%s"%(checkname))
             file.write("\n[%s]"%(coat3D.type))
             file.close()
-        coat3D.objectdir = checkname
         bpy.context.active_object.coat3D.objpath = coat3D.objectdir
 
         return('FINISHED')
@@ -248,6 +242,7 @@
         coat3D = bpy.context.scene.coat3D
         coat = bpy.coat3D
         activeobj = bpy.context.active_object.name
+        pathname = coat3D.objectdir + activeobj + ".obj"
         mat_list = []
         scene.objects[activeobj].select = True
         objekti = scene.objects[activeobj]
@@ -274,14 +269,14 @@
             act_mat_index = objekti.active_material_index
 
 
-        if(coat3D.importmesh and os.path.isfile(coat3D.objectdir)):
-            mtl = coat3D.objectdir
+        if(coat3D.importmesh and os.path.isfile(pathname)):
+            mtl = pathname
             mtl = mtl.replace('.obj','.mtl')
             if(os.path.isfile(mtl)):
                 os.remove(mtl)
 
             
-            bpy.ops.import_scene.obj(filepath=coat3D.objectdir)
+            bpy.ops.import_scene.obj(filepath=pathname)
             obj_proxy = scene.objects[0]
             proxy_mat = obj_proxy.material_slots[0].material
             obj_proxy.data.materials.pop(0)
@@ -343,7 +338,7 @@
             else:
                 bpy.ops.object.shade_flat()
                 
-        if(coat3D.importmesh and not(os.path.isfile(coat3D.objectdir))):
+        if(coat3D.importmesh and not(os.path.isfile(pathname))):
             coat3D.importmesh = False
 
         if(mat_list and coat3D.importmesh):
@@ -416,21 +411,6 @@
     
         return('FINISHED')
 
-class SCENE_OT_pickname(bpy.types.Operator):
-    bl_idname = "pickname"
-    bl_label = "Picks Object's name into path"
-    bl_description = "Loads 3b linked into object"
-
-    
-    def invoke(self, context, event):
-        coat3D = bpy.context.scene.coat3D
-        scene = context.scene
-        new_name = os.path.dirname(coat3D.objectdir) + os.sep
-        new_name += ("%s.obj"%(bpy.context.active_object.name))
-        coat3D.objectdir = new_name
-    
-        return('FINISHED')
-
 class SCENE_OT_deltex(bpy.types.Operator):
     bl_idname = "deltex"
     bl_label = "Picks Object's name into path"

Modified: trunk/py/scripts/addons/io_coat3D/tex.py
===================================================================
--- trunk/py/scripts/addons/io_coat3D/tex.py	2011-01-08 10:32:09 UTC (rev 1366)
+++ trunk/py/scripts/addons/io_coat3D/tex.py	2011-01-08 11:15:47 UTC (rev 1367)
@@ -72,8 +72,10 @@
                     if(tex_slot.texture.type == 'IMAGE'):
                                                 tex_slot.texture.image.reload()
     else:
-        nimi = objname(coat3D.objectdir)
-        osoite = os.path.dirname(coat3D.objectdir) + os.sep
+        activeobj = bpy.context.active_object.name
+        pathname = coat3D.objectdir + activeobj + ".obj"
+        nimi = objname(pathname)
+        osoite = os.path.dirname(pathname) + os.sep
     just_nimi = justname(nimi)
     just_nimi += '_'
     just_nimi_len = len(just_nimi)
@@ -217,7 +219,7 @@
 
             else:
                 bpy.data.textures[name_tex].use_normal_map = True
-                bpy.data.textures[name_tex].normal_space = 'TANGENT'
+                objekti.active_material.texture_slots[index].normal_map_space = 'TANGENT'
             
 
         elif(useold != ''):



More information about the Bf-extensions-cvs mailing list