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',
36 'location': 'View3D > Tools > 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_progressbar
)
50 imp
.reload(archipack_material
)
51 imp
.reload(archipack_snap
)
52 imp
.reload(archipack_manipulator
)
53 imp
.reload(archipack_reference_point
)
54 imp
.reload(archipack_autoboolean
)
55 imp
.reload(archipack_door
)
56 imp
.reload(archipack_window
)
57 imp
.reload(archipack_stair
)
58 imp
.reload(archipack_wall2
)
59 imp
.reload(archipack_roof
)
60 imp
.reload(archipack_slab
)
61 imp
.reload(archipack_fence
)
62 imp
.reload(archipack_truss
)
63 imp
.reload(archipack_floor
)
64 imp
.reload(archipack_rendering
)
66 # print("archipack: reload ready")
68 from . import archipack_progressbar
69 from . import archipack_material
70 from . import archipack_snap
71 from . import archipack_manipulator
72 from . import archipack_reference_point
73 from . import archipack_autoboolean
74 from . import archipack_door
75 from . import archipack_window
76 from . import archipack_stair
77 from . import archipack_wall2
78 from . import archipack_roof
79 from . import archipack_slab
80 from . import archipack_fence
81 from . import archipack_truss
82 from . import archipack_floor
83 from . import archipack_rendering
85 # print("archipack: ready")
87 # noinspection PyUnresolvedReferences
89 # noinspection PyUnresolvedReferences
90 from bpy
.types
import (
91 Panel
, WindowManager
, PropertyGroup
,
92 AddonPreferences
, Menu
94 from bpy
.props
import (
95 EnumProperty
, PointerProperty
,
96 StringProperty
, BoolProperty
,
97 IntProperty
, FloatProperty
, FloatVectorProperty
100 from bpy
.utils
import previews
101 icons_collection
= {}
104 # ----------------------------------------------------
106 # ----------------------------------------------------
108 def update_panel(self
, context
):
110 bpy
.utils
.unregister_class(TOOLS_PT_Archipack_Tools
)
111 bpy
.utils
.unregister_class(TOOLS_PT_Archipack_Create
)
114 prefs
= context
.user_preferences
.addons
[__name__
].preferences
115 TOOLS_PT_Archipack_Tools
.bl_category
= prefs
.tools_category
116 bpy
.utils
.register_class(TOOLS_PT_Archipack_Tools
)
117 TOOLS_PT_Archipack_Create
.bl_category
= prefs
.create_category
118 bpy
.utils
.register_class(TOOLS_PT_Archipack_Create
)
121 class Archipack_Pref(AddonPreferences
):
124 tools_category
= StringProperty(
126 description
="Choose a name for the category of the Tools panel",
130 create_category
= StringProperty(
132 description
="Choose a name for the category of the Create panel",
136 create_submenu
= BoolProperty(
138 description
="Put Achipack's object into a sub menu (shift+a)",
141 max_style_draw_tool
= BoolProperty(
142 name
="Draw a wall use 3dsmax style",
143 description
="Reverse clic / release & drag cycle for Draw a wall",
146 # Arrow sizes (world units)
147 arrow_size
= FloatProperty(
149 description
="Manipulators arrow size (blender units)",
152 # Handle area size (pixels)
153 handle_size
= IntProperty(
155 description
="Manipulators handle sensitive area size (pixels)",
159 matlib_path
= StringProperty(
161 description
="absolute path to material library folder",
164 # Font sizes and basic colour scheme
165 feedback_size_main
= IntProperty(
167 description
="Main title font size (pixels)",
171 feedback_size_title
= IntProperty(
173 description
="Tool name font size (pixels)",
177 feedback_size_shortcut
= IntProperty(
179 description
="Shortcuts font size (pixels)",
183 feedback_shortcut_area
= FloatVectorProperty(
184 name
="Background Shortcut",
185 description
="Shortcut area background color",
186 subtype
='COLOR_GAMMA',
187 default
=(0, 0.4, 0.6, 0.2),
191 feedback_title_area
= FloatVectorProperty(
192 name
="Background Main",
193 description
="Title area background color",
194 subtype
='COLOR_GAMMA',
195 default
=(0, 0.4, 0.6, 0.5),
199 feedback_colour_main
= FloatVectorProperty(
201 description
="Title color",
202 subtype
='COLOR_GAMMA',
203 default
=(0.95, 0.95, 0.95, 1.0),
207 feedback_colour_key
= FloatVectorProperty(
208 name
="Font Shortcut key",
209 description
="KEY label color",
210 subtype
='COLOR_GAMMA',
211 default
=(0.67, 0.67, 0.67, 1.0),
215 feedback_colour_shortcut
= FloatVectorProperty(
216 name
="Font Shortcut hint",
217 description
="Shortcuts text color",
218 subtype
='COLOR_GAMMA',
219 default
=(0.51, 0.51, 0.51, 1.0),
224 def draw(self
, context
):
229 col
.label(text
="Tab Category:")
230 col
.prop(self
, "tools_category")
231 col
.prop(self
, "create_category")
232 col
.prop(self
, "create_submenu")
234 box
.label("Features")
235 box
.prop(self
, "max_style_draw_tool")
239 col
.label(text
="Material library:")
240 col
.prop(self
, "matlib_path")
243 split
= row
.split(percentage
=0.5)
245 col
.label(text
="Colors:")
246 row
= col
.row(align
=True)
247 row
.prop(self
, "feedback_title_area")
248 row
= col
.row(align
=True)
249 row
.prop(self
, "feedback_shortcut_area")
250 row
= col
.row(align
=True)
251 row
.prop(self
, "feedback_colour_main")
252 row
= col
.row(align
=True)
253 row
.prop(self
, "feedback_colour_key")
254 row
= col
.row(align
=True)
255 row
.prop(self
, "feedback_colour_shortcut")
257 col
.label(text
="Font size:")
258 col
.prop(self
, "feedback_size_main")
259 col
.prop(self
, "feedback_size_title")
260 col
.prop(self
, "feedback_size_shortcut")
261 col
.label(text
="Manipulators:")
262 col
.prop(self
, "arrow_size")
263 col
.prop(self
, "handle_size")
264 # layout.operator("archipack.render_thumbs")
266 # ----------------------------------------------------
268 # ----------------------------------------------------
271 class TOOLS_PT_Archipack_Tools(Panel
):
272 bl_label
= "Archipack Tools"
273 bl_idname
= "TOOLS_PT_Archipack_Tools"
274 bl_space_type
= "VIEW_3D"
275 bl_region_type
= "TOOLS"
276 bl_category
= "Tools"
277 bl_context
= "objectmode"
280 def poll(self
, context
):
283 def draw(self
, context
):
284 wm
= context
.window_manager
287 box
.label("Auto boolean")
288 box
.operator("archipack.auto_boolean", text
="AutoBoolean", icon
='AUTO').mode
= 'HYBRID'
290 box
.label("Rendering")
291 box
.prop(wm
.archipack
, 'render_type', text
="")
292 box
.operator("archipack.render", icon
='RENDER_STILL')
294 box
.label("Render presets Thumbnails")
295 box
.operator("archipack.render_thumbs", icon
='ERROR')
298 class TOOLS_PT_Archipack_Create(Panel
):
299 bl_label
= "Add Archipack"
300 bl_idname
= "TOOLS_PT_Archipack_Create"
301 bl_space_type
= "VIEW_3D"
302 bl_region_type
= "TOOLS"
303 bl_category
= "Create"
304 bl_context
= "objectmode"
307 def poll(self
, context
):
310 def draw(self
, context
):
311 global icons_collection
313 icons
= icons_collection
["main"]
315 row
= layout
.row(align
=True)
318 row
= box
.row(align
=True)
319 row
.operator("archipack.window_preset_menu",
321 icon_value
=icons
["window"].icon_id
322 ).preset_operator
= "archipack.window"
323 row
.operator("archipack.window_preset_menu",
326 ).preset_operator
= "archipack.window_draw"
327 row
= box
.row(align
=True)
328 row
.operator("archipack.door_preset_menu",
330 icon_value
=icons
["door"].icon_id
331 ).preset_operator
= "archipack.door"
332 row
.operator("archipack.door_preset_menu",
335 ).preset_operator
= "archipack.door_draw"
336 row
= box
.row(align
=True)
337 row
.operator("archipack.stair_preset_menu",
339 icon_value
=icons
["stair"].icon_id
340 ).preset_operator
= "archipack.stair"
341 row
= box
.row(align
=True)
342 row
.operator("archipack.wall2",
343 icon_value
=icons
["wall"].icon_id
345 row
.operator("archipack.wall2_draw", text
="Draw", icon
='GREASEPENCIL')
346 row
.operator("archipack.wall2_from_curve", text
="", icon
='CURVE_DATA')
348 row
= box
.row(align
=True)
349 row
.operator("archipack.fence_preset_menu",
351 icon_value
=icons
["fence"].icon_id
352 ).preset_operator
= "archipack.fence"
353 row
.operator("archipack.fence_from_curve", text
="", icon
='CURVE_DATA')
354 row
= box
.row(align
=True)
355 row
.operator("archipack.truss",
356 icon_value
=icons
["truss"].icon_id
358 row
= box
.row(align
=True)
359 row
.operator("archipack.slab_from_curve",
360 icon_value
=icons
["slab"].icon_id
362 row
= box
.row(align
=True)
363 row
.operator("archipack.wall2_from_slab",
364 icon_value
=icons
["wall"].icon_id
)
365 row
.operator("archipack.slab_from_wall",
366 icon_value
=icons
["slab"].icon_id
368 row
.operator("archipack.slab_from_wall",
370 icon_value
=icons
["slab"].icon_id
372 row
= box
.row(align
=True)
373 row
.operator("archipack.roof_preset_menu",
375 icon_value
=icons
["roof"].icon_id
376 ).preset_operator
= "archipack.roof"
377 row
= box
.row(align
=True)
378 row
.operator("archipack.floor_preset_menu",
380 icon_value
=icons
["floor"].icon_id
381 ).preset_operator
= "archipack.floor"
382 row
.operator("archipack.floor_preset_menu",
384 icon_value
=icons
["floor"].icon_id
385 ).preset_operator
= "archipack.floor_from_wall"
386 row
.operator("archipack.floor_preset_menu",
388 icon
='CURVE_DATA').preset_operator
= "archipack.floor_from_curve"
391 # ----------------------------------------------------
393 # ----------------------------------------------------
396 def draw_menu(self
, context
):
397 global icons_collection
398 icons
= icons_collection
["main"]
400 layout
.operator_context
= 'INVOKE_REGION_WIN'
402 layout
.operator("archipack.wall2",
404 icon_value
=icons
["wall"].icon_id
406 layout
.operator("archipack.window_preset_menu",
408 icon_value
=icons
["window"].icon_id
409 ).preset_operator
= "archipack.window"
410 layout
.operator("archipack.door_preset_menu",
412 icon_value
=icons
["door"].icon_id
413 ).preset_operator
= "archipack.door"
414 layout
.operator("archipack.stair_preset_menu",
416 icon_value
=icons
["stair"].icon_id
417 ).preset_operator
= "archipack.stair"
418 layout
.operator("archipack.fence_preset_menu",
420 icon_value
=icons
["fence"].icon_id
421 ).preset_operator
= "archipack.fence"
422 layout
.operator("archipack.truss",
424 icon_value
=icons
["truss"].icon_id
426 layout
.operator("archipack.floor_preset_menu",
428 icon_value
=icons
["floor"].icon_id
429 ).preset_operator
= "archipack.floor"
430 layout
.operator("archipack.roof_preset_menu",
432 icon_value
=icons
["roof"].icon_id
433 ).preset_operator
= "archipack.roof"
436 class ARCHIPACK_MT_create(Menu
):
437 bl_label
= 'Archipack'
439 def draw(self
, context
):
440 draw_menu(self
, context
)
443 def menu_func(self
, context
):
446 global icons_collection
447 icons
= icons_collection
["main"]
449 # either draw sub menu or right at end of this one
450 if context
.user_preferences
.addons
[__name__
].preferences
.create_submenu
:
451 layout
.operator_context
= 'INVOKE_REGION_WIN'
452 layout
.menu("ARCHIPACK_MT_create", icon_value
=icons
["archipack"].icon_id
)
454 draw_menu(self
, context
)
457 # ----------------------------------------------------
458 # Datablock to store global addon variables
459 # ----------------------------------------------------
462 class archipack_data(PropertyGroup
):
463 render_type
= EnumProperty(
465 ('1', "Draw over", "Draw over last rendered image"),
467 ('3', "Animation OpenGL", ""),
468 ('4', "Image", "Render image and draw over"),
469 ('5', "Animation", "Draw on each frame")
472 description
="Render method"
477 global icons_collection
478 icons
= previews
.new()
479 icons_dir
= os
.path
.join(os
.path
.dirname(__file__
), "icons")
480 for icon
in os
.listdir(icons_dir
):
481 name
, ext
= os
.path
.splitext(icon
)
482 icons
.load(name
, os
.path
.join(icons_dir
, icon
), 'IMAGE')
483 icons_collection
["main"] = icons
485 archipack_progressbar
.register()
486 archipack_material
.register()
487 archipack_snap
.register()
488 archipack_manipulator
.register()
489 archipack_reference_point
.register()
490 archipack_autoboolean
.register()
491 archipack_door
.register()
492 archipack_window
.register()
493 archipack_stair
.register()
494 archipack_wall2
.register()
495 archipack_roof
.register()
496 archipack_slab
.register()
497 archipack_fence
.register()
498 archipack_truss
.register()
499 archipack_floor
.register()
500 archipack_rendering
.register()
502 bpy
.utils
.register_class(archipack_data
)
503 WindowManager
.archipack
= PointerProperty(type=archipack_data
)
504 bpy
.utils
.register_class(Archipack_Pref
)
505 update_panel(None, bpy
.context
)
506 bpy
.utils
.register_class(ARCHIPACK_MT_create
)
507 bpy
.types
.INFO_MT_mesh_add
.append(menu_func
)
511 global icons_collection
512 bpy
.types
.INFO_MT_mesh_add
.remove(menu_func
)
513 bpy
.utils
.unregister_class(ARCHIPACK_MT_create
)
515 bpy
.utils
.unregister_class(TOOLS_PT_Archipack_Tools
)
516 bpy
.utils
.unregister_class(TOOLS_PT_Archipack_Create
)
517 bpy
.utils
.unregister_class(Archipack_Pref
)
518 archipack_progressbar
.unregister()
519 archipack_material
.unregister()
520 archipack_snap
.unregister()
521 archipack_manipulator
.unregister()
522 archipack_reference_point
.unregister()
523 archipack_autoboolean
.unregister()
524 archipack_door
.unregister()
525 archipack_window
.unregister()
526 archipack_stair
.unregister()
527 archipack_wall2
.unregister()
528 archipack_roof
.unregister()
529 archipack_slab
.unregister()
530 archipack_fence
.unregister()
531 archipack_truss
.unregister()
532 archipack_floor
.unregister()
533 archipack_rendering
.unregister()
535 bpy
.utils
.unregister_class(archipack_data
)
536 del WindowManager
.archipack
538 for icons
in icons_collection
.values():
539 previews
.remove(icons
)
540 icons_collection
.clear()
543 if __name__
== "__main__":