[Bf-extensions-cvs] [cd22ea98] blender2.8: Move applink panel into left tab + other small changes

Kalle-Samuli Riihikoski noreply at git.blender.org
Mon Dec 10 00:48:24 CET 2018


Commit: cd22ea98050651f2fb32b7883ab72a0695f7b53f
Author: Kalle-Samuli Riihikoski
Date:   Mon Dec 10 01:45:02 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBAcd22ea98050651f2fb32b7883ab72a0695f7b53f

Move applink panel into left tab + other small changes

===================================================================

M	io_coat3D/__init__.py

===================================================================

diff --git a/io_coat3D/__init__.py b/io_coat3D/__init__.py
index 98ff8092..02c2848d 100644
--- a/io_coat3D/__init__.py
+++ b/io_coat3D/__init__.py
@@ -405,7 +405,6 @@ class SCENE_OT_export(bpy.types.Operator):
                     for all_ob in bpy.data.meshes:
                         numero = ("%.3d"%(nimiNum))
                         nimi2 = name_boxs[0] + numero
-                        print('nimi2',nimi2)
                         if(all_ob.name == nimi2):
                             lyytyi = True
                             break
@@ -430,14 +429,11 @@ class SCENE_OT_export(bpy.types.Operator):
             objekti.coat3D.applink_scale = objekti.scale
 
         bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')
-        #bpy.ops.object.transforms_to_deltas(mode='SCALE')
+        if(len(bpy.context.selected_objects) > 1 and coat3D.type != 'vox'):
+            bpy.ops.object.transforms_to_deltas(mode='ROT')
 
-        if(coat3D.type == 'ppp' or coat3D.type == 'mv' or coat3D.type == 'ptex'):
-            bpy.ops.export_scene.fbx(filepath=coa.applink_address, use_selection=True, use_mesh_modifiers=False, axis_forward='X', axis_up='Y')
-        else:
-            bpy.ops.export_scene.fbx(filepath=coa.applink_address, use_selection=True, use_mesh_modifiers=False, axis_up='Y', axis_forward='-Z')
-            objekti.coat3D.type = 'Voxel'
 
+        bpy.ops.export_scene.fbx(filepath=coa.applink_address, use_selection=True, use_mesh_modifiers=coat3D.exportmod, axis_forward='X', axis_up='Y')
 
         file = open(importfile, "w")
         file.write("%s"%(checkname))
@@ -446,10 +442,10 @@ class SCENE_OT_export(bpy.types.Operator):
         file.close()
         group_index = -1.0
         for idx, objekti in enumerate(bpy.context.selected_objects):
-            nimi = ''
-            for koko in bpy.context.selected_objects:
-                nimi += koko.data.name + ':::'
-            objekti.coat3D.applink_group = nimi
+
+            if(len(bpy.context.selected_objects) == 1):
+                objekti.coat3D.applink_onlyone = True
+            objekti.coat3D.type = coat3D.type
             objekti.coat3D.applink_mesh = True
             objekti.coat3D.applink_address = coa.applink_address
             objekti.coat3D.obj_mat = ''
@@ -457,12 +453,13 @@ class SCENE_OT_export(bpy.types.Operator):
             objekti.coat3D.objecttime = str(os.path.getmtime(objekti.coat3D.applink_address))
             objekti.data.coat3D.name = '3DC'
 
-            if(objekti.material_slots.keys() != []):
-                for material in objekti.material_slots:
-                    if material.material.use_nodes == True:
-                        for node in material.material.node_tree.nodes:
-                            if(node.name.startswith('3DC_') == True):
-                                material.material.node_tree.nodes.remove(node)
+            if(coat3D.type != 'vox'):
+                if(objekti.material_slots.keys() != []):
+                    for material in objekti.material_slots:
+                        if material.material.use_nodes == True:
+                            for node in material.material.node_tree.nodes:
+                                if(node.name.startswith('3DC_') == True):
+                                    material.material.node_tree.nodes.remove(node)
 
         return {'FINISHED'}
 
@@ -518,7 +515,6 @@ class SCENE_OT_import(bpy.types.Operator):
         new_applink_address = 'False'
         new_object = False
 
-        print('Blender_export: ', Blender_export)
         if(os.path.isfile(Blender_export)):
             obj_pathh = open(Blender_export)
             new_object = True
@@ -537,7 +533,6 @@ class SCENE_OT_import(bpy.types.Operator):
         exportfile += ('%sexport.txt' % (os.sep))
         if (os.path.isfile(exportfile)):
             os.remove(exportfile)
-        print('new_object=', new_object)
         if(new_object == False):
 
             '''
@@ -547,11 +542,11 @@ class SCENE_OT_import(bpy.types.Operator):
 
             old_materials = bpy.data.materials.keys()
             old_objects = bpy.data.objects.keys()
-            old_images = bpy.data.images.keys()
-            image_list = []
+            cache_base = bpy.data.objects.keys()
+
             object_list = []
             import_list = []
-            mesh_del_list = []
+            import_type = []
 
             for objekti in bpy.data.objects:
                 if objekti.type == 'MESH':
@@ -566,10 +561,19 @@ class SCENE_OT_import(bpy.types.Operator):
                                 obj_coat.objecttime = str(os.path.getmtime(obj_coat.applink_address))
                                 if(obj_coat.applink_address not in import_list):
                                     import_list.append(obj_coat.applink_address)
+                                    import_type.append(coat3D.type)
 
             if(import_list or coat3D.importmesh):
-                for list in import_list:
+                print('import_list:', import_list)
+                for idx, list in enumerate(import_list):
                     bpy.ops.import_scene.fbx(filepath=list, global_scale = 1,axis_forward='X',use_custom_normals=False)
+                    cache_objects = bpy.data.objects.keys()
+                    cache_objects = [i for i in cache_objects if i not in cache_base]
+                    for cache_object in cache_objects:
+                        bpy.data.objects[cache_object].coat3D.type = import_type[idx]
+                        bpy.data.objects[cache_object].coat3D.applink_address = list
+                        cache_base.append(cache_object)
+
 
                 bpy.ops.object.select_all(action='DESELECT')
 
@@ -605,19 +609,14 @@ class SCENE_OT_import(bpy.types.Operator):
                         found_obj = False
 
                         '''Changes objects mesh into proxy mesh'''
-
-                        if(objekti.coat3D.type == ''):
+                        print('ONAME:',oname)
+                        if(objekti.coat3D.type):
                             for proxy_objects in diff_objects:
+                                print('tryis to found: ',proxy_objects)
                                 if (proxy_objects.startswith(objekti.coat3D.applink_name + '.')):
                                     obj_proxy = bpy.data.objects[proxy_objects]
+                                    obj_proxy.coat3D.delete_proxy_mesh = True
                                     found_obj = True
-                        elif(objekti.coat3D.type == 'Voxel' and len(object_list) == 1):
-                            obj_proxy = bpy.data.objects[diff_objects[0]]
-                            found_obj = True
-                            if objekti.coat3D.applink_firsttime == True:
-                                objekti.rotation_euler[0] = 1.5708
-                                bpy.ops.object.transforms_to_deltas(mode='ROT')
-                                objekti.coat3D.applink_firsttime = False
 
                         if(found_obj == True):
                             exportfile = coat3D.exchangedir
@@ -639,12 +638,6 @@ class SCENE_OT_import(bpy.types.Operator):
                                 export_file.close()
                                 coat3D.remove_path = True
 
-
-
-                            obj_names = objekti.coat3D.applink_group
-
-
-
                             mat_list = []
                             if(objekti.material_slots):
                                 act_mat = objekti.active_material
@@ -655,10 +648,22 @@ class SCENE_OT_import(bpy.types.Operator):
 
                             bpy.ops.object.select_all(action='TOGGLE')
 
-                            if objekti.coat3D.applink_firsttime == True:
+                            if objekti.coat3D.applink_firsttime == True and objekti.coat3D.type == 'vox':
+                                #objekti.scale = (objekti.scale[0] / objekti.coat3D.applink_scale[0], objekti.scale[1] / objekti.coat3D.applink_scale[1], objekti.scale[2] / objekti.coat3D.applink_scale[2])
+                                #bpy.ops.object.transforms_to_deltas(mode='SCALE')
+                                objekti.rotation_euler[0] = 1.5708
+                                objekti.rotation_euler[2] = 1.5708
+                                bpy.ops.object.transforms_to_deltas(mode='ROT')
+                                #objekti.rotation_euler = (0, 0, 0)
+                                objekti.scale = (0.02, 0.02, 0.02)
+                                bpy.ops.object.transforms_to_deltas(mode='SCALE')
+                                objekti.coat3D.applink_firsttime = False
+
+                            elif objekti.coat3D.applink_firsttime == True:
                                 objekti.scale = (objekti.scale[0]/objekti.coat3D.applink_scale[0],objekti.scale[1]/objekti.coat3D.applink_scale[1],objekti.scale[2]/objekti.coat3D.applink_scale[2])
                                 bpy.ops.object.transforms_to_deltas(mode='SCALE')
-                                objekti.rotation_euler = (0,0,0)
+                                if(objekti.coat3D.applink_onlyone == False):
+                                    objekti.rotation_euler = (0,0,0)
                                 objekti.scale = (0.01,0.01,0.01)
                                 objekti.coat3D.applink_firsttime = False
 
@@ -717,8 +722,30 @@ class SCENE_OT_import(bpy.types.Operator):
             bpy.ops.object.select_all(action='DESELECT')
             if(import_list):
                 for del_obj in diff_objects:
-                    bpy.context.collection.all_objects[del_obj].select_set(True)
-                    bpy.ops.object.delete()
+                    print('diff_objects', diff_objects)
+
+                    if(bpy.context.collection.all_objects[del_obj].coat3D.type == 'vox' and bpy.context.collection.all_objects[del_obj].coat3D.delete_proxy_mesh == False):
+                        bpy.context.collection.all_objects[del_obj].select_set(True)
+                        objekti = bpy.context.collection.all_objects[del_obj]
+                        objekti.rotation_euler[2] = 1.5708
+                        bpy.ops.object.transforms_to_deltas(mode='ROT')
+                   

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list