Fix: ensure loaded path is folder and not file #104812

Closed
Daniel Grauer wants to merge 4 commits from DanielGrauer:fix-error-when-file-is-selected into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Showing only changes of commit 195acac65e - Show all commits

View File

@ -50,18 +50,13 @@ ext_list = ['.bmp',
fakeUser = False
def LoadBrushSet(filepath, filename):
def LoadBrushSet(directory):
# 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)
for file in os.listdir(directory):
path = os.path.join(directory + file)
# get folder name
(f1, f2) = os.path.split(filepath)
(f1, f2) = os.path.split(directory)
(f3, foldername) = os.path.split(f1)
# filter files by extensions (filter images)
@ -93,22 +88,11 @@ class BrushSetImporter(bpy.types.Operator):
bl_idname = "import_image.brushset"
bl_label = "Import BrushSet"
filename: StringProperty(name = "File Name",
description = "filepath",
default = "",
maxlen = 1024,
options = {'ANIMATABLE'},
subtype = 'NONE')
directory: bpy.props.StringProperty(name="Directory", options={"HIDDEN"})
filepath: StringProperty(name = "File Name",
description = "filepath",
default = "",
maxlen = 1024,
options = {'ANIMATABLE'},
subtype = 'NONE')
def execute(self, context):
LoadBrushSet(self.properties.filepath, self.properties.filename)
LoadBrushSet(self.directory)
return {'FINISHED'}
def invoke(self, context, event):