3 # ##### BEGIN GPL LICENSE BLOCK #####
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 # ##### END GPL LICENSE BLOCK #####
23 # ----------------------------------------------------------
24 # Author: Stephen Leger (s-leger)
26 # ----------------------------------------------------------
30 'description': 'Architectural objects',
34 'version': (1, 2, 83),
35 'blender': (2, 80, 0),
36 'location': 'View3D > Sidebar > Create > Archipack',
38 'wiki_url': 'https://github.com/s-leger/archipack/wiki',
39 'tracker_url': 'https://github.com/s-leger/archipack/issues',
40 'link': 'https://github.com/s-leger/archipack',
41 'support': 'COMMUNITY',
42 'category': 'Add Mesh'
48 import importlib
as imp
49 imp
.reload(archipack_material
)
50 imp
.reload(archipack_snap
)
51 imp
.reload(archipack_manipulator
)
52 imp
.reload(archipack_reference_point
)
53 imp
.reload(archipack_autoboolean
)
54 imp
.reload(archipack_door
)
55 imp
.reload(archipack_window
)
56 imp
.reload(archipack_stair
)
57 imp
.reload(archipack_wall2
)
58 imp
.reload(archipack_roof
)
59 imp
.reload(archipack_slab
)
60 imp
.reload(archipack_fence
)
61 imp
.reload(archipack_truss
)
62 imp
.reload(archipack_floor
)
63 imp
.reload(archipack_rendering
)
65 # print("archipack: reload ready")
67 from . import archipack_material
68 from . import archipack_snap
69 from . import archipack_manipulator
70 from . import archipack_reference_point
71 from . import archipack_autoboolean
72 from . import archipack_door
73 from . import archipack_window
74 from . import archipack_stair
75 from . import archipack_wall2
76 from . import archipack_roof
77 from . import archipack_slab
78 from . import archipack_fence
79 from . import archipack_truss
80 from . import archipack_floor
81 from . import archipack_rendering
82 # print("archipack: ready")
84 # noinspection PyUnresolvedReferences
86 # noinspection PyUnresolvedReferences
87 from bpy
.types
import (
88 Panel
, WindowManager
, PropertyGroup
,
89 AddonPreferences
, Menu
91 from bpy
.props
import (
92 EnumProperty
, PointerProperty
,
93 StringProperty
, BoolProperty
,
94 IntProperty
, FloatProperty
, FloatVectorProperty
97 from bpy
.utils
import previews
101 # ----------------------------------------------------
103 # ----------------------------------------------------
106 class Archipack_Pref(AddonPreferences
):
109 create_submenu
: BoolProperty(
111 description
="Put Achipack's object into a sub menu (shift+a)",
114 max_style_draw_tool
: BoolProperty(
115 name
="Draw a wall use 3dsmax style",
116 description
="Reverse clic / release & drag cycle for Draw a wall",
119 # Arrow sizes (world units)
120 arrow_size
: FloatProperty(
122 description
="Manipulators arrow size (blender units)",
125 # Handle area size (pixels)
126 handle_size
: IntProperty(
128 description
="Manipulators handle sensitive area size (pixels)",
132 constant_handle_size
: BoolProperty(
133 name
="Constant handle size",
134 description
="When checked, handle size on scree remains constant (handle size pixels)",
137 text_size
: IntProperty(
139 description
="Manipulator font size (pixels)",
143 handle_colour_selected
: FloatVectorProperty(
144 name
="Selected handle colour",
145 description
="Handle color when selected",
146 subtype
='COLOR_GAMMA',
147 default
=(0.0, 0.0, 0.7, 1.0),
151 handle_colour_inactive
: FloatVectorProperty(
152 name
="Inactive handle colour",
153 description
="Handle color when disabled",
154 subtype
='COLOR_GAMMA',
155 default
=(0.3, 0.3, 0.3, 1.0),
159 handle_colour_normal
: FloatVectorProperty(
160 name
="Handle colour normal",
161 description
="Base handle color when not selected",
162 subtype
='COLOR_GAMMA',
163 default
=(1.0, 1.0, 1.0, 1.0),
167 handle_colour_hover
: FloatVectorProperty(
168 name
="Handle colour hover",
169 description
="Handle color when mouse hover",
170 subtype
='COLOR_GAMMA',
171 default
=(1.0, 1.0, 0.0, 1.0),
175 handle_colour_active
: FloatVectorProperty(
176 name
="Handle colour active",
177 description
="Handle colour when moving",
178 subtype
='COLOR_GAMMA',
179 default
=(1.0, 0.0, 0.0, 1.0),
183 matlib_path
: StringProperty(
185 description
="absolute path to material library folder",
189 # Font sizes and basic colour scheme
190 feedback_size_main
: IntProperty(
192 description
="Main title font size (pixels)",
196 feedback_size_title
: IntProperty(
198 description
="Tool name font size (pixels)",
202 feedback_size_shortcut
: IntProperty(
204 description
="Shortcuts font size (pixels)",
208 feedback_shortcut_area
: FloatVectorProperty(
209 name
="Background Shortcut",
210 description
="Shortcut area background color",
211 subtype
='COLOR_GAMMA',
212 default
=(0, 0.4, 0.6, 0.2),
216 feedback_title_area
: FloatVectorProperty(
217 name
="Background Main",
218 description
="Title area background color",
219 subtype
='COLOR_GAMMA',
220 default
=(0, 0.4, 0.6, 0.5),
224 feedback_colour_main
: FloatVectorProperty(
226 description
="Title color",
227 subtype
='COLOR_GAMMA',
228 default
=(0.95, 0.95, 0.95, 1.0),
232 feedback_colour_key
: FloatVectorProperty(
233 name
="Font Shortcut key",
234 description
="KEY label color",
235 subtype
='COLOR_GAMMA',
236 default
=(0.67, 0.67, 0.67, 1.0),
240 feedback_colour_shortcut
: FloatVectorProperty(
241 name
="Font Shortcut hint",
242 description
="Shortcuts text color",
243 subtype
='COLOR_GAMMA',
244 default
=(0.51, 0.51, 0.51, 1.0),
249 def draw(self
, context
):
254 col
.label(text
="Setup actions")
255 col
.prop(self
, "matlib_path", text
="Material library")
256 box
.label(text
="Render presets Thumbnails")
257 box
.operator("archipack.render_thumbs", icon
='ERROR')
261 col
.label(text
="Add menu:")
262 col
.prop(self
, "create_submenu")
265 box
.label(text
="Features")
266 box
.prop(self
, "max_style_draw_tool")
269 split
= row
.split(factor
=0.5)
271 col
.label(text
="Colors:")
272 row
= col
.row(align
=True)
273 row
.prop(self
, "feedback_title_area")
274 row
= col
.row(align
=True)
275 row
.prop(self
, "feedback_shortcut_area")
276 row
= col
.row(align
=True)
277 row
.prop(self
, "feedback_colour_main")
278 row
= col
.row(align
=True)
279 row
.prop(self
, "feedback_colour_key")
280 row
= col
.row(align
=True)
281 row
.prop(self
, "feedback_colour_shortcut")
282 row
= col
.row(align
=True)
283 row
.prop(self
, "handle_colour_normal")
284 row
= col
.row(align
=True)
285 row
.prop(self
, "handle_colour_hover")
286 row
= col
.row(align
=True)
287 row
.prop(self
, "handle_colour_active")
288 row
= col
.row(align
=True)
289 row
.prop(self
, "handle_colour_selected")
290 row
= col
.row(align
=True)
291 row
.prop(self
, "handle_colour_inactive")
293 col
.label(text
="Font size:")
294 col
.prop(self
, "feedback_size_main")
295 col
.prop(self
, "feedback_size_title")
296 col
.prop(self
, "feedback_size_shortcut")
297 col
.label(text
="Manipulators:")
298 col
.prop(self
, "arrow_size")
299 col
.prop(self
, "handle_size")
300 col
.prop(self
, "text_size")
301 col
.prop(self
, "constant_handle_size")
303 # ----------------------------------------------------
305 # ----------------------------------------------------
307 class TOOLS_PT_Archipack_Create(Panel
):
308 bl_label
= "Archipack"
309 bl_idname
= "TOOLS_PT_Archipack_Create"
310 bl_space_type
= "VIEW_3D"
311 bl_region_type
= "UI"
312 bl_category
= "Create"
313 bl_context
= "objectmode"
314 bl_options
= {'DEFAULT_CLOSED'}
317 def poll(self
, context
):
320 def draw(self
, context
):
321 global icons_collection
323 icons
= icons_collection
["main"]
326 box
.operator("archipack.auto_boolean", text
="Boolean", icon
='AUTO').mode
= 'HYBRID'
327 row
= layout
.row(align
=True)
329 box
.label(text
="Create")
330 row
= box
.row(align
=True)
331 row
.operator("archipack.window_preset_menu",
333 icon_value
=icons
["window"].icon_id
334 ).preset_operator
= "archipack.window"
335 row
.operator("archipack.window_preset_menu",
338 ).preset_operator
= "archipack.window_draw"
339 row
= box
.row(align
=True)
340 row
.operator("archipack.door_preset_menu",
342 icon_value
=icons
["door"].icon_id
343 ).preset_operator
= "archipack.door"
344 row
.operator("archipack.door_preset_menu",
347 ).preset_operator
= "archipack.door_draw"
348 row
= box
.row(align
=True)
349 row
.operator("archipack.stair_preset_menu",
351 icon_value
=icons
["stair"].icon_id
352 ).preset_operator
= "archipack.stair"
353 row
= box
.row(align
=True)
354 row
.operator("archipack.wall2",
355 icon_value
=icons
["wall"].icon_id
357 row
.operator("archipack.wall2_draw", text
="Draw", icon
='GREASEPENCIL')
358 row
.operator("archipack.wall2_from_curve", text
="", icon
='CURVE_DATA')
360 row
= box
.row(align
=True)
361 row
.operator("archipack.fence_preset_menu",
363 icon_value
=icons
["fence"].icon_id
364 ).preset_operator
= "archipack.fence"
365 row
.operator("archipack.fence_from_curve", text
="", icon
='CURVE_DATA')
366 row
= box
.row(align
=True)
367 row
.operator("archipack.truss",
368 icon_value
=icons
["truss"].icon_id
370 row
= box
.row(align
=True)
371 row
.operator("archipack.slab_from_curve",
372 icon_value
=icons
["slab"].icon_id
374 row
= box
.row(align
=True)
375 row
.operator("archipack.wall2_from_slab",
376 icon_value
=icons
["wall"].icon_id
)
377 row
.operator("archipack.slab_from_wall",
378 icon_value
=icons
["slab"].icon_id
380 row
.operator("archipack.slab_from_wall",
382 icon_value
=icons
["slab"].icon_id
384 row
= box
.row(align
=True)
385 row
.operator("archipack.roof_preset_menu",
387 icon_value
=icons
["roof"].icon_id
388 ).preset_operator
= "archipack.roof"
389 row
= box
.row(align
=True)
390 row
.operator("archipack.floor_preset_menu",
392 icon_value
=icons
["floor"].icon_id
393 ).preset_operator
= "archipack.floor"
394 row
.operator("archipack.floor_preset_menu",
396 icon_value
=icons
["floor"].icon_id
397 ).preset_operator
= "archipack.floor_from_wall"
398 row
.operator("archipack.floor_preset_menu",
400 icon
='CURVE_DATA').preset_operator
= "archipack.floor_from_curve"
403 # ----------------------------------------------------
405 # ----------------------------------------------------
408 def draw_menu(self
, context
):
409 global icons_collection
410 icons
= icons_collection
["main"]
412 layout
.operator_context
= 'INVOKE_REGION_WIN'
414 layout
.operator("archipack.wall2",
416 icon_value
=icons
["wall"].icon_id
418 layout
.operator("archipack.window_preset_menu",
420 icon_value
=icons
["window"].icon_id
421 ).preset_operator
= "archipack.window"
422 layout
.operator("archipack.door_preset_menu",
424 icon_value
=icons
["door"].icon_id
425 ).preset_operator
= "archipack.door"
426 layout
.operator("archipack.stair_preset_menu",
428 icon_value
=icons
["stair"].icon_id
429 ).preset_operator
= "archipack.stair"
430 layout
.operator("archipack.fence_preset_menu",
432 icon_value
=icons
["fence"].icon_id
433 ).preset_operator
= "archipack.fence"
434 layout
.operator("archipack.truss",
436 icon_value
=icons
["truss"].icon_id
438 layout
.operator("archipack.floor_preset_menu",
440 icon_value
=icons
["floor"].icon_id
441 ).preset_operator
= "archipack.floor"
442 layout
.operator("archipack.roof_preset_menu",
444 icon_value
=icons
["roof"].icon_id
445 ).preset_operator
= "archipack.roof"
448 class ARCHIPACK_MT_create(Menu
):
449 bl_label
= 'Archipack'
451 def draw(self
, context
):
452 draw_menu(self
, context
)
455 def menu_func(self
, context
):
458 global icons_collection
459 icons
= icons_collection
["main"]
461 # either draw sub menu or right at end of this one
462 if context
.preferences
.addons
[__name__
].preferences
.create_submenu
:
463 layout
.operator_context
= 'INVOKE_REGION_WIN'
464 layout
.menu("ARCHIPACK_MT_create", icon_value
=icons
["archipack"].icon_id
)
466 draw_menu(self
, context
)
470 global icons_collection
471 icons
= previews
.new()
472 icons_dir
= os
.path
.join(os
.path
.dirname(__file__
), "icons")
473 for icon
in os
.listdir(icons_dir
):
474 name
, ext
= os
.path
.splitext(icon
)
475 icons
.load(name
, os
.path
.join(icons_dir
, icon
), 'IMAGE')
476 icons_collection
["main"] = icons
477 archipack_material
.register()
478 archipack_snap
.register()
479 archipack_manipulator
.register()
480 archipack_reference_point
.register()
481 archipack_autoboolean
.register()
482 archipack_door
.register()
483 archipack_window
.register()
484 archipack_stair
.register()
485 archipack_wall2
.register()
486 archipack_roof
.register()
487 archipack_slab
.register()
488 archipack_fence
.register()
489 archipack_truss
.register()
490 archipack_floor
.register()
491 archipack_rendering
.register()
492 bpy
.utils
.register_class(Archipack_Pref
)
493 bpy
.utils
.register_class(TOOLS_PT_Archipack_Create
)
494 bpy
.utils
.register_class(ARCHIPACK_MT_create
)
495 bpy
.types
.VIEW3D_MT_mesh_add
.append(menu_func
)
499 global icons_collection
500 bpy
.types
.VIEW3D_MT_mesh_add
.remove(menu_func
)
501 bpy
.utils
.unregister_class(ARCHIPACK_MT_create
)
502 bpy
.utils
.unregister_class(TOOLS_PT_Archipack_Create
)
503 bpy
.utils
.unregister_class(Archipack_Pref
)
504 archipack_material
.unregister()
505 archipack_snap
.unregister()
506 archipack_manipulator
.unregister()
507 archipack_reference_point
.unregister()
508 archipack_autoboolean
.unregister()
509 archipack_door
.unregister()
510 archipack_window
.unregister()
511 archipack_stair
.unregister()
512 archipack_wall2
.unregister()
513 archipack_roof
.unregister()
514 archipack_slab
.unregister()
515 archipack_fence
.unregister()
516 archipack_truss
.unregister()
517 archipack_floor
.unregister()
518 archipack_rendering
.unregister()
520 for icons
in icons_collection
.values():
521 previews
.remove(icons
)
522 icons_collection
.clear()
525 if __name__
== "__main__":