Fix #100973: Node Wrangler: previewing node if hierarchy not active
[blender-addons.git] / archimesh / __init__.py
blob6b0613122c55a9fcc00edcd56d677d0da67b0186
1 # SPDX-FileCopyrightText: 2016-2023 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 # ----------------------------------------------------------
6 # Author: Antonio Vazquez (antonioya)
7 # ----------------------------------------------------------
9 # ----------------------------------------------
10 # Define Addon info
11 # ----------------------------------------------
12 bl_info = {
13 "name": "Archimesh",
14 "author": "Antonio Vazquez (antonioya)",
15 "location": "View3D > Add Mesh / Sidebar > Create Tab",
16 "version": (1, 2, 5),
17 "blender": (3, 0, 0),
18 "description": "Generate rooms, doors, windows, and other architecture objects",
19 "doc_url": "{BLENDER_MANUAL_URL}/addons/add_mesh/archimesh.html",
20 "category": "Add Mesh"
23 import sys
24 import os
26 # ----------------------------------------------
27 # Import modules
28 # ----------------------------------------------
29 if "bpy" in locals():
30 import importlib
31 importlib.reload(achm_room_maker)
32 importlib.reload(achm_door_maker)
33 importlib.reload(achm_window_maker)
34 importlib.reload(achm_roof_maker)
35 importlib.reload(achm_column_maker)
36 importlib.reload(achm_stairs_maker)
37 importlib.reload(achm_kitchen_maker)
38 importlib.reload(achm_shelves_maker)
39 importlib.reload(achm_books_maker)
40 importlib.reload(achm_lamp_maker)
41 importlib.reload(achm_curtain_maker)
42 importlib.reload(achm_venetian_maker)
43 importlib.reload(achm_main_panel)
44 importlib.reload(achm_window_panel)
45 # print("archimesh: Reloaded multifiles")
46 else:
47 from . import achm_books_maker
48 from . import achm_column_maker
49 from . import achm_curtain_maker
50 from . import achm_venetian_maker
51 from . import achm_door_maker
52 from . import achm_kitchen_maker
53 from . import achm_lamp_maker
54 from . import achm_main_panel
55 from . import achm_roof_maker
56 from . import achm_room_maker
57 from . import achm_shelves_maker
58 from . import achm_stairs_maker
59 from . import achm_window_maker
60 from . import achm_window_panel
62 # print("archimesh: Imported multifiles")
64 # noinspection PyUnresolvedReferences
65 import bpy
66 # noinspection PyUnresolvedReferences
67 from bpy.props import (
68 BoolProperty,
69 FloatVectorProperty,
70 IntProperty,
71 FloatProperty,
72 StringProperty,
74 # noinspection PyUnresolvedReferences
75 from bpy.types import (
76 AddonPreferences,
77 Menu,
78 Scene,
79 VIEW3D_MT_mesh_add,
80 WindowManager,
83 # ----------------------------------------------------------
84 # Decoration assets
85 # ----------------------------------------------------------
88 class ARCHIMESH_MT_MeshDecorationAdd(Menu):
89 bl_idname = "VIEW3D_MT_mesh_decoration_add"
90 bl_label = "Decoration assets"
92 # noinspection PyUnusedLocal
93 def draw(self, context):
94 self.layout.operator("mesh.archimesh_books", text="Books")
95 self.layout.operator("mesh.archimesh_light", text="Lamp")
96 self.layout.operator("mesh.archimesh_roller", text="Roller curtains")
97 self.layout.operator("mesh.archimesh_venetian", text="Venetian blind")
98 self.layout.operator("mesh.archimesh_japan", text="Japanese curtains")
100 # ----------------------------------------------------------
101 # Registration
102 # ----------------------------------------------------------
105 class ARCHIMESH_MT_CustomMenuAdd(Menu):
106 bl_idname = "VIEW3D_MT_mesh_custom_menu_add"
107 bl_label = "Archimesh"
109 # noinspection PyUnusedLocal
110 def draw(self, context):
111 self.layout.operator_context = 'INVOKE_REGION_WIN'
112 self.layout.operator("mesh.archimesh_room", text="Room")
113 self.layout.operator("mesh.archimesh_door", text="Door")
114 self.layout.operator("mesh.archimesh_window", text="Rail Window")
115 self.layout.operator("mesh.archimesh_winpanel", text="Panel Window")
116 self.layout.operator("mesh.archimesh_kitchen", text="Cabinet")
117 self.layout.operator("mesh.archimesh_shelves", text="Shelves")
118 self.layout.operator("mesh.archimesh_column", text="Column")
119 self.layout.operator("mesh.archimesh_stairs", text="Stairs")
120 self.layout.operator("mesh.archimesh_roof", text="Roof")
121 self.layout.menu("VIEW3D_MT_mesh_decoration_add", text="Decoration props", icon="GROUP")
123 # --------------------------------------------------------------
124 # Register all operators and panels
125 # --------------------------------------------------------------
127 # Define menu
128 # noinspection PyUnusedLocal
129 def AchmMenu_func(self, context):
130 layout = self.layout
131 layout.separator()
132 self.layout.menu("VIEW3D_MT_mesh_custom_menu_add", icon="GROUP")
135 classes = (
136 ARCHIMESH_MT_CustomMenuAdd,
137 ARCHIMESH_MT_MeshDecorationAdd,
138 achm_room_maker.ARCHIMESH_OT_Room,
139 achm_room_maker.ARCHIMESH_PT_RoomGenerator,
140 achm_room_maker.ARCHIMESH_OT_ExportRoom,
141 achm_room_maker.ARCHIMESH_OT_ImportRoom,
142 achm_door_maker.ARCHIMESH_OT_Door,
143 achm_door_maker.ARCHIMESH_PT_DoorObjectgenerator,
144 achm_window_maker.ARCHIMESH_OT_Windows,
145 achm_window_maker.ARCHIMESH_PT_WindowObjectgenerator,
146 achm_roof_maker.ARCHIMESH_OT_Roof,
147 achm_column_maker.ARCHIMESH_OT_Column,
148 achm_stairs_maker.ARCHIMESH_OT_Stairs,
149 achm_kitchen_maker.ARCHIMESH_OT_Kitchen,
150 achm_kitchen_maker.ARCHIMESH_OT_ExportInventory,
151 achm_shelves_maker.ARCHIMESH_OT_Shelves,
152 achm_books_maker.ARCHIMESH_OT_Books,
153 achm_lamp_maker.ARCHIMESH_PT_Lamp,
154 achm_curtain_maker.ARCHIMESH_OT_Roller,
155 achm_curtain_maker.ARCHIMESH_OT_Japan,
156 achm_venetian_maker.ARCHIMESH_OT_Venetian,
157 achm_venetian_maker.ARCHIMESH_PT_VenetianObjectgenerator,
158 achm_main_panel.ARCHIMESH_PT_Main,
159 achm_main_panel.ARCHIMESH_OT_Hole,
160 achm_main_panel.ARCHIMESH_OT_Pencil,
161 achm_main_panel.ARCHIMESH_OT_HintDisplay,
162 achm_window_panel.ARCHIMESH_PT_Win,
163 achm_window_panel.ARCHIMESH_PT_WindowEdit
166 def register():
167 from bpy.utils import register_class
168 for cls in classes:
169 register_class(cls)
171 VIEW3D_MT_mesh_add.append(AchmMenu_func)
173 # Define properties
174 Scene.archimesh_select_only = BoolProperty(
175 name="Only selected",
176 description="Apply auto holes only to selected objects",
177 default=False,
179 Scene.archimesh_ceiling = BoolProperty(
180 name="Ceiling",
181 description="Create a ceiling",
182 default=False,
184 Scene.archimesh_floor = BoolProperty(
185 name="Floor",
186 description="Create a floor automatically",
187 default=False,
190 Scene.archimesh_merge = BoolProperty(
191 name="Close walls",
192 description="Close walls to create a full closed room",
193 default=False,
196 Scene.archimesh_text_color = FloatVectorProperty(
197 name="Hint color",
198 description="Color for the text and lines",
199 default=(0.173, 0.545, 1.0, 1.0),
200 min=0.1,
201 max=1,
202 subtype='COLOR',
203 size=4,
205 Scene.archimesh_walltext_color = FloatVectorProperty(
206 name="Hint color",
207 description="Color for the wall label",
208 default=(1, 0.8, 0.1, 1.0),
209 min=0.1,
210 max=1,
211 subtype='COLOR',
212 size=4,
214 Scene.archimesh_font_size = IntProperty(
215 name="Text Size",
216 description="Text size for hints",
217 default=14, min=10, max=150,
219 Scene.archimesh_wfont_size = IntProperty(
220 name="Text Size",
221 description="Text size for wall labels",
222 default=16, min=10, max=150,
224 Scene.archimesh_hint_space = FloatProperty(
225 name='Separation', min=0, max=5, default=0.1,
226 precision=2,
227 description='Distance from object to display hint',
229 Scene.archimesh_gl_measure = BoolProperty(
230 name="Measures",
231 description="Display measures",
232 default=True,
234 Scene.archimesh_gl_name = BoolProperty(
235 name="Names",
236 description="Display names",
237 default=True,
239 Scene.archimesh_gl_ghost = BoolProperty(
240 name="All",
241 description="Display measures for all objects,"
242 " not only selected",
243 default=True,
246 # OpenGL flag
247 wm = WindowManager
248 # register internal property
249 wm.archimesh_run_opengl = BoolProperty(default=False)
252 def unregister():
253 from bpy.utils import unregister_class
254 for cls in reversed(classes):
255 unregister_class(cls)
257 VIEW3D_MT_mesh_add.remove(AchmMenu_func)
259 # Remove properties
260 del Scene.archimesh_select_only
261 del Scene.archimesh_ceiling
262 del Scene.archimesh_floor
263 del Scene.archimesh_merge
264 del Scene.archimesh_text_color
265 del Scene.archimesh_walltext_color
266 del Scene.archimesh_font_size
267 del Scene.archimesh_wfont_size
268 del Scene.archimesh_hint_space
269 del Scene.archimesh_gl_measure
270 del Scene.archimesh_gl_name
271 del Scene.archimesh_gl_ghost
272 # remove OpenGL data
273 achm_main_panel.ARCHIMESH_OT_HintDisplay.handle_remove(achm_main_panel.ARCHIMESH_OT_HintDisplay, bpy.context)
274 wm = bpy.context.window_manager
275 p = 'archimesh_run_opengl'
276 if p in wm:
277 del wm[p]
280 if __name__ == '__main__':
281 register()