diff options
author | Stephen Leger <stephen@3dservices.ch> | 2017-08-01 04:48:42 +0300 |
---|---|---|
committer | Stephen Leger <stephen@3dservices.ch> | 2017-08-01 04:51:01 +0300 |
commit | 45cad6756f10eb708d1a17dae4a70723accc1928 (patch) | |
tree | 48e189c5e9053f6c72547ebf425fbbd4966ef840 /archipack/archipack_reference_point.py | |
parent | 15ce79c680dd63e5d54cc8ec28ad2c4d87a813ac (diff) |
archipack: update to 1.2.8 add roof and freeform floors
Diffstat (limited to 'archipack/archipack_reference_point.py')
-rw-r--r-- | archipack/archipack_reference_point.py | 162 |
1 files changed, 137 insertions, 25 deletions
diff --git a/archipack/archipack_reference_point.py b/archipack/archipack_reference_point.py index d81a6839..5e8f1f59 100644 --- a/archipack/archipack_reference_point.py +++ b/archipack/archipack_reference_point.py @@ -29,7 +29,8 @@ from bpy.types import Operator, PropertyGroup, Object, Panel from bpy.props import ( FloatVectorProperty, CollectionProperty, - FloatProperty + FloatProperty, + EnumProperty ) from mathutils import Vector from .bmesh_utils import BmeshEdit as bmed @@ -55,6 +56,13 @@ class archipack_reference_point(PropertyGroup): default=1, min=0.01, update=update) + symbol_type = EnumProperty( + name="Symbol type", + default='WALL', + items=( + ('WALL', 'Wall', '', 0), + ('ROOF', 'Roof', '', 1)), + update=update) @classmethod def filter(cls, o): @@ -98,29 +106,61 @@ class archipack_reference_point(PropertyGroup): return s = self.symbol_scale - verts = [(s * x, s * y, s * z) for x, y, z in [ - (-0.25, 0.25, 0.0), (0.25, 0.25, 0.0), (-0.25, -0.25, 0.0), (0.25, -0.25, 0.0), - (0.0, 0.0, 0.487), (-0.107, 0.107, 0.216), (0.108, 0.107, 0.216), (-0.107, -0.107, 0.216), - (0.108, -0.107, 0.216), (-0.05, 0.05, 0.5), (0.05, 0.05, 0.5), (0.05, -0.05, 0.5), - (-0.05, -0.05, 0.5), (-0.193, 0.193, 0.0), (0.193, 0.193, 0.0), (0.193, -0.193, 0.0), - (-0.193, -0.193, 0.0), (0.0, 0.0, 0.8), (0.0, 0.8, -0.0), (0.0, 0.0, -0.0), - (0.0, 0.0, 0.0), (0.05, 0.05, 0.674), (-0.05, 0.674, -0.05), (0.0, 0.8, -0.0), - (-0.05, -0.05, 0.674), (-0.05, 0.674, 0.05), (0.05, 0.674, -0.05), (-0.129, 0.129, 0.162), - (0.129, 0.129, 0.162), (-0.129, -0.129, 0.162), (0.129, -0.129, 0.162), (0.0, 0.0, 0.8), - (-0.05, 0.05, 0.674), (0.05, -0.05, 0.674), (0.05, 0.674, 0.05), (0.8, -0.0, -0.0), - (0.0, -0.0, -0.0), (0.674, 0.05, -0.05), (0.8, -0.0, -0.0), (0.674, 0.05, 0.05), - (0.674, -0.05, -0.05), (0.674, -0.05, 0.05)]] - - edges = [(1, 0), (0, 9), (9, 10), (10, 1), (3, 1), (10, 11), - (11, 3), (2, 3), (11, 12), (12, 2), (0, 2), (12, 9), - (6, 5), (8, 6), (7, 8), (5, 7), (17, 24), (17, 20), - (18, 25), (18, 19), (13, 14), (14, 15), (15, 16), (16, 13), - (4, 6), (15, 30), (17, 21), (26, 22), (23, 22), (23, 34), - (18, 26), (28, 27), (30, 28), (29, 30), (27, 29), (14, 28), - (13, 27), (16, 29), (4, 7), (4, 8), (4, 5), (31, 33), - (31, 32), (21, 32), (24, 32), (24, 33), (21, 33), (25, 22), - (25, 34), (26, 34), (35, 39), (35, 36), (40, 37), (38, 37), - (38, 41), (35, 40), (39, 37), (39, 41), (40, 41)] + + if self.symbol_type == 'WALL': + + verts = [(s * x, s * y, s * z) for x, y, z in [ + (-0.25, 0.25, 0.0), (0.25, 0.25, 0.0), (-0.25, -0.25, 0.0), (0.25, -0.25, 0.0), + (0.0, 0.0, 0.487), (-0.107, 0.107, 0.216), (0.108, 0.107, 0.216), (-0.107, -0.107, 0.216), + (0.108, -0.107, 0.216), (-0.05, 0.05, 0.5), (0.05, 0.05, 0.5), (0.05, -0.05, 0.5), + (-0.05, -0.05, 0.5), (-0.193, 0.193, 0.0), (0.193, 0.193, 0.0), (0.193, -0.193, 0.0), + (-0.193, -0.193, 0.0), (0.0, 0.0, 0.8), (0.0, 0.8, -0.0), (0.0, 0.0, -0.0), + (0.0, 0.0, 0.0), (0.05, 0.05, 0.674), (-0.05, 0.674, -0.05), (0.0, 0.8, -0.0), + (-0.05, -0.05, 0.674), (-0.05, 0.674, 0.05), (0.05, 0.674, -0.05), (-0.129, 0.129, 0.162), + (0.129, 0.129, 0.162), (-0.129, -0.129, 0.162), (0.129, -0.129, 0.162), (0.0, 0.0, 0.8), + (-0.05, 0.05, 0.674), (0.05, -0.05, 0.674), (0.05, 0.674, 0.05), (0.8, -0.0, -0.0), + (0.0, -0.0, -0.0), (0.674, 0.05, -0.05), (0.8, -0.0, -0.0), (0.674, 0.05, 0.05), + (0.674, -0.05, -0.05), (0.674, -0.05, 0.05)]] + + edges = [(1, 0), (0, 9), (9, 10), (10, 1), (3, 1), (10, 11), + (11, 3), (2, 3), (11, 12), (12, 2), (0, 2), (12, 9), + (6, 5), (8, 6), (7, 8), (5, 7), (17, 24), (17, 20), + (18, 25), (18, 19), (13, 14), (14, 15), (15, 16), (16, 13), + (4, 6), (15, 30), (17, 21), (26, 22), (23, 22), (23, 34), + (18, 26), (28, 27), (30, 28), (29, 30), (27, 29), (14, 28), + (13, 27), (16, 29), (4, 7), (4, 8), (4, 5), (31, 33), + (31, 32), (21, 32), (24, 32), (24, 33), (21, 33), (25, 22), + (25, 34), (26, 34), (35, 39), (35, 36), (40, 37), (38, 37), + (38, 41), (35, 40), (39, 37), (39, 41), (40, 41)] + + elif self.symbol_type == 'ROOF': + + verts = [(s * x, s * y, s * z) for x, y, z in [ + (-0.25, 0.25, 0.0), (0.25, 0.25, 0.0), (-0.25, -0.25, 0.0), (0.25, -0.25, 0.0), + (0.0, 0.0, 0.487), (-0.107, 0.107, 0.216), (0.108, 0.107, 0.216), (-0.107, -0.107, 0.216), + (0.108, -0.107, 0.216), (-0.05, 0.05, 0.5), (0.05, 0.05, 0.5), (0.05, -0.05, 0.5), + (-0.05, -0.05, 0.5), (-0.193, 0.193, 0.0), (0.193, 0.193, 0.0), (0.193, -0.193, 0.0), + (-0.193, -0.193, 0.0), (0.0, 0.0, 0.8), (0.0, 0.8, -0.0), (0.0, 0.0, 0.0), + (0.05, 0.05, 0.673), (-0.05, 0.674, -0.05), (-0.05, -0.05, 0.673), (-0.05, 0.674, 0.05), + (0.05, 0.674, -0.05), (-0.129, 0.129, 0.162), (0.129, 0.129, 0.162), (-0.129, -0.129, 0.162), + (0.129, -0.129, 0.162), (-0.05, 0.05, 0.673), (0.05, -0.05, 0.673), (0.05, 0.674, 0.05), + (0.8, -0.0, -0.0), (0.674, 0.05, -0.05), (0.674, 0.05, 0.05), (0.674, -0.05, -0.05), + (0.674, -0.05, 0.05), (0.108, 0.0, 0.216), (0.09, 0.0, 0.261), (0.001, 0.107, 0.216), + (0.001, -0.107, 0.216), (-0.107, 0.0, 0.216), (0.0, -0.089, 0.261), (0.0, 0.089, 0.261), + (-0.089, 0.0, 0.261), (0.0, 0.042, 0.694), (-0.042, 0.0, 0.694), (0.0, -0.042, 0.694), + (0.042, 0.0, 0.694)]] + + edges = [ + (1, 0), (0, 9), (10, 1), (3, 1), (11, 3), (2, 3), (12, 2), (0, 2), + (17, 22), (17, 19), (18, 23), (13, 14), (14, 15), (15, 16), (16, 13), + (15, 28), (17, 20), (24, 21), (18, 24), (14, 26), (13, 25), (16, 27), + (45, 29), (46, 29), (47, 30), (48, 30), (23, 21), (23, 31), (24, 31), + (32, 34), (35, 33), (32, 35), (34, 33), (34, 36), (35, 36), (28, 37), + (6, 38), (26, 37), (26, 39), (25, 39), (5, 43), (5, 44), (25, 41), + (27, 41), (7, 44), (8, 42), (28, 40), (27, 40), (20, 45), (22, 46), + (22, 47), (20, 48), (18, 19), (18, 21), (18, 31), (17, 30), (17, 29), + (32, 19), (32, 33), (32, 36), (4, 6), (4, 7), (4, 8), (4, 5), (8, 38), + (6, 43), (7, 42), (9, 10), (10, 11), (11, 12), (12, 9)] bm = bmed._start(context, o) bm.clear() @@ -154,8 +194,9 @@ class ARCHIPACK_PT_reference_point(Panel): layout.operator('archipack.move_2d_reference_to_cursor') else: layout.operator('archipack.move_to_2d') - layout.prop(props, 'symbol_scale') + layout.separator() + layout.operator('archipack.apply_holes') class ARCHIPACK_OT_reference_point(Operator): @@ -170,6 +211,13 @@ class ARCHIPACK_OT_reference_point(Operator): name="position 3d", default=Vector((0, 0, 0)) ) + symbol_type = EnumProperty( + name="Symbol type", + default='WALL', + items=( + ('WALL', 'Wall', '', 0), + ('ROOF', 'Roof', '', 1)) + ) @classmethod def poll(cls, context): @@ -190,6 +238,7 @@ class ARCHIPACK_OT_reference_point(Operator): d = o.archipack_reference_point.add() d.location_2d = Vector((x, y, 0)) d.location_3d = self.location_3d + d.symbol_type = self.symbol_type o.select = True context.scene.objects.active = o d.update(context) @@ -230,6 +279,67 @@ class ARCHIPACK_OT_move_to_3d(Operator): return {'CANCELLED'} +class ARCHIPACK_OT_apply_holes(Operator): + bl_idname = "archipack.apply_holes" + bl_label = "Apply holes" + bl_description = "Apply and remove holes from scene" + bl_category = 'Archipack' + bl_options = {'REGISTER', 'UNDO'} + + @classmethod + def poll(cls, context): + return archipack_reference_point.filter(context.active_object) + + def apply_boolean(self, context, o): + # mods = [m for m in o.modifiers if m.type == 'BOOLEAN'] + ctx = bpy.context.copy() + ctx['object'] = o + for mod in o.modifiers[:]: + ctx['modifier'] = mod + try: + bpy.ops.object.modifier_apply(ctx, apply_as='DATA', + modifier=ctx['modifier'].name) + except: + pass + + def execute(self, context): + if context.mode == "OBJECT": + o = context.active_object + to_remove = [] + + for c in o.children: + if 'archipack_hybridhole' in c: + self.apply_boolean(context, c) + to_remove.append(c) + + for c in o.children: + if c.data is not None and "archipack_wall2" in c.data: + self.apply_boolean(context, c) + + for c in o.children: + if c.data is not None and ( + "archipack_window" in c.data or + "archipack_door" in c.data): + for h in c.children: + if "archipack_hole" in h: + to_remove.append(h) + + bpy.ops.object.select_all(action="DESELECT") + for r in to_remove: + r.hide_select = False + r.select = True + context.scene.objects.active = r + bpy.ops.object.delete(use_global=False) + + o.select = True + context.scene.objects.active = o + + return {'FINISHED'} + else: + self.report({'WARNING'}, "Archipack: Option only valid in Object mode") + return {'CANCELLED'} + + class ARCHIPACK_OT_move_to_2d(Operator): bl_idname = "archipack.move_to_2d" bl_label = "Move to 2d" @@ -354,6 +464,7 @@ def register(): bpy.utils.register_class(ARCHIPACK_OT_store_2d_reference) bpy.utils.register_class(ARCHIPACK_OT_move_2d_reference_to_cursor) bpy.utils.register_class(ARCHIPACK_OT_parent_to_reference) + bpy.utils.register_class(ARCHIPACK_OT_apply_holes) def unregister(): @@ -366,3 +477,4 @@ def unregister(): bpy.utils.unregister_class(ARCHIPACK_OT_store_2d_reference) bpy.utils.unregister_class(ARCHIPACK_OT_move_2d_reference_to_cursor) bpy.utils.unregister_class(ARCHIPACK_OT_parent_to_reference) + bpy.utils.unregister_class(ARCHIPACK_OT_apply_holes) |