-
Notifications
You must be signed in to change notification settings - Fork 9
/
__init__.py
156 lines (121 loc) · 5.52 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
bl_info = {
"name" : "Bricker",
"author" : "Christopher Gearhart <[email protected]>",
"version" : (1, 4, 2),
"blender" : (2, 79, 0),
"description" : "Turn any mesh into a 3D brick sculpture or simulation with the click of a button",
"location" : "View3D > Tools > Bricker",
"warning" : "", # used for warning icon and text in addons panel
"wiki_url" : "https://www.blendermarket.com/products/rebrickr/",
"tracker_url" : "https://github.com/bblanimation/rebrickr/issues",
"category" : "Object"}
developer_mode = 1 # NOTE: Set to 0 for release, 1 for exposed dictionary and access to safe scene, 2 for testBrickGenerators button
# NOTE: Disable "LEGO Logo" for releases
"""
Copyright (C) 2017 Bricks Brought to Life
http://bblanimation.com/
Created by Christopher Gearhart
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
# System imports
# NONE!
# Blender imports
import bpy
from bpy.props import *
# Addon imports
from .ui import *
from .buttons import *
from .buttons.customize import *
from .operators import *
from .lib.preferences import *
# from .lib.rigid_body_props import *
from .lib.Brick.legal_brick_sizes import getLegalBrickSizes
from .lib import keymaps
# updater import
from . import addon_updater_ops
# store keymaps here to access after registration
addon_keymaps = []
def register():
bpy.utils.register_module(__name__)
bpy.props.bricker_module_name = __name__
bpy.props.bricker_initialized = False
bpy.props.bricker_undoUpdating = False
bpy.props.bricker_version = str(bl_info["version"])[1:-1].replace(", ", ".")
bpy.props.Bricker_developer_mode = developer_mode
bpy.types.Object.protected = BoolProperty(name='protected', default=False)
bpy.types.Object.isBrickifiedObject = BoolProperty(name='Is Brickified Object', default=False)
bpy.types.Object.isBrick = BoolProperty(name='Is Brick', default=False)
bpy.types.Object.cmlist_id = IntProperty(name='Custom Model ID', description="ID of cmlist entry to which this object refers", default=-1)
bpy.types.Material.num_averaged = IntProperty(name='Colors Averaged', description="Number of colors averaged together", default=0)
# # backup rigid body settings
# bpy.types.Object.rigid_body_settings = PointerProperty(type=Bricker_RigidBodySettings)
bpy.types.Scene.Bricker_runningBlockingOperation = BoolProperty(default=False)
bpy.types.Scene.Bricker_printTimes = BoolProperty(default=False)
bpy.types.Scene.Bricker_last_layers = StringProperty(default="")
bpy.types.Scene.Bricker_last_cmlist_index = IntProperty(default=-2)
bpy.types.Scene.Bricker_active_object_name = StringProperty(default="")
bpy.types.Scene.Bricker_last_active_object_name = StringProperty(default="")
bpy.types.Scene.Bricker_copy_from_id = IntProperty(default=-1)
# define legal brick sizes (key:height, val:[width,depth])
bpy.props.Bricker_legal_brick_sizes = getLegalBrickSizes()
# bpy.types.Scene.Bricker_snapping = BoolProperty(
# name="Bricker Snap",
# description="Snap to brick dimensions",
# default=False)
# bpy.types.VIEW3D_HT_header.append(Bricker_snap_button)
# handle the keymap
wm = bpy.context.window_manager
# Note that in background mode (no GUI available), keyconfigs are not available either, so we have
# to check this to avoid nasty errors in background case.
if wm.keyconfigs.addon:
km = wm.keyconfigs.addon.keymaps.new(name='Object Mode', space_type='EMPTY')
keymaps.addKeymaps(km)
addon_keymaps.append(km)
# other things (UI List)
bpy.types.Scene.cmlist = CollectionProperty(type=Bricker_CreatedModels)
bpy.types.Scene.cmlist_index = IntProperty(default=-1)
# addon updater code and configurations
addon_updater_ops.register(bl_info)
def unregister():
Scn = bpy.types.Scene
# addon updater unregister
addon_updater_ops.unregister()
del Scn.cmlist_index
del Scn.cmlist
# bpy.types.VIEW3D_HT_header.remove(Bricker_snap_button)
# del Scn.Bricker_snapping
del Scn.Bricker_copy_from_id
del Scn.Bricker_last_active_object_name
del Scn.Bricker_active_object_name
del Scn.Bricker_last_cmlist_index
del Scn.Bricker_last_layers
del Scn.Bricker_printTimes
del Scn.Bricker_runningBlockingOperation
del bpy.types.Material.num_averaged
del bpy.types.Object.cmlist_id
del bpy.types.Object.isBrick
del bpy.types.Object.isBrickifiedObject
del bpy.types.Object.protected
del bpy.props.Bricker_developer_mode
del bpy.props.bricker_version
del bpy.props.bricker_undoUpdating
del bpy.props.bricker_initialized
del bpy.props.bricker_module_name
# handle the keymaps
wm = bpy.context.window_manager
for km in addon_keymaps:
wm.keyconfigs.addon.keymaps.remove(km)
addon_keymaps.clear()
bpy.utils.unregister_module(__name__)
if __name__ == "__main__":
register()