Import_3ds: Improved distance cue node setup
[blender-addons.git] / io_import_palette / __init__.py
blob06535011602611bdd84a8bb5cca92c3737afdeec
1 # SPDX-FileCopyrightText: 2019-2023 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 bl_info = {
6 "name": "Import Palettes",
7 "author": "Antonio Vazquez, Kevin C. Burke (@blastframe)",
8 "version": (1, 0, 1),
9 "blender": (2, 81, 6),
10 "location": "File > Import",
11 "description": "Import Palettes",
12 "warning": "",
13 "doc_url": "{BLENDER_MANUAL_URL}/addons/import_export/palettes.html",
14 "category": "Import-Export",
17 import sys
18 import os
20 # ----------------------------------------------
21 # Add to Python path (once only)
22 # ----------------------------------------------
23 path = sys.path
24 flag = False
25 for item in path:
26 if "io_import_palette" in item:
27 flag = True
28 if flag is False:
29 sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'io_import_palette'))
31 # ----------------------------------------------
32 # Import modules
33 # ----------------------------------------------
34 if "bpy" in locals():
35 import importlib
37 importlib.reload(import_ase)
38 importlib.reload(import_krita)
39 else:
40 import import_ase
41 import import_krita
43 import bpy
44 from bpy.props import (
45 StringProperty,
47 from bpy_extras.io_utils import (
48 ImportHelper,
49 path_reference_mode,
53 class ImportASE(bpy.types.Operator, ImportHelper):
54 """Load a Palette File"""
55 bl_idname = "import_ase.read"
56 bl_label = "Import ASE"
57 bl_options = {'PRESET', 'UNDO'}
59 filename_ext = ".ase"
60 filter_glob: StringProperty(
61 default="*.ase",
62 options={'HIDDEN'},
65 def execute(self, context):
66 return import_ase.load(context, self.properties.filepath)
68 def draw(self, context):
69 pass
72 class importKPL(bpy.types.Operator, ImportHelper):
73 """Load a File"""
74 bl_idname = "import_krita.read"
75 bl_label = "Import Palette"
76 bl_options = {'PRESET', 'UNDO'}
78 filename_ext = ".kpl"
79 filter_glob: StringProperty(
80 default="*.kpl;*gpl",
81 options={'HIDDEN'},
84 def execute(self, context):
85 return import_krita.load(context, self.properties.filepath)
87 def draw(self, context):
88 pass
91 def menu_func_import(self, context):
92 self.layout.operator(importKPL.bl_idname, text="KPL Palette (.kpl)")
93 self.layout.operator(ImportASE.bl_idname, text="ASE Palette (.ase)")
96 classes = (
97 ImportASE,
98 importKPL,
102 def register():
103 for cls in classes:
104 bpy.utils.register_class(cls)
106 bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
109 def unregister():
110 bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
112 for cls in classes:
113 bpy.utils.unregister_class(cls)
116 if __name__ == "__main__":
117 register()