Remove deprecated 2D_/3D_ prefix
[blender-addons.git] / io_import_palette / __init__.py
blobab71272d8a0c24450c0fc9a35b9a37692c7db7aa
1 # SPDX-License-Identifier: GPL-2.0-or-later
3 bl_info = {
4 "name": "Import Palettes",
5 "author": "Antonio Vazquez, Kevin C. Burke (@blastframe)",
6 "version": (1, 0, 1),
7 "blender": (2, 81, 6),
8 "location": "File > Import",
9 "description": "Import Palettes",
10 "warning": "",
11 "doc_url": "{BLENDER_MANUAL_URL}/addons/import_export/palettes.html",
12 "category": "Import-Export",
15 import sys
16 import os
18 # ----------------------------------------------
19 # Add to Python path (once only)
20 # ----------------------------------------------
21 path = sys.path
22 flag = False
23 for item in path:
24 if "io_import_palette" in item:
25 flag = True
26 if flag is False:
27 sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'io_import_palette'))
29 # ----------------------------------------------
30 # Import modules
31 # ----------------------------------------------
32 if "bpy" in locals():
33 import imp
35 imp.reload(import_ase)
36 imp.reload(import_krita)
37 else:
38 import import_ase
39 import import_krita
41 import bpy
42 from bpy.props import (
43 StringProperty,
45 from bpy_extras.io_utils import (
46 ImportHelper,
47 path_reference_mode,
51 class ImportASE(bpy.types.Operator, ImportHelper):
52 """Load a Palette File"""
53 bl_idname = "import_ase.read"
54 bl_label = "Import ASE"
55 bl_options = {'PRESET', 'UNDO'}
57 filename_ext = ".ase"
58 filter_glob: StringProperty(
59 default="*.ase",
60 options={'HIDDEN'},
63 def execute(self, context):
64 return import_ase.load(context, self.properties.filepath)
66 def draw(self, context):
67 pass
70 class importKPL(bpy.types.Operator, ImportHelper):
71 """Load a File"""
72 bl_idname = "import_krita.read"
73 bl_label = "Import Palette"
74 bl_options = {'PRESET', 'UNDO'}
76 filename_ext = ".kpl"
77 filter_glob: StringProperty(
78 default="*.kpl;*gpl",
79 options={'HIDDEN'},
82 def execute(self, context):
83 return import_krita.load(context, self.properties.filepath)
85 def draw(self, context):
86 pass
89 def menu_func_import(self, context):
90 self.layout.operator(importKPL.bl_idname, text="KPL Palette (.kpl)")
91 self.layout.operator(ImportASE.bl_idname, text="ASE Palette (.ase)")
94 classes = (
95 ImportASE,
96 importKPL,
100 def register():
101 for cls in classes:
102 bpy.utils.register_class(cls)
104 bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
107 def unregister():
108 bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
110 for cls in classes:
111 bpy.utils.unregister_class(cls)
114 if __name__ == "__main__":
115 register()