Skip to content

Commit 04bdb12

Browse files
committed
Window Modifier - added mullions/transoms, removed relative panel dimensions
1 parent d69f6c0 commit 04bdb12

4 files changed

Lines changed: 282 additions & 279 deletions

File tree

src/blenderbim/blenderbim/bim/module/model/prop.py

Lines changed: 50 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -301,15 +301,9 @@ class BIMSverchokProperties(PropertyGroup):
301301

302302

303303
def window_type_prop_update(self, context):
304-
panels_data = self.window_types_panels[self.window_type]
305-
for i in range(3):
306-
try:
307-
width, height = panels_data[i]
308-
except IndexError:
309-
width, height = (0.0, 0.0)
310-
311-
self.relative_width[i] = width
312-
self.relative_height[i] = height
304+
number_of_panels, panels_data = self.window_types_panels[self.window_type]
305+
self.first_mullion_offset, self.second_mullion_offset = panels_data[0]
306+
self.first_transom_offset, self.second_transom_offset = panels_data[1]
313307

314308

315309
class BIMWindowProperties(PropertyGroup):
@@ -325,17 +319,17 @@ class BIMWindowProperties(PropertyGroup):
325319
("TRIPLE_PANEL_VERTICAL", "TRIPLE_PANEL_VERTICAL", ""),
326320
)
327321

328-
# default panel relative dimensions
322+
# number of panels and default mullion/transom values
329323
window_types_panels = {
330-
"SINGLE_PANEL": ((1.0, 1.0), ),
331-
"DOUBLE_PANEL_HORIZONTAL": ((1.0, 0.5), (1.0, 0.5), ),
332-
"DOUBLE_PANEL_VERTICAL": ((0.5, 1.0), (0.5, 1.0), ),
333-
"TRIPLE_PANEL_BOTTOM": ((0.5, 0.5), (0.5, 0.5), (1.0, 0.5), ),
334-
"TRIPLE_PANEL_TOP": ((1.0, 0.5), (0.5, 0.5), (0.5, 0.5), ),
335-
"TRIPLE_PANEL_LEFT": ((0.5, 1.0), (0.5, 0.5), (0.5, 0.5), ),
336-
"TRIPLE_PANEL_RIGHT": ((0.5, 0.5), (0.5, 1.0), (0.5, 0.5), ),
337-
"TRIPLE_PANEL_HORIZONTAL": ((1.0, 1/3), (1.0, 1/3), (1.0, 1/3),),
338-
"TRIPLE_PANEL_VERTICAL": ((1/3, 1.0), (1/3, 1.0), (1/3, 1.0),),
324+
"SINGLE_PANEL": (1, ((0, 0 ), (0, 0 ))),
325+
"DOUBLE_PANEL_HORIZONTAL": (2, ((0, 0 ), (450, 0 ))),
326+
"DOUBLE_PANEL_VERTICAL": (2, ((300, 0 ), (0, 0 ))),
327+
"TRIPLE_PANEL_BOTTOM": (3, ((300, 0 ), (450, 0 ))),
328+
"TRIPLE_PANEL_TOP": (3, ((300, 0 ), (450, 0 ))),
329+
"TRIPLE_PANEL_LEFT": (3, ((300, 0 ), (450, 0 ))),
330+
"TRIPLE_PANEL_RIGHT": (3, ((300, 0 ), (450, 0 ))),
331+
"TRIPLE_PANEL_HORIZONTAL": (3, ((0, 0 ), (300, 600))),
332+
"TRIPLE_PANEL_VERTICAL": (3, ((200, 400), (0, 0 ))),
339333
}
340334

341335
is_editing: bpy.props.IntProperty(default=-1)
@@ -351,14 +345,16 @@ class BIMWindowProperties(PropertyGroup):
351345
lining_offset: bpy.props.FloatProperty(name="Lining Offset", default=50)
352346
lining_to_panel_offset_x: bpy.props.FloatProperty(name="Lining to Panel Offset X", default=25)
353347
lining_to_panel_offset_y: bpy.props.FloatProperty(name="Lining to Panel Offset Y", default=25)
354-
mullion_thickness: bpy.props.FloatProperty(name="(not used) Mullion Thickness")
355-
transom_thickness: bpy.props.FloatProperty(name="(not used) Transom Thickness")
348+
mullion_thickness: bpy.props.FloatProperty(name="Mullion Thickness", default=50)
349+
first_mullion_offset: bpy.props.FloatProperty(name="First Mullion Offset", default=300)
350+
second_mullion_offset: bpy.props.FloatProperty(name="Second Mullion Offset", default=450)
351+
transom_thickness: bpy.props.FloatProperty(name="Transom Thickness", default=50)
352+
first_transom_offset: bpy.props.FloatProperty(name="First Transom Offset", default=300)
353+
second_transom_offset: bpy.props.FloatProperty(name="Second Transom Offset", default=600)
356354

357355
# panel_properties
358356
frame_depth: bpy.props.FloatVectorProperty(name="Frame Depth", size=3, default=[35] * 3)
359357
frame_thickness: bpy.props.FloatVectorProperty(name="Frame Thickness", size=3, default=[35] * 3)
360-
relative_width: bpy.props.FloatVectorProperty(name="Relative Width", size=3, default=[1, 0, 0])
361-
relative_height: bpy.props.FloatVectorProperty(name="Relative Height", size=3, default=[1, 0, 0])
362358

363359
def get_general_kwargs(self):
364360
return {
@@ -368,20 +364,46 @@ def get_general_kwargs(self):
368364
}
369365

370366
def get_lining_kwargs(self):
371-
return {
367+
kwargs = {
372368
"lining_depth": self.lining_depth,
373369
"lining_thickness": self.lining_thickness,
374370
"lining_offset": self.lining_offset,
375371
"lining_to_panel_offset_x": self.lining_to_panel_offset_x,
376372
"lining_to_panel_offset_y": self.lining_to_panel_offset_y,
377-
"mullion_thickness": self.mullion_thickness,
378-
"transom_thickness": self.transom_thickness,
379373
}
380374

375+
if self.window_type in (
376+
"DOUBLE_PANEL_VERTICAL",
377+
"TRIPLE_PANEL_BOTTOM",
378+
"TRIPLE_PANEL_TOP",
379+
"TRIPLE_PANEL_LEFT",
380+
"TRIPLE_PANEL_RIGHT",
381+
"TRIPLE_PANEL_VERTICAL",
382+
):
383+
kwargs["mullion_thickness"] = self.mullion_thickness
384+
kwargs["first_mullion_offset"] = self.first_mullion_offset
385+
386+
if self.window_type in (
387+
"DOUBLE_PANEL_HORIZONTAL",
388+
"TRIPLE_PANEL_BOTTOM",
389+
"TRIPLE_PANEL_TOP",
390+
"TRIPLE_PANEL_LEFT",
391+
"TRIPLE_PANEL_RIGHT",
392+
"TRIPLE_PANEL_HORIZONTAL",
393+
):
394+
kwargs["transom_thickness"] = self.transom_thickness
395+
kwargs["first_transom_offset"] = self.first_transom_offset
396+
397+
if self.window_type in ("TRIPLE_PANEL_VERTICAL",):
398+
kwargs["second_mullion_offset"] = self.second_mullion_offset
399+
400+
if self.window_type in ("TRIPLE_PANEL_HORIZONTAL",):
401+
kwargs["second_transom_offset"] = self.second_transom_offset
402+
403+
return kwargs
404+
381405
def get_panel_kwargs(self):
382406
return {
383407
"frame_depth": self.frame_depth,
384408
"frame_thickness": self.frame_thickness,
385-
"relative_width": self.relative_width,
386-
"relative_height": self.relative_height,
387409
}

src/blenderbim/blenderbim/bim/module/model/ui.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ def draw(self, context):
429429
row.label(text="Window parameters", icon="OUTLINER_OB_LATTICE")
430430

431431
window_data = WindowData.data["parameters"]["data"]
432+
number_of_panels, panels_data = props.window_types_panels[props.window_type]
432433

433434
if props.is_editing != -1:
434435
row = self.layout.row(align=True)
@@ -446,7 +447,6 @@ def draw(self, context):
446447

447448
panel_props = props.get_panel_kwargs()
448449
self.layout.label(text="Panel properties")
449-
number_of_panels = len(props.window_types_panels[props.window_type])
450450

451451
panel_box = self.layout.box()
452452
row = panel_box.row()
@@ -492,7 +492,6 @@ def draw(self, context):
492492

493493
panel_props = props.get_panel_kwargs()
494494
self.layout.label(text="Panel properties")
495-
number_of_panels = len(props.window_types_panels[props.window_type])
496495

497496
panel_box = self.layout.box()
498497
row = panel_box.row()

src/blenderbim/blenderbim/bim/module/model/window.py

Lines changed: 90 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
from os.path import basename, dirname
3838
import json
39+
import collections
3940

4041

4142
V = lambda *x: Vector([float(i) for i in x])
@@ -55,16 +56,20 @@ def update_window_modifier_representation(context):
5556
"LiningOffset": props.lining_offset,
5657
"LiningToPanelOffsetX": props.lining_to_panel_offset_x,
5758
"LiningToPanelOffsetY": props.lining_to_panel_offset_y,
59+
"MullionThickness": props.mullion_thickness,
60+
"FirstMullionOffset": props.first_mullion_offset,
61+
"SecondMullionOffset": props.second_mullion_offset,
62+
"TransomThickness": props.transom_thickness,
63+
"FirstTransomOffset": props.first_transom_offset,
64+
"SecondTransomOffset": props.second_transom_offset,
5865
},
5966
"panel_properties": [],
6067
}
61-
number_of_panels = len(props.window_types_panels[props.window_type])
68+
number_of_panels, panels_data = props.window_types_panels[props.window_type]
6269
for panel_i in range(number_of_panels):
6370
panel_data = {
6471
"FrameDepth": props.frame_depth[panel_i],
6572
"FrameThickness": props.frame_thickness[panel_i],
66-
"RelativeWidth": props.relative_width[panel_i],
67-
"RelativeHeight": props.relative_height[panel_i],
6873
}
6974
representation_data["panel_properties"].append(panel_data)
7075

@@ -97,10 +102,8 @@ def update_window_modifier_representation(context):
97102
def replace_representation_for_object(ifc_file, ifc_context, obj, new_representation):
98103
ifc_element = tool.Ifc.get_entity(obj)
99104
old_representation = ifcopenshell.util.representation.get_representation(
100-
ifc_element,
101-
ifc_context.ContextType,
102-
ifc_context.ContextIdentifier,
103-
ifc_context.TargetView)
105+
ifc_element, ifc_context.ContextType, ifc_context.ContextIdentifier, ifc_context.TargetView
106+
)
104107

105108
if old_representation:
106109
for inverse in ifc_file.get_inverse(old_representation):
@@ -121,14 +124,24 @@ def replace_representation_for_object(ifc_file, ifc_context, obj, new_representa
121124
)
122125

123126

124-
def create_bm_window_closed_profile(bm, size: Vector, thickness: float, position: Vector):
127+
def create_bm_window_closed_profile(bm, size: Vector, thickness: Vector, position: Vector):
128+
"""thickness of the profile is defined as list in the following order: (LEFT, TOP, RIGHT, BOTTOM)
129+
130+
thickness can be also defined just as 1 float value.
131+
"""
132+
133+
if not isinstance(thickness, collections.abc.Iterable):
134+
thickness = [thickness] * 4
135+
136+
th_left, th_up, th_right, th_bottom = thickness
137+
125138
width, depth, height = size
126139

127140
verts = [
128-
(0, [thickness, 0.0, thickness]),
129-
(1, [width - thickness, 0.0, thickness]),
130-
(2, [thickness, 0.0, height - thickness]),
131-
(3, [width - thickness, 0.0, height - thickness]),
141+
(0, [th_left, 0.0, th_bottom]),
142+
(1, [width - th_right, 0.0, th_bottom]),
143+
(2, [th_left, 0.0, height - th_up]),
144+
(3, [width - th_right, 0.0, height - th_up]),
132145
(4, [0.0, 0.0, 0.0]),
133146
(5, [0.0, 0.0, height]),
134147
(6, [width, 0.0, 0.0]),
@@ -151,10 +164,10 @@ def create_bm_window_closed_profile(bm, size: Vector, thickness: float, position
151164
]
152165

153166
faces = [
154-
(0, (2, 3, 7, 5)),
155-
(1, (5, 4, 0, 2)),
156-
(2, (1, 0, 4, 6)),
157-
(3, (7, 3, 1, 6)),
167+
(0, (5, 7, 3, 2)),
168+
(1, (2, 0, 4, 5)),
169+
(2, (6, 4, 0, 1)),
170+
(3, (6, 1, 3, 7)),
158171
]
159172

160173
bm.verts.index_update()
@@ -187,28 +200,79 @@ def update_window_modifier_bmesh(context):
187200
lining_depth = props.lining_depth * si_conversion
188201
overall_height = props.overall_height * si_conversion
189202
lining_to_panel_offset_x = props.lining_to_panel_offset_x * si_conversion
203+
lining_thickness = props.lining_thickness * si_conversion
204+
205+
mullion_thickness = props.mullion_thickness * si_conversion / 2
206+
first_mullion_offset = props.first_mullion_offset * si_conversion
207+
second_mullion_offset = props.second_mullion_offset * si_conversion
208+
transom_thickness = props.transom_thickness * si_conversion / 2
209+
first_transom_offset = props.first_transom_offset * si_conversion
210+
second_transom_offset = props.second_transom_offset * si_conversion
211+
212+
glass_thickness = 10 * si_conversion
190213

191214
bm = bmesh.new()
215+
panel_schema = list(reversed(panel_schema))
192216

193-
for row_i, panel_row in enumerate(reversed(panel_schema)):
217+
# TODO: need more readable way to define panel width and height
218+
unique_rows_in_col = [len(set(row[column_i] for row in panel_schema)) for column_i in range(len(panel_schema[0]))]
219+
for row_i, panel_row in enumerate(panel_schema):
194220
accumulated_width = 0
221+
unique_cols = len(set(panel_row))
222+
195223
for column_i, panel_i in enumerate(panel_row):
224+
# calculate current panel dimensions
225+
if unique_cols > 1:
226+
if column_i == 0:
227+
panel_width = first_mullion_offset
228+
elif column_i == unique_cols - 1:
229+
panel_width = overall_width - accumulated_width
230+
else:
231+
panel_width = second_mullion_offset - accumulated_width
232+
else:
233+
panel_width = overall_width
234+
235+
if unique_rows_in_col[column_i] > 1:
236+
if row_i == 0:
237+
panel_height = first_transom_offset
238+
elif row_i == unique_rows_in_col[column_i] - 1:
239+
panel_height = overall_height - accumulated_height[column_i]
240+
else:
241+
panel_height = second_transom_offset - accumulated_height[column_i]
242+
else:
243+
panel_height = overall_height
244+
196245
if panel_i in built_panels:
197-
accumulated_height[column_i] += props.relative_height[panel_i]
198-
accumulated_width += props.relative_width[panel_i]
246+
accumulated_height[column_i] += panel_height
247+
accumulated_width += panel_width
199248
continue
200249

201250
frame_depth = props.frame_depth[panel_i] * si_conversion
202251
frame_thickness = props.frame_thickness[panel_i] * si_conversion
203-
glass_thickness = 10 * si_conversion
204252

205253
# create lining
206254
lining_size = V(
207-
overall_width * props.relative_width[panel_i],
255+
panel_width,
208256
lining_depth,
209-
overall_height * props.relative_height[panel_i],
257+
panel_height,
210258
)
211-
thickness = props.lining_thickness * si_conversion
259+
260+
# calculate lining thickness
261+
# taking into account mullions and transoms
262+
thickness = [lining_thickness] * 4
263+
# mullion thickness
264+
if unique_cols > 1:
265+
if column_i != 0:
266+
thickness[0] = mullion_thickness # left column
267+
if column_i != unique_cols - 1:
268+
thickness[2] = mullion_thickness # right column
269+
# transom thickness
270+
if unique_rows_in_col[column_i] > 1:
271+
if row_i != 0:
272+
thickness[3] = transom_thickness # bottom row
273+
if row_i != unique_rows_in_col[column_i] - 1:
274+
thickness[1] = transom_thickness # top row
275+
212276
lining_verts = create_bm_window_closed_profile(bm, lining_size, thickness, V(0, 0, 0))
213277

214278
# add panel
@@ -239,15 +303,13 @@ def update_window_modifier_bmesh(context):
239303
bmesh.ops.translate(bm, vec=glass_position, verts=glass_verts)
240304

241305
# translate panel
242-
accumulated_offset = V(accumulated_width, 0, accumulated_height[column_i]) * V(
243-
overall_width, 0, overall_height
244-
)
306+
accumulated_offset = V(accumulated_width, 0, accumulated_height[column_i])
245307
bmesh.ops.translate(bm, vec=accumulated_offset, verts=lining_verts + panel_verts + glass_verts)
246308

247309
built_panels.append(panel_i)
248310

249-
accumulated_height[column_i] += props.relative_height[panel_i]
250-
accumulated_width += props.relative_width[panel_i]
311+
accumulated_height[column_i] += panel_height
312+
accumulated_width += panel_width
251313

252314
bmesh.ops.translate(bm, vec=V(0, props.lining_offset * si_conversion, 0), verts=bm.verts)
253315
bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=0.0001)

0 commit comments

Comments
 (0)