From fc59c46c1a50dd4da1841e09e4a074f6f03911a6 Mon Sep 17 00:00:00 2001 From: Kalle-Samuli Riihikoski <haikalle@gmail.com> Date: Wed, 15 Aug 2018 13:18:27 +0300 Subject: [PATCH] fixed a texture naming bug --- io_coat3D/__init__.py | 16 ++++++++++++---- io_coat3D/tex.py | 10 ++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/io_coat3D/__init__.py b/io_coat3D/__init__.py index 0a1bd9b9a..9a2e4bd0d 100644 --- a/io_coat3D/__init__.py +++ b/io_coat3D/__init__.py @@ -143,10 +143,7 @@ def set_working_folders(): platform = os.sys.platform coat3D = bpy.context.scene.coat3D if(platform == 'win32'): - if(bpy.data.filepath == ''): - folder_objects = os.path.expanduser("~") + os.sep + 'Documents' + os.sep + '3DC2Blender' + os.sep + 'ApplinkObjects' - else: - folder_objects = os.path.dirname(bpy.data.filepath) + os.sep + '3DCApplink' + folder_objects = os.path.expanduser("~") + os.sep + 'Documents' + os.sep + '3DC2Blender' + os.sep + 'ApplinkObjects' if(not(os.path.isdir(folder_objects))): os.makedirs(folder_objects) else: @@ -316,6 +313,7 @@ class SCENE_OT_export(bpy.types.Operator): material.material.node_tree.nodes.remove(node) + return {'FINISHED'} class SCENE_OT_import(bpy.types.Operator): @@ -339,6 +337,10 @@ class SCENE_OT_import(bpy.types.Operator): coat3D.exchangedir = set_exchange_folder() texturelist = make_texture_list(coat3D.exchangedir) + for texturepath in texturelist: + for image in bpy.data.images: + if(image.filepath == texturepath[3]): + bpy.data.images.remove(image) Blender_folder = ("%s%sBlender"%(coat3D.exchangedir,os.sep)) @@ -376,6 +378,8 @@ 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 = [] object_list = [] import_list = [] mesh_del_list = [] @@ -397,11 +401,15 @@ class SCENE_OT_import(bpy.types.Operator): new_materials = bpy.data.materials.keys() new_objects = bpy.data.objects.keys() + new_images = bpy.data.images.keys() diff_mat = [i for i in new_materials if i not in old_materials] diff_objects = [i for i in new_objects if i not in old_objects] + diff_images = [i for i in new_images if i not in old_images] for c_index in diff_mat: bpy.data.materials.remove(bpy.data.materials[c_index]) + for i in diff_images: + bpy.data.images.remove(bpy.data.images[i]) #The main Applink Object Loop diff --git a/io_coat3D/tex.py b/io_coat3D/tex.py index 1c8c7db19..b682c8df6 100644 --- a/io_coat3D/tex.py +++ b/io_coat3D/tex.py @@ -41,13 +41,8 @@ def readtexturefolder(objekti,is_new): #read textures from texture file texcoat['nmap'] = [] texcoat['disp'] = [] - if(is_new == True): - files_dir = os.path.dirname(os.path.abspath(objekti.coat3D.applink_address)) - else: - if(bpy.data.filepath == ''): - files_dir = os.path.dirname(os.path.abspath(objekti.coat3D.applink_address)) - else: - files_dir = os.path.dirname(bpy.data.filepath) + os.sep + '3DCApplink' + + files_dir = os.path.dirname(os.path.abspath(objekti.coat3D.applink_address)) files = os.listdir(files_dir) materiaali_muutos = objekti.active_material.name uusin_mat = materiaali_muutos.replace('Material.','Material_') @@ -58,7 +53,6 @@ def readtexturefolder(objekti,is_new): #read textures from texture file tex_name = listed[-2] texcoat[tex_name].append(koko_osoite) - createnodes(objekti, texcoat) def checkmaterial(mat_list, objekti): #check how many materials object has -- GitLab