From df344a5d784fcf3503f93818e33b0e215df12ec6 Mon Sep 17 00:00:00 2001 From: Daniel Grauer Date: Fri, 21 Jul 2023 19:07:03 +0200 Subject: [PATCH 1/6] replace hardcoded list of supported file formats with extensions_image lookup --- io_import_BrushSet.py | 54 +++++++------------------------------------ 1 file changed, 8 insertions(+), 46 deletions(-) diff --git a/io_import_BrushSet.py b/io_import_BrushSet.py index a67e2c52d..c141e282c 100644 --- a/io_import_BrushSet.py +++ b/io_import_BrushSet.py @@ -2,81 +2,43 @@ # # SPDX-License-Identifier: GPL-2.0-or-later -#---------------------------------------------# -# todo -#---------------------------------------------# -''' -- add file selection for single and multiple files -- option to enable/disable fake users -''' - -#---------------------------------------------# import bpy import os -from bpy.props import * +from bpy.props import StringProperty # addon description bl_info = { "name": "Import BrushSet", "author": "Daniel Grauer (kromar), CansecoGPC", - "version": (1, 2, 2), + "version": (1, 3, 0), "blender": (2, 80, 0), "location": "File > Import > BrushSet", "description": "Imports all image files from a folder.", "warning": '', # used for warning icon and text in addons panel "doc_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/Scripts/Import-Export/BrushSet", - "tracker_url": "https://developer.blender.org/maniphest/task/edit/form/2/", + "tracker_url": "https://projects.blender.org/blender/blender-addons/src/branch/main/io_import_BrushSet.py", "category": "Import-Export", } -#---------------------------------------------# - -# extension filter (alternative use mimetypes) -# TODO: rewrite so it tries to load image and if it fails we know its not a format blender can load -ext_list = ['.bmp', - '.png', - '.jpg', - '.jp2', - '.rgb', - '.dds', - '.hdr', - '.exr', - '.dpx', - '.cin', - '.tga', - '.tif']; - -#---------------------------------------------# - fakeUser = False def LoadBrushSet(filepath, filename): for file in os.listdir(filepath): path = (filepath + file) - # get folder name - (f1, f2) = os.path.split(filepath) - (f3, foldername) = os.path.split(f1) - - # filter files by extensions (filter images) - if any(file.lower().endswith(ext) for ext in ext_list): - print("file: ", file) + if any(file.lower().endswith(ext) for ext in bpy.path.extensions_image): # create new texture texture = bpy.data.textures.new(file, 'IMAGE') texture.use_fake_user = fakeUser - print("texture: ", texture) - # now we need to load the image into data + # load the image into data image = bpy.data.images.load(path) image.use_fake_user = fakeUser - # image.source = 'FILE' #default is FILE so can remove this - # image.filepath = path - print("image: ", image, " ", path) - print("texturename: ", texture.name) - # and assign the image to the texture + # assign the image to the texture bpy.data.textures[texture.name].image = image - + + print("imported: ", file) print("Brush Set imported!") -- 2.30.2 From 8fabb11720856c0b77c6c34b74dd66818a096dc8 Mon Sep 17 00:00:00 2001 From: Daniel Grauer Date: Fri, 21 Jul 2023 20:00:06 +0200 Subject: [PATCH 2/6] Ensure filepath is a path and not a file (this can happen when the user selects a file within the folder) --- io_import_BrushSet.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/io_import_BrushSet.py b/io_import_BrushSet.py index c141e282c..dce1f1a34 100644 --- a/io_import_BrushSet.py +++ b/io_import_BrushSet.py @@ -23,6 +23,12 @@ bl_info = { fakeUser = False def LoadBrushSet(filepath, filename): + + # Ensure filepath is a path and not a file (this can happen when the user selects a file within the folder) + if os.path.isfile(filepath): + path, file = os.path.split(filepath) + filepath = os.path.join(path + "\\") + for file in os.listdir(filepath): path = (filepath + file) -- 2.30.2 From 2a79bc2463ec46b28a94ebbba455e5720f2453e1 Mon Sep 17 00:00:00 2001 From: Daniel Grauer Date: Sun, 30 Jul 2023 20:56:18 +0200 Subject: [PATCH 3/6] fix: point to archive documentation until documentation is updated --- io_import_BrushSet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io_import_BrushSet.py b/io_import_BrushSet.py index dce1f1a34..8ca5b74af 100644 --- a/io_import_BrushSet.py +++ b/io_import_BrushSet.py @@ -15,7 +15,7 @@ bl_info = { "location": "File > Import > BrushSet", "description": "Imports all image files from a folder.", "warning": '', # used for warning icon and text in addons panel - "doc_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/Scripts/Import-Export/BrushSet", + "doc_url": "https://archive.blender.org/wiki/index.php/Extensions:2.5/Py/Scripts/Import-Export/BrushSet/", "tracker_url": "https://projects.blender.org/blender/blender-addons/src/branch/main/io_import_BrushSet.py", "category": "Import-Export", } -- 2.30.2 From aec44e7905c5ea41790227efaae9cb4845c1a166 Mon Sep 17 00:00:00 2001 From: Daniel Grauer Date: Tue, 1 Aug 2023 16:23:03 +0200 Subject: [PATCH 4/6] Revert "fix: point to archive documentation until documentation is updated" This reverts commit ce37aea4d6fd7077880202da4277d319b080651f. --- io_import_BrushSet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io_import_BrushSet.py b/io_import_BrushSet.py index 8ca5b74af..dce1f1a34 100644 --- a/io_import_BrushSet.py +++ b/io_import_BrushSet.py @@ -15,7 +15,7 @@ bl_info = { "location": "File > Import > BrushSet", "description": "Imports all image files from a folder.", "warning": '', # used for warning icon and text in addons panel - "doc_url": "https://archive.blender.org/wiki/index.php/Extensions:2.5/Py/Scripts/Import-Export/BrushSet/", + "doc_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/Scripts/Import-Export/BrushSet", "tracker_url": "https://projects.blender.org/blender/blender-addons/src/branch/main/io_import_BrushSet.py", "category": "Import-Export", } -- 2.30.2 From 7234bb57868017696e2966d18f715a83ce1dfe1f Mon Sep 17 00:00:00 2001 From: Daniel Grauer Date: Tue, 1 Aug 2023 16:23:14 +0200 Subject: [PATCH 5/6] Revert "Ensure filepath is a path and not a file (this can happen when the user selects a file within the folder)" This reverts commit da0ca4f0a214a3e02999557031b63398835f01e7. --- io_import_BrushSet.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/io_import_BrushSet.py b/io_import_BrushSet.py index dce1f1a34..c141e282c 100644 --- a/io_import_BrushSet.py +++ b/io_import_BrushSet.py @@ -23,12 +23,6 @@ bl_info = { fakeUser = False def LoadBrushSet(filepath, filename): - - # Ensure filepath is a path and not a file (this can happen when the user selects a file within the folder) - if os.path.isfile(filepath): - path, file = os.path.split(filepath) - filepath = os.path.join(path + "\\") - for file in os.listdir(filepath): path = (filepath + file) -- 2.30.2 From 5c84e61055023f951d8866f57936ae794f81f7d9 Mon Sep 17 00:00:00 2001 From: Daniel Grauer Date: Mon, 21 Aug 2023 19:40:39 +0200 Subject: [PATCH 6/6] revert tracker url --- io_import_BrushSet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io_import_BrushSet.py b/io_import_BrushSet.py index c141e282c..0ccfcdcda 100644 --- a/io_import_BrushSet.py +++ b/io_import_BrushSet.py @@ -16,7 +16,7 @@ bl_info = { "description": "Imports all image files from a folder.", "warning": '', # used for warning icon and text in addons panel "doc_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/Scripts/Import-Export/BrushSet", - "tracker_url": "https://projects.blender.org/blender/blender-addons/src/branch/main/io_import_BrushSet.py", + "tracker_url": "https://developer.blender.org/maniphest/task/edit/form/2/", "category": "Import-Export", } -- 2.30.2