/
__init__.py
78 lines (58 loc) · 2.01 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"""Hydridic Blender is an addon designed to help import and draw stunning images of molecules and crystals.
"""
import os
import sys
import bpy
sys.path.append(os.path.dirname(__file__))
import operators
bl_info = {
"name": "Hydridic Blender",
"author": "James Dean",
"description": "Import and manipulate molecules, crystals, and other chemical species in an efficient manner",
"blender": (2, 80, 0),
"version": (0, 1, 0),
"location": "File > Import > Chemical Structure",
"warning": "",
"tracker_url": "https://github.com/AcylSilane/hydridic_blender/issues",
"category": "Import-Export",
}
# =================
# Addon Preferences
class HYDRIDIC_UL_preferences(bpy.types.AddonPreferences):
"""
Preferences menu, giving the user a button to install the dependencies.
"""
bl_idname = __name__
def draw(self, context: bpy.types.Context) -> None:
"""Defines what is displayed to the user in the preferences menu"""
layout = self.layout
layout.operator(
operators.HYDRIDIC_OT_install_dependencies.bl_idname, icon="CONSOLE"
)
# ==============
# Menu Functions
def menu_func_import(self, context):
"""Defines which options are available in the 'file->import' menu"""
layout = self.layout
layout.operator(
operators.HYDRIDIC_OT_import_chemical_structure.bl_idname,
text="Chemical Structure",
)
# =======================
# Register those classes!
classes = (HYDRIDIC_UL_preferences,)
modules = (operators,)
def register():
"""Makes classes and operators available to blender"""
for module in modules:
module.register()
for cls in classes:
bpy.utils.register_class(cls)
bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
def unregister():
"""Makes classes and operators unavailable to blender"""
for module in modules:
module.unregister()
for cls in classes:
bpy.utils.unregister_class(cls)
bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)