Fix: ensure loaded path is folder and not file #104812
@ -13,7 +13,6 @@
|
||||
#---------------------------------------------#
|
||||
import bpy
|
||||
import os
|
||||
from bpy.props import *
|
||||
|
||||
# addon description
|
||||
bl_info = {
|
||||
@ -50,12 +49,13 @@ ext_list = ['.bmp',
|
||||
|
||||
fakeUser = False
|
||||
|
||||
def LoadBrushSet(filepath, filename):
|
||||
for file in os.listdir(filepath):
|
||||
path = (filepath + file)
|
||||
def LoadBrushSet(directory):
|
||||
|
||||
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)
|
||||
@ -87,22 +87,18 @@ 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')
|
||||
set_default_filters: bool = True
|
||||
def draw(self, context):
|
||||
if self.set_default_filters:
|
||||
context.space_data.params.use_filter = True
|
||||
context.space_data.params.use_filter_folder = True
|
||||
context.space_data.params.use_filter_image = True
|
||||
self.set_default_filters = False
|
||||
|
||||
def execute(self, context):
|
||||
LoadBrushSet(self.properties.filepath, self.properties.filename)
|
||||
LoadBrushSet(self.directory)
|
||||
return {'FINISHED'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
@ -148,16 +144,14 @@ classes = (
|
||||
|
||||
|
||||
def register():
|
||||
from bpy.utils import register_class
|
||||
for cls in classes:
|
||||
register_class(cls)
|
||||
bpy.utils.register_class(cls)
|
||||
bpy.types.TOPBAR_MT_file_import.append(menu_func)
|
||||
|
||||
|
||||
def unregister():
|
||||
from bpy.utils import unregister_class
|
||||
for cls in reversed(classes):
|
||||
unregister_class(cls)
|
||||
bpy.utils.unregister_class(cls)
|
||||
bpy.types.TOPBAR_MT_file_import.remove(menu_func)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user