mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Window Modifier - added mullions/transoms, removed relative panel dimensions
This commit is contained in:
@@ -301,15 +301,9 @@ class BIMSverchokProperties(PropertyGroup):
|
||||
|
||||
|
||||
def window_type_prop_update(self, context):
|
||||
panels_data = self.window_types_panels[self.window_type]
|
||||
for i in range(3):
|
||||
try:
|
||||
width, height = panels_data[i]
|
||||
except IndexError:
|
||||
width, height = (0.0, 0.0)
|
||||
|
||||
self.relative_width[i] = width
|
||||
self.relative_height[i] = height
|
||||
number_of_panels, panels_data = self.window_types_panels[self.window_type]
|
||||
self.first_mullion_offset, self.second_mullion_offset = panels_data[0]
|
||||
self.first_transom_offset, self.second_transom_offset = panels_data[1]
|
||||
|
||||
|
||||
class BIMWindowProperties(PropertyGroup):
|
||||
@@ -325,17 +319,17 @@ class BIMWindowProperties(PropertyGroup):
|
||||
("TRIPLE_PANEL_VERTICAL", "TRIPLE_PANEL_VERTICAL", ""),
|
||||
)
|
||||
|
||||
# default panel relative dimensions
|
||||
# number of panels and default mullion/transom values
|
||||
window_types_panels = {
|
||||
"SINGLE_PANEL": ((1.0, 1.0), ),
|
||||
"DOUBLE_PANEL_HORIZONTAL": ((1.0, 0.5), (1.0, 0.5), ),
|
||||
"DOUBLE_PANEL_VERTICAL": ((0.5, 1.0), (0.5, 1.0), ),
|
||||
"TRIPLE_PANEL_BOTTOM": ((0.5, 0.5), (0.5, 0.5), (1.0, 0.5), ),
|
||||
"TRIPLE_PANEL_TOP": ((1.0, 0.5), (0.5, 0.5), (0.5, 0.5), ),
|
||||
"TRIPLE_PANEL_LEFT": ((0.5, 1.0), (0.5, 0.5), (0.5, 0.5), ),
|
||||
"TRIPLE_PANEL_RIGHT": ((0.5, 0.5), (0.5, 1.0), (0.5, 0.5), ),
|
||||
"TRIPLE_PANEL_HORIZONTAL": ((1.0, 1/3), (1.0, 1/3), (1.0, 1/3),),
|
||||
"TRIPLE_PANEL_VERTICAL": ((1/3, 1.0), (1/3, 1.0), (1/3, 1.0),),
|
||||
"SINGLE_PANEL": (1, ((0, 0 ), (0, 0 ))),
|
||||
"DOUBLE_PANEL_HORIZONTAL": (2, ((0, 0 ), (450, 0 ))),
|
||||
"DOUBLE_PANEL_VERTICAL": (2, ((300, 0 ), (0, 0 ))),
|
||||
"TRIPLE_PANEL_BOTTOM": (3, ((300, 0 ), (450, 0 ))),
|
||||
"TRIPLE_PANEL_TOP": (3, ((300, 0 ), (450, 0 ))),
|
||||
"TRIPLE_PANEL_LEFT": (3, ((300, 0 ), (450, 0 ))),
|
||||
"TRIPLE_PANEL_RIGHT": (3, ((300, 0 ), (450, 0 ))),
|
||||
"TRIPLE_PANEL_HORIZONTAL": (3, ((0, 0 ), (300, 600))),
|
||||
"TRIPLE_PANEL_VERTICAL": (3, ((200, 400), (0, 0 ))),
|
||||
}
|
||||
|
||||
is_editing: bpy.props.IntProperty(default=-1)
|
||||
@@ -351,14 +345,16 @@ class BIMWindowProperties(PropertyGroup):
|
||||
lining_offset: bpy.props.FloatProperty(name="Lining Offset", default=50)
|
||||
lining_to_panel_offset_x: bpy.props.FloatProperty(name="Lining to Panel Offset X", default=25)
|
||||
lining_to_panel_offset_y: bpy.props.FloatProperty(name="Lining to Panel Offset Y", default=25)
|
||||
mullion_thickness: bpy.props.FloatProperty(name="(not used) Mullion Thickness")
|
||||
transom_thickness: bpy.props.FloatProperty(name="(not used) Transom Thickness")
|
||||
mullion_thickness: bpy.props.FloatProperty(name="Mullion Thickness", default=50)
|
||||
first_mullion_offset: bpy.props.FloatProperty(name="First Mullion Offset", default=300)
|
||||
second_mullion_offset: bpy.props.FloatProperty(name="Second Mullion Offset", default=450)
|
||||
transom_thickness: bpy.props.FloatProperty(name="Transom Thickness", default=50)
|
||||
first_transom_offset: bpy.props.FloatProperty(name="First Transom Offset", default=300)
|
||||
second_transom_offset: bpy.props.FloatProperty(name="Second Transom Offset", default=600)
|
||||
|
||||
# panel_properties
|
||||
frame_depth: bpy.props.FloatVectorProperty(name="Frame Depth", size=3, default=[35] * 3)
|
||||
frame_thickness: bpy.props.FloatVectorProperty(name="Frame Thickness", size=3, default=[35] * 3)
|
||||
relative_width: bpy.props.FloatVectorProperty(name="Relative Width", size=3, default=[1, 0, 0])
|
||||
relative_height: bpy.props.FloatVectorProperty(name="Relative Height", size=3, default=[1, 0, 0])
|
||||
|
||||
def get_general_kwargs(self):
|
||||
return {
|
||||
@@ -368,20 +364,46 @@ class BIMWindowProperties(PropertyGroup):
|
||||
}
|
||||
|
||||
def get_lining_kwargs(self):
|
||||
return {
|
||||
kwargs = {
|
||||
"lining_depth": self.lining_depth,
|
||||
"lining_thickness": self.lining_thickness,
|
||||
"lining_offset": self.lining_offset,
|
||||
"lining_to_panel_offset_x": self.lining_to_panel_offset_x,
|
||||
"lining_to_panel_offset_y": self.lining_to_panel_offset_y,
|
||||
"mullion_thickness": self.mullion_thickness,
|
||||
"transom_thickness": self.transom_thickness,
|
||||
}
|
||||
|
||||
if self.window_type in (
|
||||
"DOUBLE_PANEL_VERTICAL",
|
||||
"TRIPLE_PANEL_BOTTOM",
|
||||
"TRIPLE_PANEL_TOP",
|
||||
"TRIPLE_PANEL_LEFT",
|
||||
"TRIPLE_PANEL_RIGHT",
|
||||
"TRIPLE_PANEL_VERTICAL",
|
||||
):
|
||||
kwargs["mullion_thickness"] = self.mullion_thickness
|
||||
kwargs["first_mullion_offset"] = self.first_mullion_offset
|
||||
|
||||
if self.window_type in (
|
||||
"DOUBLE_PANEL_HORIZONTAL",
|
||||
"TRIPLE_PANEL_BOTTOM",
|
||||
"TRIPLE_PANEL_TOP",
|
||||
"TRIPLE_PANEL_LEFT",
|
||||
"TRIPLE_PANEL_RIGHT",
|
||||
"TRIPLE_PANEL_HORIZONTAL",
|
||||
):
|
||||
kwargs["transom_thickness"] = self.transom_thickness
|
||||
kwargs["first_transom_offset"] = self.first_transom_offset
|
||||
|
||||
if self.window_type in ("TRIPLE_PANEL_VERTICAL",):
|
||||
kwargs["second_mullion_offset"] = self.second_mullion_offset
|
||||
|
||||
if self.window_type in ("TRIPLE_PANEL_HORIZONTAL",):
|
||||
kwargs["second_transom_offset"] = self.second_transom_offset
|
||||
|
||||
return kwargs
|
||||
|
||||
def get_panel_kwargs(self):
|
||||
return {
|
||||
"frame_depth": self.frame_depth,
|
||||
"frame_thickness": self.frame_thickness,
|
||||
"relative_width": self.relative_width,
|
||||
"relative_height": self.relative_height,
|
||||
}
|
||||
|
||||
@@ -429,6 +429,7 @@ class BIM_PT_window(bpy.types.Panel):
|
||||
row.label(text="Window parameters", icon="OUTLINER_OB_LATTICE")
|
||||
|
||||
window_data = WindowData.data["parameters"]["data"]
|
||||
number_of_panels, panels_data = props.window_types_panels[props.window_type]
|
||||
|
||||
if props.is_editing != -1:
|
||||
row = self.layout.row(align=True)
|
||||
@@ -446,7 +447,6 @@ class BIM_PT_window(bpy.types.Panel):
|
||||
|
||||
panel_props = props.get_panel_kwargs()
|
||||
self.layout.label(text="Panel properties")
|
||||
number_of_panels = len(props.window_types_panels[props.window_type])
|
||||
|
||||
panel_box = self.layout.box()
|
||||
row = panel_box.row()
|
||||
@@ -492,7 +492,6 @@ class BIM_PT_window(bpy.types.Panel):
|
||||
|
||||
panel_props = props.get_panel_kwargs()
|
||||
self.layout.label(text="Panel properties")
|
||||
number_of_panels = len(props.window_types_panels[props.window_type])
|
||||
|
||||
panel_box = self.layout.box()
|
||||
row = panel_box.row()
|
||||
|
||||
@@ -36,6 +36,7 @@ from pprint import pprint
|
||||
|
||||
from os.path import basename, dirname
|
||||
import json
|
||||
import collections
|
||||
|
||||
|
||||
V = lambda *x: Vector([float(i) for i in x])
|
||||
@@ -55,16 +56,20 @@ def update_window_modifier_representation(context):
|
||||
"LiningOffset": props.lining_offset,
|
||||
"LiningToPanelOffsetX": props.lining_to_panel_offset_x,
|
||||
"LiningToPanelOffsetY": props.lining_to_panel_offset_y,
|
||||
"MullionThickness": props.mullion_thickness,
|
||||
"FirstMullionOffset": props.first_mullion_offset,
|
||||
"SecondMullionOffset": props.second_mullion_offset,
|
||||
"TransomThickness": props.transom_thickness,
|
||||
"FirstTransomOffset": props.first_transom_offset,
|
||||
"SecondTransomOffset": props.second_transom_offset,
|
||||
},
|
||||
"panel_properties": [],
|
||||
}
|
||||
number_of_panels = len(props.window_types_panels[props.window_type])
|
||||
number_of_panels, panels_data = props.window_types_panels[props.window_type]
|
||||
for panel_i in range(number_of_panels):
|
||||
panel_data = {
|
||||
"FrameDepth": props.frame_depth[panel_i],
|
||||
"FrameThickness": props.frame_thickness[panel_i],
|
||||
"RelativeWidth": props.relative_width[panel_i],
|
||||
"RelativeHeight": props.relative_height[panel_i],
|
||||
}
|
||||
representation_data["panel_properties"].append(panel_data)
|
||||
|
||||
@@ -97,10 +102,8 @@ def update_window_modifier_representation(context):
|
||||
def replace_representation_for_object(ifc_file, ifc_context, obj, new_representation):
|
||||
ifc_element = tool.Ifc.get_entity(obj)
|
||||
old_representation = ifcopenshell.util.representation.get_representation(
|
||||
ifc_element,
|
||||
ifc_context.ContextType,
|
||||
ifc_context.ContextIdentifier,
|
||||
ifc_context.TargetView)
|
||||
ifc_element, ifc_context.ContextType, ifc_context.ContextIdentifier, ifc_context.TargetView
|
||||
)
|
||||
|
||||
if old_representation:
|
||||
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
|
||||
)
|
||||
|
||||
|
||||
def create_bm_window_closed_profile(bm, size: Vector, thickness: float, position: Vector):
|
||||
def create_bm_window_closed_profile(bm, size: Vector, thickness: Vector, position: Vector):
|
||||
"""thickness of the profile is defined as list in the following order: (LEFT, TOP, RIGHT, BOTTOM)
|
||||
|
||||
thickness can be also defined just as 1 float value.
|
||||
"""
|
||||
|
||||
if not isinstance(thickness, collections.abc.Iterable):
|
||||
thickness = [thickness] * 4
|
||||
|
||||
th_left, th_up, th_right, th_bottom = thickness
|
||||
|
||||
width, depth, height = size
|
||||
|
||||
verts = [
|
||||
(0, [thickness, 0.0, thickness]),
|
||||
(1, [width - thickness, 0.0, thickness]),
|
||||
(2, [thickness, 0.0, height - thickness]),
|
||||
(3, [width - thickness, 0.0, height - thickness]),
|
||||
(0, [th_left, 0.0, th_bottom]),
|
||||
(1, [width - th_right, 0.0, th_bottom]),
|
||||
(2, [th_left, 0.0, height - th_up]),
|
||||
(3, [width - th_right, 0.0, height - th_up]),
|
||||
(4, [0.0, 0.0, 0.0]),
|
||||
(5, [0.0, 0.0, height]),
|
||||
(6, [width, 0.0, 0.0]),
|
||||
@@ -151,10 +164,10 @@ def create_bm_window_closed_profile(bm, size: Vector, thickness: float, position
|
||||
]
|
||||
|
||||
faces = [
|
||||
(0, (2, 3, 7, 5)),
|
||||
(1, (5, 4, 0, 2)),
|
||||
(2, (1, 0, 4, 6)),
|
||||
(3, (7, 3, 1, 6)),
|
||||
(0, (5, 7, 3, 2)),
|
||||
(1, (2, 0, 4, 5)),
|
||||
(2, (6, 4, 0, 1)),
|
||||
(3, (6, 1, 3, 7)),
|
||||
]
|
||||
|
||||
bm.verts.index_update()
|
||||
@@ -187,28 +200,79 @@ def update_window_modifier_bmesh(context):
|
||||
lining_depth = props.lining_depth * si_conversion
|
||||
overall_height = props.overall_height * si_conversion
|
||||
lining_to_panel_offset_x = props.lining_to_panel_offset_x * si_conversion
|
||||
lining_thickness = props.lining_thickness * si_conversion
|
||||
|
||||
mullion_thickness = props.mullion_thickness * si_conversion / 2
|
||||
first_mullion_offset = props.first_mullion_offset * si_conversion
|
||||
second_mullion_offset = props.second_mullion_offset * si_conversion
|
||||
transom_thickness = props.transom_thickness * si_conversion / 2
|
||||
first_transom_offset = props.first_transom_offset * si_conversion
|
||||
second_transom_offset = props.second_transom_offset * si_conversion
|
||||
|
||||
glass_thickness = 10 * si_conversion
|
||||
|
||||
bm = bmesh.new()
|
||||
panel_schema = list(reversed(panel_schema))
|
||||
|
||||
for row_i, panel_row in enumerate(reversed(panel_schema)):
|
||||
# TODO: need more readable way to define panel width and height
|
||||
unique_rows_in_col = [len(set(row[column_i] for row in panel_schema)) for column_i in range(len(panel_schema[0]))]
|
||||
for row_i, panel_row in enumerate(panel_schema):
|
||||
accumulated_width = 0
|
||||
unique_cols = len(set(panel_row))
|
||||
|
||||
for column_i, panel_i in enumerate(panel_row):
|
||||
# calculate current panel dimensions
|
||||
if unique_cols > 1:
|
||||
if column_i == 0:
|
||||
panel_width = first_mullion_offset
|
||||
elif column_i == unique_cols - 1:
|
||||
panel_width = overall_width - accumulated_width
|
||||
else:
|
||||
panel_width = second_mullion_offset - accumulated_width
|
||||
else:
|
||||
panel_width = overall_width
|
||||
|
||||
if unique_rows_in_col[column_i] > 1:
|
||||
if row_i == 0:
|
||||
panel_height = first_transom_offset
|
||||
elif row_i == unique_rows_in_col[column_i] - 1:
|
||||
panel_height = overall_height - accumulated_height[column_i]
|
||||
else:
|
||||
panel_height = second_transom_offset - accumulated_height[column_i]
|
||||
else:
|
||||
panel_height = overall_height
|
||||
|
||||
if panel_i in built_panels:
|
||||
accumulated_height[column_i] += props.relative_height[panel_i]
|
||||
accumulated_width += props.relative_width[panel_i]
|
||||
accumulated_height[column_i] += panel_height
|
||||
accumulated_width += panel_width
|
||||
continue
|
||||
|
||||
frame_depth = props.frame_depth[panel_i] * si_conversion
|
||||
frame_thickness = props.frame_thickness[panel_i] * si_conversion
|
||||
glass_thickness = 10 * si_conversion
|
||||
|
||||
# create lining
|
||||
lining_size = V(
|
||||
overall_width * props.relative_width[panel_i],
|
||||
panel_width,
|
||||
lining_depth,
|
||||
overall_height * props.relative_height[panel_i],
|
||||
panel_height,
|
||||
)
|
||||
thickness = props.lining_thickness * si_conversion
|
||||
|
||||
# calculate lining thickness
|
||||
# taking into account mullions and transoms
|
||||
thickness = [lining_thickness] * 4
|
||||
# mullion thickness
|
||||
if unique_cols > 1:
|
||||
if column_i != 0:
|
||||
thickness[0] = mullion_thickness # left column
|
||||
if column_i != unique_cols - 1:
|
||||
thickness[2] = mullion_thickness # right column
|
||||
# transom thickness
|
||||
if unique_rows_in_col[column_i] > 1:
|
||||
if row_i != 0:
|
||||
thickness[3] = transom_thickness # bottom row
|
||||
if row_i != unique_rows_in_col[column_i] - 1:
|
||||
thickness[1] = transom_thickness # top row
|
||||
|
||||
lining_verts = create_bm_window_closed_profile(bm, lining_size, thickness, V(0, 0, 0))
|
||||
|
||||
# add panel
|
||||
@@ -239,15 +303,13 @@ def update_window_modifier_bmesh(context):
|
||||
bmesh.ops.translate(bm, vec=glass_position, verts=glass_verts)
|
||||
|
||||
# translate panel
|
||||
accumulated_offset = V(accumulated_width, 0, accumulated_height[column_i]) * V(
|
||||
overall_width, 0, overall_height
|
||||
)
|
||||
accumulated_offset = V(accumulated_width, 0, accumulated_height[column_i])
|
||||
bmesh.ops.translate(bm, vec=accumulated_offset, verts=lining_verts + panel_verts + glass_verts)
|
||||
|
||||
built_panels.append(panel_i)
|
||||
|
||||
accumulated_height[column_i] += props.relative_height[panel_i]
|
||||
accumulated_width += props.relative_width[panel_i]
|
||||
accumulated_height[column_i] += panel_height
|
||||
accumulated_width += panel_width
|
||||
|
||||
bmesh.ops.translate(bm, vec=V(0, props.lining_offset * si_conversion, 0), verts=bm.verts)
|
||||
bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=0.0001)
|
||||
|
||||
@@ -62,18 +62,17 @@ class Usecase:
|
||||
"LiningToPanelOffsetX": 25,
|
||||
"LiningToPanelOffsetY": 25,
|
||||
# applies to DoublePanelVertical, TriplePanelBottom, TriplePanelTop, TriplePanelLeft, TriplePanelRight
|
||||
# mullion - distance between panels
|
||||
"FirstMullionOffset": ..., # distance from the first lining to the mullion
|
||||
# TODO: take mullion thickness into account
|
||||
"MullionThickness": ...,
|
||||
# mullion - horizontal distance between panels
|
||||
"MullionThickness": 50,
|
||||
"FirstMullionOffset": 300, # distance from the first lining to the mullion center
|
||||
# applies to TriplePanelVertical
|
||||
"SecondMullionOffset": 450, # distance from the first lining to the second mullion
|
||||
# applies to DoublePanelHorizontal, TriplePanelBottom, TriplePanelTop, TriplePanelLeft, TriplePanelRight
|
||||
# works similar way to mullion
|
||||
"FirstTransomOffset": ...,
|
||||
"TransomThickness": ...,
|
||||
# applies to TriplePanelVertical
|
||||
"SecondMullionOffset": ..., # distance from the first lining to the second mullion
|
||||
"TransomThickness": 50,
|
||||
"FirstTransomOffset": 300,
|
||||
# applies to TriplePanelHorizontal
|
||||
"SecondTransomOffset": ...,
|
||||
"SecondTransomOffset": 600,
|
||||
"ShapeAspectStyle": None, # DEPRECATED
|
||||
},
|
||||
"panel_properties": [
|
||||
@@ -86,10 +85,6 @@ class Usecase:
|
||||
# how it's hanged, how it opens
|
||||
"OperationType": None,
|
||||
"ShapeAspectStyle": None, # DEPRECATED
|
||||
# Custom Parameter not available in IFC
|
||||
# dimensions of the panel relative to overall window dimensions
|
||||
"RelativeWidth": 1.0,
|
||||
"RelativeHeight": 1.0,
|
||||
},
|
||||
],
|
||||
}
|
||||
@@ -98,19 +93,6 @@ class Usecase:
|
||||
self.settings[key] = value
|
||||
self.settings["panel_schema"] = DEFAULT_PANEL_SCHEMAS[self.settings["partition_type"]]
|
||||
|
||||
# recalculate relative width and height to avoid errors
|
||||
# TODO: rework or remove
|
||||
# panels_data = self.settings['panel_properties']
|
||||
# current_height = sum(p['RelativeHeight'] for p in panels_data)
|
||||
# current_width = sum(p['RelativeWidth'] for p in panels_data)
|
||||
|
||||
# for p in panels_data:
|
||||
# if current_height != 1.0:
|
||||
# p['RelativeHeight'] = p['RelativeHeight'] / current_height
|
||||
|
||||
# if current_width != 1.0:
|
||||
# p['RelativeWidth'] = p['RelativeWidth'] / current_width
|
||||
|
||||
def execute(self):
|
||||
self.settings["unit_scale"] = ifcopenshell.util.unit.calculate_unit_scale(self.file)
|
||||
builder = ShapeBuilder(self.file)
|
||||
@@ -135,19 +117,54 @@ class Usecase:
|
||||
lining_panel_offset_y = self.convert_si_to_unit(self.settings["lining_properties"]["LiningToPanelOffsetY"])
|
||||
glass_thickness = self.convert_si_to_unit(10)
|
||||
|
||||
for row_i, panel_row in enumerate(reversed(panel_schema)):
|
||||
mullion_thickness = self.convert_si_to_unit(self.settings["lining_properties"]["MullionThickness"]) / 2
|
||||
first_mullion_offset = self.convert_si_to_unit(self.settings["lining_properties"]["FirstMullionOffset"])
|
||||
second_mullion_offset = self.convert_si_to_unit(self.settings["lining_properties"]["SecondMullionOffset"])
|
||||
transom_thickness = self.convert_si_to_unit(self.settings["lining_properties"]["TransomThickness"]) / 2
|
||||
first_transom_offset = self.convert_si_to_unit(self.settings["lining_properties"]["FirstTransomOffset"])
|
||||
second_transom_offset = self.convert_si_to_unit(self.settings["lining_properties"]["SecondTransomOffset"])
|
||||
|
||||
panel_schema = list(reversed(panel_schema))
|
||||
|
||||
# TODO: need more readable way to define panel width and height
|
||||
unique_rows_in_col = [
|
||||
len(set(row[column_i] for row in panel_schema)) for column_i in range(len(panel_schema[0]))
|
||||
]
|
||||
for row_i, panel_row in enumerate(panel_schema):
|
||||
accumulated_width = 0
|
||||
unique_cols = len(set(panel_row))
|
||||
|
||||
for column_i, panel_i in enumerate(panel_row):
|
||||
# calculate current panel dimensions
|
||||
if unique_cols > 1:
|
||||
if column_i == 0:
|
||||
panel_width = first_mullion_offset
|
||||
elif column_i == unique_cols - 1:
|
||||
panel_width = overall_width - accumulated_width
|
||||
else:
|
||||
panel_width = second_mullion_offset - accumulated_width
|
||||
else:
|
||||
panel_width = overall_width
|
||||
|
||||
if unique_rows_in_col[column_i] > 1:
|
||||
if row_i == 0:
|
||||
panel_height = first_transom_offset
|
||||
elif row_i == unique_rows_in_col[column_i] - 1:
|
||||
panel_height = overall_height - accumulated_height[column_i]
|
||||
else:
|
||||
panel_height = second_transom_offset - accumulated_height[column_i]
|
||||
else:
|
||||
panel_height = overall_height
|
||||
|
||||
if panel_i in built_panels:
|
||||
accumulated_height[column_i] += cur_panel["RelativeHeight"]
|
||||
accumulated_width += cur_panel["RelativeWidth"]
|
||||
accumulated_height[column_i] += panel_height
|
||||
accumulated_width += panel_width
|
||||
continue
|
||||
|
||||
cur_panel = panels[panel_i]
|
||||
current_items = []
|
||||
panel_depth = self.convert_si_to_unit(cur_panel["FrameDepth"])
|
||||
panel_thickness = self.convert_si_to_unit(cur_panel["FrameThickness"])
|
||||
panel_height = cur_panel["RelativeHeight"] * overall_height
|
||||
panel_width = cur_panel["RelativeWidth"] * overall_width
|
||||
|
||||
panel_actual_width = panel_width - lining_panel_offset_x * 2
|
||||
panel_actual_height = panel_height - lining_panel_offset_x * 2
|
||||
@@ -156,99 +173,121 @@ class Usecase:
|
||||
glass_height = panel_actual_height - panel_thickness * 2
|
||||
|
||||
# build lining
|
||||
lining_items_vertical = []
|
||||
lining_items = []
|
||||
# lining is calculated on panel level because
|
||||
# panel depth is used
|
||||
lining_rectangle = builder.rectangle(size=V(lining_thickness, lining_depth))
|
||||
lining_items_vertical_left = []
|
||||
lining_items = []
|
||||
|
||||
# need to check offsets to decide whether lining should be rectangle
|
||||
# or L shaped
|
||||
if lining_panel_offset_x >= lining_thickness or lining_panel_offset_y >= lining_depth:
|
||||
lining_vertical_polyline = ifcopenshell.util.element.copy_deep(self.file, lining_rectangle)
|
||||
lining_vertical_height = panel_height
|
||||
# calculate lining thickness
|
||||
# taking into account mullions and transoms
|
||||
thickness = [lining_thickness] * 4
|
||||
# mullion thickness
|
||||
if unique_cols > 1:
|
||||
if column_i != 0:
|
||||
thickness[0] = mullion_thickness # left column
|
||||
if column_i != unique_cols - 1:
|
||||
thickness[2] = mullion_thickness # right column
|
||||
# transom thickness
|
||||
if unique_rows_in_col[column_i] > 1:
|
||||
if row_i != 0:
|
||||
thickness[3] = transom_thickness # bottom row
|
||||
if row_i != unique_rows_in_col[column_i] - 1:
|
||||
thickness[1] = transom_thickness # top row
|
||||
|
||||
else:
|
||||
lining_points = [
|
||||
V(0, 0),
|
||||
V(0, lining_depth),
|
||||
V(lining_panel_offset_x, lining_depth),
|
||||
V(lining_panel_offset_x, lining_depth - (panel_depth - lining_panel_offset_y)),
|
||||
V(lining_thickness, lining_depth - (panel_depth - lining_panel_offset_y)),
|
||||
V(lining_thickness, 0),
|
||||
]
|
||||
def get_lining_rectangle(current_lining_thickness):
|
||||
lining_rectangle = builder.rectangle(size=V(current_lining_thickness, lining_depth))
|
||||
return lining_rectangle
|
||||
|
||||
# lining vertical
|
||||
lining_vertical_polyline = builder.polyline(lining_points, closed=True)
|
||||
def get_lining_polyline(current_lining_thickness):
|
||||
# need to check offsets to decide whether lining should be rectangle
|
||||
# or L shaped
|
||||
if lining_panel_offset_x >= current_lining_thickness or lining_panel_offset_y >= lining_depth:
|
||||
lining_polyline = get_lining_rectangle(current_lining_thickness)
|
||||
else:
|
||||
lining_points = [
|
||||
V(0, 0),
|
||||
V(0, lining_depth),
|
||||
V(lining_panel_offset_x, lining_depth),
|
||||
V(lining_panel_offset_x, lining_depth - (panel_depth - lining_panel_offset_y)),
|
||||
V(current_lining_thickness, lining_depth - (panel_depth - lining_panel_offset_y)),
|
||||
V(current_lining_thickness, 0),
|
||||
]
|
||||
lining_polyline = builder.polyline(lining_points, closed=True)
|
||||
return lining_polyline
|
||||
|
||||
def create_lining_vertical(current_lining_thickness):
|
||||
current_vertical_lining_items = []
|
||||
lining_vertical_polyline = get_lining_polyline(current_lining_thickness)
|
||||
lining_vertical_height = panel_height - lining_panel_offset_x * 2
|
||||
extrusion_position = V(0, 0, lining_panel_offset_x)
|
||||
lining_vertical_extruded = builder.extrude(
|
||||
lining_vertical_polyline, lining_vertical_height, position=extrusion_position
|
||||
)
|
||||
current_vertical_lining_items.append(lining_vertical_extruded)
|
||||
|
||||
# if lining panel X offset is present
|
||||
# then we also need to add two more box shapes
|
||||
# to finish the lining after the panel ends
|
||||
if lining_panel_offset_x > 0:
|
||||
lining_vertical_addition = builder.extrude(
|
||||
builder.deep_copy(lining_rectangle), lining_panel_offset_x
|
||||
get_lining_rectangle(current_lining_thickness), lining_panel_offset_x
|
||||
)
|
||||
|
||||
lining_items_vertical.extend(
|
||||
[
|
||||
current_vertical_lining_items.append(lining_vertical_addition)
|
||||
current_vertical_lining_items.append(
|
||||
builder.translate(
|
||||
lining_vertical_addition,
|
||||
builder.translate(
|
||||
lining_vertical_addition,
|
||||
V(0, 0, panel_height - lining_panel_offset_x),
|
||||
create_copy=True,
|
||||
),
|
||||
]
|
||||
V(0, 0, panel_height - lining_panel_offset_x),
|
||||
create_copy=True,
|
||||
)
|
||||
)
|
||||
|
||||
# horizontal lining
|
||||
lining_horizontal_polyline = builder.deep_copy(lining_vertical_polyline)
|
||||
return current_vertical_lining_items
|
||||
|
||||
# vertical lining
|
||||
lining_items_vertical_left = create_lining_vertical(thickness[0])
|
||||
lining_items_vertical_right = create_lining_vertical(thickness[2])
|
||||
lining_items_vertical_right = builder.mirror(
|
||||
lining_items_vertical_right, mirror_point=V(panel_width / 2, 0), mirror_axes=V(1, 0)
|
||||
)
|
||||
lining_items.extend(lining_items_vertical_left)
|
||||
lining_items.extend(lining_items_vertical_right)
|
||||
|
||||
# horizontal lining
|
||||
def create_horizontal_lining(current_lining_thickness, mirror_point=None):
|
||||
lining_horizontal_polyline = get_lining_polyline(current_lining_thickness)
|
||||
if mirror_point:
|
||||
lining_horizontal_polyline = builder.mirror(
|
||||
lining_horizontal_polyline,
|
||||
mirror_axes=V(1, 0),
|
||||
mirror_point=mirror_point
|
||||
)
|
||||
builder.translate(lining_horizontal_polyline, -mirror_point)
|
||||
lining_horizontal_extruded = builder.extrude(
|
||||
lining_horizontal_polyline,
|
||||
magnitude=panel_width - 2 * lining_thickness,
|
||||
magnitude=panel_width - (thickness[0] + thickness[2]),
|
||||
extrusion_vector=V(0, 0, -1),
|
||||
position_z_axis=V(-1, 0, 0),
|
||||
position_x_axis=V(0, 0, 1),
|
||||
position=V(lining_thickness, 0, 0),
|
||||
)
|
||||
return lining_horizontal_extruded
|
||||
|
||||
# TODO: should implement mirror by Z for more readability
|
||||
# TODO: investigate meaning of mirror axes in case of custom x/y/z space
|
||||
# lining_horizontal_mirrored = builder.mirror(
|
||||
# lining_horizontal_extruded,
|
||||
# mirror_point=V(0, panel_height/2),
|
||||
# mirror_axes=V(0,1),
|
||||
# create_copy=True
|
||||
# )
|
||||
lining_horizontal_bottom = create_horizontal_lining(thickness[3])
|
||||
builder.translate(lining_horizontal_bottom, V(thickness[0], 0, 0))
|
||||
|
||||
lining_horizontal_polyline_mirrored = builder.mirror(
|
||||
lining_horizontal_polyline,
|
||||
mirror_axes=V(1, 0),
|
||||
mirror_point=V(lining_thickness, 0),
|
||||
create_copy=True,
|
||||
)
|
||||
lining_horizontal_mirrored = builder.extrude(
|
||||
lining_horizontal_polyline_mirrored,
|
||||
magnitude=panel_width - 2 * lining_thickness,
|
||||
extrusion_vector=V(0, 0, -1),
|
||||
position_z_axis=V(-1, 0, 0),
|
||||
position_x_axis=V(0, 0, 1),
|
||||
position=V(lining_thickness, 0, panel_height - lining_thickness * 2),
|
||||
)
|
||||
lining_items.extend([lining_horizontal_extruded, lining_horizontal_mirrored])
|
||||
lining_horizontal_top = create_horizontal_lining(thickness[1], mirror_point=V(thickness[1], 0))
|
||||
builder.translate(lining_horizontal_top, V(thickness[0], 0, panel_height - thickness[1]))
|
||||
|
||||
extrusion_position = V(0, 0, lining_panel_offset_x)
|
||||
lining_vertical_extruded = builder.extrude(
|
||||
lining_vertical_polyline, lining_vertical_height, position=extrusion_position
|
||||
)
|
||||
lining_items_vertical.append(lining_vertical_extruded)
|
||||
# TODO: should implement mirror by Z for more readability
|
||||
# TODO: investigate meaning of mirror axes in case of custom x/y/z space
|
||||
# lining_horizontal_mirrored = builder.mirror(
|
||||
# lining_horizontal_extruded,
|
||||
# mirror_point=V(0, panel_height/2),
|
||||
# mirror_axes=V(0,1),
|
||||
# create_copy=True
|
||||
# )
|
||||
|
||||
lining_items_vertical_mirrored = builder.mirror(
|
||||
lining_items_vertical, mirror_point=V(panel_width / 2, 0), mirror_axes=V(1, 0), create_copy=True
|
||||
)
|
||||
|
||||
lining_items.extend(lining_items_vertical)
|
||||
lining_items.extend(lining_items_vertical_mirrored)
|
||||
lining_items.extend([lining_horizontal_bottom, lining_horizontal_top])
|
||||
current_items.extend(lining_items)
|
||||
|
||||
# PANEL
|
||||
@@ -278,16 +317,14 @@ class Usecase:
|
||||
current_items.append(glass)
|
||||
|
||||
# translate panel
|
||||
accumulated_offset = V(accumulated_width, 0, accumulated_height[column_i]) * V(
|
||||
overall_width, 0, overall_height
|
||||
)
|
||||
accumulated_offset = V(accumulated_width, 0, accumulated_height[column_i])
|
||||
builder.translate(current_items, accumulated_offset)
|
||||
|
||||
built_panels.append(panel_i)
|
||||
window_items.extend(current_items)
|
||||
|
||||
accumulated_height[column_i] += cur_panel["RelativeHeight"]
|
||||
accumulated_width += cur_panel["RelativeWidth"]
|
||||
accumulated_height[column_i] += panel_height
|
||||
accumulated_width += panel_width
|
||||
|
||||
builder.translate(window_items, V(0, lining_offset, 0)) # wall offset
|
||||
representation = builder.get_representation(self.settings["context"], window_items)
|
||||
@@ -295,120 +332,3 @@ class Usecase:
|
||||
|
||||
def convert_si_to_unit(self, value):
|
||||
return value * 0.001 / self.settings["unit_scale"]
|
||||
|
||||
|
||||
# TODO: remove test at the end
|
||||
if __name__ == "__main__":
|
||||
ifc_file = ifcopenshell.file()
|
||||
project = ifcopenshell.api.run(
|
||||
"root.create_entity", ifc_file, ifc_class="IfcProject", name=f"Non-structural assets library"
|
||||
)
|
||||
library = ifcopenshell.api.run(
|
||||
"root.create_entity", ifc_file, ifc_class="IfcProjectLibrary", name=f"Non-structural assets library"
|
||||
)
|
||||
ifcopenshell.api.run("project.assign_declaration", ifc_file, definition=library, relating_context=project)
|
||||
unit = ifcopenshell.api.run("unit.add_si_unit", ifc_file, unit_type="LENGTHUNIT", name="METRE", prefix="MILLI")
|
||||
ifcopenshell.api.run("unit.assign_unit", ifc_file, units=[unit])
|
||||
model = ifcopenshell.api.run("context.add_context", ifc_file, context_type="Model")
|
||||
plan = ifcopenshell.api.run("context.add_context", ifc_file, context_type="Plan")
|
||||
|
||||
representations = {
|
||||
"body": ifcopenshell.api.run(
|
||||
"context.add_context",
|
||||
ifc_file,
|
||||
context_type="Model",
|
||||
context_identifier="Body",
|
||||
target_view="MODEL_VIEW",
|
||||
parent=model,
|
||||
),
|
||||
"elevation": ifcopenshell.api.run(
|
||||
"context.add_context",
|
||||
ifc_file,
|
||||
context_type="Model",
|
||||
context_identifier="Profile",
|
||||
target_view="ELEVATION_VIEW",
|
||||
parent=model,
|
||||
),
|
||||
"annotation": ifcopenshell.api.run(
|
||||
"context.add_context",
|
||||
ifc_file,
|
||||
context_type="Plan",
|
||||
context_identifier="Annotation",
|
||||
target_view="PLAN_VIEW",
|
||||
parent=plan,
|
||||
),
|
||||
}
|
||||
|
||||
settings = {
|
||||
"context": representations["body"],
|
||||
# SINGLE_PANEL, DOUBLE_PANEL_HORIZONTAL, DOUBLE_PANEL_VERTICAL,
|
||||
# TRIPLE_PANEL_BOTTOM, TRIPLE_PANEL_HORIZONTAL, TRIPLE_PANEL_LEFT, TRIPLE_PANEL_RIGHT, TRIPLE_PANEL_TOP, TRIPLE_PANEL_VERTICAL
|
||||
"partition_type": "TRIPLE_PANEL_RIGHT",
|
||||
"overall_height": 900,
|
||||
"overall_width": 600 * 3,
|
||||
# "lining_properties": {
|
||||
# 'LiningDepth': 50,
|
||||
# 'LiningThickness': 50,
|
||||
# 'LiningOffset': 50, # offset to the wall
|
||||
# 'LiningToPanelOffsetX': 25,
|
||||
# 'LiningToPanelOffsetY': 25,
|
||||
# # applies to DoublePanelVertical, TriplePanelBottom, TriplePanelTop, TriplePanelLeft, TriplePanelRight
|
||||
# # mullion - distance between panels
|
||||
# 'FirstMullionOffset': ..., # distance from the first lining to the mullion
|
||||
# # TODO: take mullion thickness into account
|
||||
# 'MullionThickness': ...,
|
||||
# # applies to DoublePanelHorizontal, TriplePanelBottom, TriplePanelTop, TriplePanelLeft, TriplePanelRight
|
||||
# # works similar way to mullion
|
||||
# 'FirstTransomOffset': ...,
|
||||
# 'TransomThickness': ...,
|
||||
# # applies to TriplePanelVertical
|
||||
# 'SecondMullionOffset': ..., # distance from the first lining to the second mullion
|
||||
# # applies to TriplePanelHorizontal
|
||||
# 'SecondTransomOffset': ...,
|
||||
# 'ShapeAspectStyle': None, # DEPRECATED
|
||||
# },
|
||||
"panel_properties": [
|
||||
{
|
||||
"FrameDepth": 35, # by Y
|
||||
"FrameThickness": 35, # by X
|
||||
"RelativeWidth": 1.0 / 2,
|
||||
"RelativeHeight": 1.0 / 2,
|
||||
},
|
||||
{
|
||||
"FrameDepth": 35, # by Y
|
||||
"FrameThickness": 35, # by X
|
||||
"RelativeWidth": 1.0 / 2,
|
||||
"RelativeHeight": 1.0,
|
||||
},
|
||||
{
|
||||
"FrameDepth": 35, # by Y
|
||||
"FrameThickness": 35, # by X
|
||||
"RelativeWidth": 1.0 / 2,
|
||||
"RelativeHeight": 1.0 / 2,
|
||||
},
|
||||
],
|
||||
}
|
||||
# builder = ShapeBuilder(ifc_file)
|
||||
# points = [V(0,0), V(5,1)]
|
||||
# print(points)
|
||||
# base_point = V(2,2)
|
||||
# points = [p + base_point for p in points]
|
||||
# points = [builder.mirror_2d_point(p, mirror_axes=V(0,1), mirror_point=V(3,3)) for p in points]
|
||||
# print('mirrored')
|
||||
# print(points)
|
||||
# print('mirrored base point')
|
||||
# base_point = builder.mirror_2d_point(base_point, mirror_axes=V(0,1), mirror_point=V(3,3))
|
||||
# print(base_point)
|
||||
# print('base line')
|
||||
# print([p - base_point for p in points])
|
||||
|
||||
use_case = Usecase(ifc_file, **settings)
|
||||
representation = use_case.execute()
|
||||
print(representation)
|
||||
|
||||
settings["context"] = representations["elevation"]
|
||||
use_case = Usecase(ifc_file, **settings)
|
||||
representation_2d = use_case.execute()
|
||||
print(representation_2d)
|
||||
|
||||
ifc_file.write("tmp.ifc")
|
||||
|
||||
Reference in New Issue
Block a user