Fix mesh_snap_utilities_line running without key-maps available
[blender-addons.git] / io_import_palette / __init__.py
blobc2c15d5dcf53f7430df07c0803a381281ed79e4b
1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
19 # <pep8-80 compliant>
21 bl_info = {
22 "name": "Import Palettes",
23 "author": "Antonio Vazquez",
24 "version": (1, 0, 0),
25 "blender": (2, 81, 6),
26 "location": "File > Import",
27 "description": "Import Palettes",
28 "warning": "",
29 "doc_url": "{BLENDER_MANUAL_URL}/addons/import_export/palettes.html",
30 "category": "Import-Export",
33 import sys
34 import os
36 # ----------------------------------------------
37 # Add to Phyton path (once only)
38 # ----------------------------------------------
39 path = sys.path
40 flag = False
41 for item in path:
42 if "io_import_palette" in item:
43 flag = True
44 if flag is False:
45 sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'io_import_palette'))
47 # ----------------------------------------------
48 # Import modules
49 # ----------------------------------------------
50 if "bpy" in locals():
51 import imp
53 imp.reload(import_ase)
54 imp.reload(import_krita)
55 else:
56 import import_ase
57 import import_krita
59 import bpy
60 from bpy.props import (
61 StringProperty,
63 from bpy_extras.io_utils import (
64 ImportHelper,
65 path_reference_mode,
69 class ImportASE(bpy.types.Operator, ImportHelper):
70 """Load a Palette File"""
71 bl_idname = "import_ase.read"
72 bl_label = "Import ASE"
73 bl_options = {'PRESET', 'UNDO'}
75 filename_ext = ".ase"
76 filter_glob: StringProperty(
77 default="*.ase",
78 options={'HIDDEN'},
81 def execute(self, context):
82 return import_ase.load(context, self.properties.filepath)
84 def draw(self, context):
85 pass
88 class importKPL(bpy.types.Operator, ImportHelper):
89 """Load a File"""
90 bl_idname = "import_krita.read"
91 bl_label = "Import Palette"
92 bl_options = {'PRESET', 'UNDO'}
94 filename_ext = ".kpl"
95 filter_glob: StringProperty(
96 default="*.kpl;*gpl",
97 options={'HIDDEN'},
100 def execute(self, context):
101 return import_krita.load(context, self.properties.filepath)
103 def draw(self, context):
104 pass
107 def menu_func_import(self, context):
108 self.layout.operator(importKPL.bl_idname, text="KPL Palette (.kpl)")
109 self.layout.operator(ImportASE.bl_idname, text="ASE Palette (.ase)")
112 classes = (
113 ImportASE,
114 importKPL,
118 def register():
119 for cls in classes:
120 bpy.utils.register_class(cls)
122 bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
125 def unregister():
126 bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
128 for cls in classes:
129 bpy.utils.unregister_class(cls)
132 if __name__ == "__main__":
133 register()