[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1417] trunk/py/scripts/addons/ io_coat3D: A lot changes :)

Kalle-Samuli Riihikoski haikalle at gmail.com
Mon Jan 17 11:06:51 CET 2011


Revision: 1417
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=1417
Author:   haikalle
Date:     2011-01-17 10:06:50 +0000 (Mon, 17 Jan 2011)
Log Message:
-----------
A lot changes :)
Biggest change was that objectdir was changed from scene type into object type. 

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

Modified: trunk/py/scripts/addons/io_coat3D/__init__.py
===================================================================
--- trunk/py/scripts/addons/io_coat3D/__init__.py	2011-01-17 08:53:30 UTC (rev 1416)
+++ trunk/py/scripts/addons/io_coat3D/__init__.py	2011-01-17 10:06:50 UTC (rev 1417)
@@ -20,18 +20,19 @@
     "name": "3D-Coat Applink",
     "author": "Kalle-Samuli Riihikoski (haikalle)",
     "version": (1, 61),
-    "blender": (2, 5, 4),
+    "blender": (2, 5, 6),
     "api": 31667,
     "location": "Scene -> 3D-Coat Applink",
     "description": "Transfer data between 3D-Coat/Blender",
     "warning": "",
-    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"\
+    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/" \
         "Scripts/Import-Export/3dcoat_applink",
     "tracker_url": "https://projects.blender.org/tracker/?"\
         "func=detail&aid=24446",
-    "category": "Import-Export"}
+    "category": "Import/Export"}
 
 
+
 if "bpy" in locals():
     import imp
     imp.reload(coat)
@@ -43,15 +44,13 @@
 import bpy
 from bpy.props import *
 
-
+    
 def register():
 
     bpy.coat3D = dict()
     bpy.coat3D['active_coat'] = ''
     bpy.coat3D['status'] = 0
-    bpy.coat3D['was'] = ''
-    bpy.coat3D['exchange'] = ''
-    bpy.coat3D['export_off'] = 0
+    bpy.coat3D['kuva'] = 1
     
     class coat3D(bpy.types.IDPropertyGroup):
         pass
@@ -72,7 +71,13 @@
         default= ""
     )
 
+    coat3D.objectdir = StringProperty(
+        name="ObjectPath",
+        subtype="FILE_PATH",
+        default= ""
+    )
 
+
     class coat3D(bpy.types.IDPropertyGroup):
         pass
 
@@ -82,12 +87,6 @@
         description= "Applink variables"
     )
 
-    coat3D.objectdir = StringProperty(
-        name="ObjectPath",
-        subtype="FILE_PATH",
-        default= ""
-    )
-
     coat3D.exchangedir = StringProperty(
         name="FilePath",
         subtype="DIR_PATH",

Modified: trunk/py/scripts/addons/io_coat3D/coat.py
===================================================================
--- trunk/py/scripts/addons/io_coat3D/coat.py	2011-01-17 08:53:30 UTC (rev 1416)
+++ trunk/py/scripts/addons/io_coat3D/coat.py	2011-01-17 10:06:50 UTC (rev 1417)
@@ -26,6 +26,11 @@
 import os
 import linecache
 
+bpy.coat3D = dict()
+bpy.coat3D['active_coat'] = ''
+bpy.coat3D['status'] = 0
+
+
 class ObjectButtonsPanel():
     bl_space_type = 'PROPERTIES'
     bl_region_type = 'WINDOW'
@@ -44,12 +49,13 @@
         mat_list = []
         import_no = 0
         coat = bpy.coat3D
-        coat3D = bpy.context.scene.coat3D               
+        coat3D = bpy.context.scene.coat3D
+        if(bpy.context.scene.objects.active):
+            coa = bpy.context.scene.objects.active.coat3D
         
         if(os.path.isdir(coat3D.exchangedir)):
             foldder = coat3D.exchangedir
             if(foldder.rfind('Exchange') >= 0):
-                coat['exchange'] = foldder
                 coat['status'] = 1
             else:
                 coat['status'] = 0
@@ -90,27 +96,13 @@
         colR.prop(coat3D,"smooth_on")
         colR.prop(coat3D,"importtextures")
         row = layout.row()
-        colL = row.column()
-        colR = row.column()
-        colL.operator("deltex",text="Del Tex")
-        if(bpy.context.active_object):
-            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):
-                    colR.operator("load3b", text="Active 3b")
-                else:
-                    colR.operator("load3b", text="Load 3b")
-            else:
-                colR.active = False
-                colR.operator("no3b",text="No 3b")
-        else:
-            colR.active = False
-            colR.operator("no3b",text="")
+        
+        if(bpy.context.scene.objects.active):
+            row.label(text="%s Path:"%(bpy.context.scene.objects.active.name))
+            row = layout.row()
+            row.prop(coa,"objectdir",text="")
+                    
         row = layout.row()
-        row.label(text="Object Folder:")
-        row = layout.row()
-        row.prop(coat3D,"objectdir",text="")                 
-        row = layout.row()
         
         if(coat['status'] == 1):
             row.label(text="Exchange Folder: connected")
@@ -140,7 +132,7 @@
 
                 for palikka in bpy.context.scene.objects:
                     if(palikka.type == 'MESH'):
-                        if(palikka.coat3D.objpath == export):
+                        if(palikka.coat3D.objectdir == export):
                             import_no = 1
                             target = palikka
                             break
@@ -151,10 +143,10 @@
                 else:
                     bpy.ops.import_scene.obj(filepath=obj_path)
                     new_obj = scene.objects[0]
+                    scene.objects[0].coat3D.objectdir = export
                 os.remove(Blender_export)
                 
                 bpy.context.scene.objects.active = new_obj
-                bpy.context.active_object.coat3D.objpath = obj_path
 
                 if(coat3D.smooth_on):
                     bpy.ops.object.shade_smooth()
@@ -174,6 +166,10 @@
         row = layout.row()
         row.prop(coat3D,"exchangedir",text="")
         row = layout.row()
+        colL = row.column()
+        colR = row.column()
+        colL.operator("deltex",text="Del Tex")
+        row = layout.row()
         row.label(text="Author: haikalle at gmail.com")
 
 
@@ -186,11 +182,11 @@
     def invoke(self, context, event):
         checkname = ''
         coat3D = bpy.context.scene.coat3D
-        coat = bpy.coat3D
         scene = context.scene
         coat3D.export_on = False
         activeobj = bpy.context.active_object.name
         obj = scene.objects[activeobj]
+        coa = bpy.context.scene.objects.active.coat3D
 
         importfile = coat3D.exchangedir
         texturefile = coat3D.exchangedir
@@ -199,35 +195,45 @@
         if(os.path.isfile(texturefile)):
                 os.remove(texturefile)
         
-        checkname = coat3D.objectdir
-            
-        checkname += ('%s.obj'%(activeobj))
+        checkname = coa.objectdir
+        
+        if(coa.objectdir[-4:] != '.obj'):
+            checkname += ('%s.obj'%(activeobj))
 
         if(not(os.path.isfile(checkname)) or coat3D.exportover):
-            
+            if(coat3D.export_pos):
 
-            bpy.ops.export_scene.obj(filepath=checkname,use_selection=True,
-            use_modifiers=coat3D.exportmod,use_blen_objects=False, group_by_material= True,
-            use_materials = False,keep_vertex_order = True)
-            coat3D.export_on = True
-        
-        if(not(coat3D.exportover)):
-            coat3D.loca = obj.location
-            coat3D.rota = obj.rotation_euler
-            coat3D.scal = obj.scale
-            coat['export_off'] = 1
-        else:
-            coat['export_off'] = 0
-           
+                bpy.ops.export_scene.obj(filepath=checkname,use_selection=True,
+                use_modifiers=coat3D.exportmod,use_blen_objects=False, group_by_material= True,
+                use_materials = False,keep_vertex_order = True)
 
+                coat3D.export_on = True
+            else:
+                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_modifiers=coat3D.exportmod,use_blen_objects=False, group_by_material= True,
+                use_materials = False,keep_vertex_order = True)
+
+                obj.location = coat3D.loca
+                obj.rotation_euler = coat3D.rota
+                obj.scale = coat3D.scal
+                coat3D.export_on = True
+                    
+
+
         if(coat3D.exportfile == False):
             file = open(importfile, "w")
             file.write("%s"%(checkname))
             file.write("\n%s"%(checkname))
             file.write("\n[%s]"%(coat3D.type))
             file.close()
-        bpy.context.active_object.coat3D.objpath = coat3D.objectdir
+        coa.objectdir = checkname
 
         return('FINISHED')
 
@@ -242,12 +248,12 @@
         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]
         coat3D.loca = objekti.location
         coat3D.rota = objekti.rotation_euler
+        coa = bpy.context.scene.objects.active.coat3D
 
         exportfile = coat3D.exchangedir
         exportfile += ('%sexport.txt'%(os.sep))
@@ -269,14 +275,14 @@
             act_mat_index = objekti.active_material_index
 
 
-        if(coat3D.importmesh and os.path.isfile(pathname)):
-            mtl = pathname
+        if(coat3D.importmesh and os.path.isfile(coa.objectdir)):
+            mtl = coa.objectdir
             mtl = mtl.replace('.obj','.mtl')
             if(os.path.isfile(mtl)):
                 os.remove(mtl)
 
             
-            bpy.ops.import_scene.obj(filepath=pathname)
+            bpy.ops.import_scene.obj(filepath=coa.objectdir)
             obj_proxy = scene.objects[0]
             proxy_mat = obj_proxy.material_slots[0].material
             obj_proxy.data.materials.pop(0)
@@ -338,7 +344,7 @@
             else:
                 bpy.ops.object.shade_flat()
                 
-        if(coat3D.importmesh and not(os.path.isfile(pathname))):
+        if(coat3D.importmesh and not(os.path.isfile(coa.objectdir))):
             coat3D.importmesh = False
 
         if(mat_list and coat3D.importmesh):
@@ -364,12 +370,6 @@
         if(coat3D.importtextures):
                         export = ''
                         tex.gettex(mat_list,objekti,scene,export)
-
-        if(coat['export_off']):
-            objekti.location = coat3D.loca
-            objekti.rotation_euler = coat3D.rota
-            objekti.scale = coat3D.scal
-            coat['export_off'] = 0
         
         return('FINISHED')
 
@@ -393,24 +393,11 @@
         file.write("\n%s"%(coat_path))
         file.write("\n[3B]")

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list