mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Doors - clean up + black format
This commit is contained in:
@@ -33,7 +33,7 @@ from . import (
|
||||
workspace,
|
||||
profile,
|
||||
sverchok_modifier,
|
||||
door
|
||||
door,
|
||||
)
|
||||
|
||||
classes = (
|
||||
|
||||
@@ -50,7 +50,7 @@ def update_door_modifier_representation(context):
|
||||
props = obj.BIMDoorProperties
|
||||
ifc_element = tool.Ifc.get_entity(obj)
|
||||
ifc_file = tool.Ifc.get()
|
||||
|
||||
|
||||
representation_data = {
|
||||
"operation_type": props.door_type,
|
||||
"overall_height": props.overall_height,
|
||||
@@ -82,17 +82,13 @@ def update_door_modifier_representation(context):
|
||||
# ELEVATION_VIEW representation
|
||||
ifc_context = get_ifc_context_or_create(ifc_file, "Model", "Profile", "ELEVATION_VIEW")
|
||||
representation_data["context"] = ifc_context
|
||||
elevation_representation = ifcopenshell.api.run(
|
||||
"geometry.add_door_representation", ifc_file, **representation_data
|
||||
)
|
||||
elevation_representation = ifcopenshell.api.run("geometry.add_door_representation", ifc_file, **representation_data)
|
||||
replace_ifc_representation_for_object(ifc_file, ifc_context, obj, elevation_representation)
|
||||
|
||||
# PLAN_VIEW representation
|
||||
ifc_context = get_ifc_context_or_create(ifc_file, "Plan", "Annotation", "PLAN_VIEW")
|
||||
representation_data["context"] = ifc_context
|
||||
elevation_representation = ifcopenshell.api.run(
|
||||
"geometry.add_door_representation", ifc_file, **representation_data
|
||||
)
|
||||
elevation_representation = ifcopenshell.api.run("geometry.add_door_representation", ifc_file, **representation_data)
|
||||
replace_ifc_representation_for_object(ifc_file, ifc_context, obj, elevation_representation)
|
||||
|
||||
# MODEL_VIEW representation
|
||||
@@ -164,6 +160,7 @@ def create_bm_door_lining(bm, size: Vector, thickness: Vector, position:Vector=V
|
||||
|
||||
return new_verts + translate_verts
|
||||
|
||||
|
||||
def update_door_modifier_bmesh(context):
|
||||
obj = context.object
|
||||
props = obj.BIMDoorProperties
|
||||
@@ -171,7 +168,7 @@ def update_door_modifier_bmesh(context):
|
||||
|
||||
overall_width = props.overall_width * si_conversion
|
||||
overall_height = props.overall_height * si_conversion
|
||||
|
||||
|
||||
# lining params
|
||||
lining_depth = props.lining_depth * si_conversion
|
||||
lining_thickness_default = props.lining_thickness * si_conversion
|
||||
@@ -186,9 +183,9 @@ def update_door_modifier_bmesh(context):
|
||||
|
||||
window_lining_height = overall_height - transfom_offset - transom_thickness
|
||||
top_lining_thickness = transom_thickness or lining_thickness_default
|
||||
panel_lining_overlap_x = max(lining_thickness_default - lining_to_panel_offset_x, 0)
|
||||
panel_top_lining_overlap_x = max(top_lining_thickness - lining_to_panel_offset_x, 0)
|
||||
door_opening_width = (overall_width - lining_to_panel_offset_x * 2)
|
||||
panel_lining_overlap_x = max(lining_thickness_default - lining_to_panel_offset_x, 0)
|
||||
panel_top_lining_overlap_x = max(top_lining_thickness - lining_to_panel_offset_x, 0)
|
||||
door_opening_width = overall_width - lining_to_panel_offset_x * 2
|
||||
|
||||
threshold_thickness = props.threshold_thickness * si_conversion
|
||||
threshold_depth = props.threshold_depth * si_conversion
|
||||
@@ -214,7 +211,7 @@ def update_door_modifier_bmesh(context):
|
||||
lining_height = overall_height
|
||||
|
||||
bm = bmesh.new()
|
||||
|
||||
|
||||
# add lining
|
||||
lining_size = V(overall_width, lining_depth, lining_height)
|
||||
lining_thickness = [lining_thickness_default, top_lining_thickness]
|
||||
@@ -246,16 +243,8 @@ def update_door_modifier_bmesh(context):
|
||||
casing_verts.extend([outer_casing_verts, inner_casing_verts])
|
||||
|
||||
# add door panel
|
||||
panel_size = V(
|
||||
panel_width,
|
||||
panel_depth,
|
||||
panel_height
|
||||
)
|
||||
panel_position = V(
|
||||
lining_to_panel_offset_x,
|
||||
lining_to_panel_offset_y,
|
||||
threshold_thickness
|
||||
)
|
||||
panel_size = V(panel_width, panel_depth, panel_height)
|
||||
panel_position = V(lining_to_panel_offset_x, lining_to_panel_offset_y, threshold_thickness)
|
||||
panel_verts = create_bm_box(bm, panel_size, panel_position)
|
||||
|
||||
# add on top window
|
||||
@@ -264,21 +253,13 @@ def update_door_modifier_bmesh(context):
|
||||
frame_verts = []
|
||||
glass_verts = []
|
||||
else:
|
||||
window_lining_thickness = [lining_thickness_default] * 3
|
||||
window_lining_thickness = [lining_thickness_default] * 3
|
||||
window_lining_thickness.append(transom_thickness)
|
||||
window_lining_size = V(
|
||||
overall_width,
|
||||
lining_depth,
|
||||
window_lining_height
|
||||
)
|
||||
window_position = V(0, 0, overall_height-window_lining_height)
|
||||
frame_size = V(
|
||||
door_opening_width,
|
||||
frame_depth,
|
||||
frame_height
|
||||
)
|
||||
window_lining_size = V(overall_width, lining_depth, window_lining_height)
|
||||
window_position = V(0, 0, overall_height - window_lining_height)
|
||||
frame_size = V(door_opening_width, frame_depth, frame_height)
|
||||
window_lining_verts, frame_verts, glass_verts = create_bm_window(
|
||||
bm,
|
||||
bm,
|
||||
window_lining_size,
|
||||
window_lining_thickness,
|
||||
lining_to_panel_offset_x,
|
||||
@@ -286,10 +267,10 @@ def update_door_modifier_bmesh(context):
|
||||
frame_size,
|
||||
frame_thickness,
|
||||
glass_thickness,
|
||||
window_position
|
||||
window_position,
|
||||
)
|
||||
|
||||
lining_offset_verts = lining_verts+panel_verts+window_lining_verts+frame_verts+glass_verts
|
||||
lining_offset_verts = lining_verts + panel_verts + window_lining_verts + frame_verts + glass_verts
|
||||
bmesh.ops.translate(bm, vec=V(0, lining_offset, 0), verts=lining_offset_verts)
|
||||
bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=0.0001)
|
||||
|
||||
@@ -352,12 +333,13 @@ class AddDoor(bpy.types.Operator, tool.Ifc.Operator):
|
||||
props = obj.BIMDoorProperties
|
||||
|
||||
if element.is_a() not in ("IfcDoor", "IfcDoorType"):
|
||||
self.report({"ERROR"}, "Object has to be IfcDoor/IfcDoorType type to add a stair.")
|
||||
self.report({"ERROR"}, "Object has to be IfcDoor/IfcDoorType type to add a door.")
|
||||
return {"CANCELLED"}
|
||||
|
||||
# need to make sure all default props will have correct units
|
||||
if not props.door_added_previously:
|
||||
convert_property_group_from_si(props, skip_props=("is_editing", "door_type", "door_added_previously", 'convert_property_group_from_si'))
|
||||
skip_props = ("is_editing", "door_type", "door_added_previously", "panel_width_ratio")
|
||||
convert_property_group_from_si(props, skip_props=skip_props)
|
||||
|
||||
door_data = props.get_general_kwargs()
|
||||
lining_props = props.get_lining_kwargs()
|
||||
@@ -453,7 +435,7 @@ class EnableEditingDoor(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
# need to make sure all props that weren't used before
|
||||
# will have correct units
|
||||
skip_props = ("is_editing", "door_type", "door_added_previously", 'convert_property_group_from_si')
|
||||
skip_props = ("is_editing", "door_type", "door_added_previously", "panel_width_ratio")
|
||||
skip_props += tuple(data.keys())
|
||||
convert_property_group_from_si(props, skip_props=skip_props)
|
||||
|
||||
|
||||
@@ -61,4 +61,4 @@ def replace_ifc_representation_for_object(ifc_file, ifc_context, obj, new_repres
|
||||
should_reload=True,
|
||||
is_global=False,
|
||||
should_sync_changes_first=True,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -358,22 +358,26 @@ class BIMWindowProperties(PropertyGroup):
|
||||
lining_to_panel_offset_y: bpy.props.FloatProperty(name="Lining to Panel Offset Y", default=0.025)
|
||||
mullion_thickness: bpy.props.FloatProperty(name="Mullion Thickness", default=0.050)
|
||||
first_mullion_offset: bpy.props.FloatProperty(
|
||||
name="First Mullion Offset",
|
||||
description="Distance from the first lining to the first mullion center",
|
||||
default=0.3)
|
||||
name="First Mullion Offset",
|
||||
description="Distance from the first lining to the first mullion center",
|
||||
default=0.3,
|
||||
)
|
||||
second_mullion_offset: bpy.props.FloatProperty(
|
||||
name="Second Mullion Offset",
|
||||
description="Distance from the first lining to the second mullion center",
|
||||
default=0.45)
|
||||
name="Second Mullion Offset",
|
||||
description="Distance from the first lining to the second mullion center",
|
||||
default=0.45,
|
||||
)
|
||||
transom_thickness: bpy.props.FloatProperty(name="Transom Thickness", default=0.050)
|
||||
first_transom_offset: bpy.props.FloatProperty(
|
||||
name="First Transom Offset",
|
||||
name="First Transom Offset",
|
||||
description="Distance from the first lining to the first transom center",
|
||||
default=0.3)
|
||||
default=0.3,
|
||||
)
|
||||
second_transom_offset: bpy.props.FloatProperty(
|
||||
name="Second Transom Offset",
|
||||
name="Second Transom Offset",
|
||||
description="Distance from the first lining to the second transom center",
|
||||
default=0.6)
|
||||
default=0.6,
|
||||
)
|
||||
|
||||
# panel properties
|
||||
frame_depth: bpy.props.FloatVectorProperty(name="Frame Depth", size=3, default=[0.035] * 3)
|
||||
@@ -440,40 +444,56 @@ class BIMDoorProperties(PropertyGroup):
|
||||
|
||||
door_added_previously: bpy.props.BoolProperty(default=False)
|
||||
is_editing: bpy.props.IntProperty(default=-1)
|
||||
door_type: bpy.props.EnumProperty(
|
||||
name="Door Operation Type", items=door_types, default="SINGLE_SWING_LEFT"
|
||||
)
|
||||
overall_height: bpy.props.FloatProperty(name="Overall Height", default=1.2)
|
||||
overall_width: bpy.props.FloatProperty(name="Overall Width", default=0.6)
|
||||
door_type: bpy.props.EnumProperty(name="Door Operation Type", items=door_types, default="SINGLE_SWING_LEFT")
|
||||
overall_height: bpy.props.FloatProperty(name="Overall Height", default=2.0)
|
||||
overall_width: bpy.props.FloatProperty(name="Overall Width", default=0.9)
|
||||
|
||||
# lining properties
|
||||
lining_depth: bpy.props.FloatProperty(name="Lining Depth", default=0.050)
|
||||
lining_thickness: bpy.props.FloatProperty(name="Lining Thickness", default=0.050)
|
||||
lining_offset: bpy.props.FloatProperty(name="Lining Offset", default=0.0)
|
||||
lining_offset: bpy.props.FloatProperty(
|
||||
name="Lining Offset",
|
||||
description="Offset from the outer side of the wall (by Y-axis). "
|
||||
"If present then adding casing is not possible.\n"
|
||||
"`0.025 mm` is good as default value",
|
||||
default=0.0,
|
||||
)
|
||||
lining_to_panel_offset_x: bpy.props.FloatProperty(name="Lining to Panel Offset X", default=0.025)
|
||||
lining_to_panel_offset_y: bpy.props.FloatProperty(name="Lining to Panel Offset Y", default=0.025)
|
||||
|
||||
transom_thickness: bpy.props.FloatProperty(name="Transom Thickness", default=0.050)
|
||||
transom_thickness: bpy.props.FloatProperty(
|
||||
name="Transom Thickness",
|
||||
description="Set values > 0 to add a transom.\n" "`0.050 mm` is good as default value",
|
||||
default=0.000,
|
||||
)
|
||||
transom_offset: bpy.props.FloatProperty(
|
||||
name="Transom Offset",
|
||||
description="Distance from the bottom door opening " \
|
||||
"to the beginning of the transom (unlike windows)",
|
||||
default=0.875)
|
||||
description="Distance from the bottom door opening to the beginning of the transom (unlike windows)",
|
||||
default=1.525,
|
||||
)
|
||||
|
||||
casing_thickness: bpy.props.FloatProperty(name="Casing Thickness", default=0.075)
|
||||
casing_thickness: bpy.props.FloatProperty(
|
||||
name="Casing Thickness", description="Set values > 0 and LiningOffset = 0 to add a casing.", default=0.075
|
||||
)
|
||||
casing_depth: bpy.props.FloatProperty(name="Casing Depth", default=0.005)
|
||||
|
||||
threshold_thickness: bpy.props.FloatProperty(name="Threshold Thickness", default=0.025)
|
||||
|
||||
threshold_thickness: bpy.props.FloatProperty(
|
||||
name="Threshold Thickness", description="Set values > 0 to add a threshold.", default=0.025
|
||||
)
|
||||
threshold_depth: bpy.props.FloatProperty(name="Threshold Depth", default=0.1)
|
||||
threshold_offset: bpy.props.FloatProperty(name="Threshold Offset", default=0.025)
|
||||
threshold_offset: bpy.props.FloatProperty(
|
||||
name="Threshold Offset", description="`0.025 mm` is good as default value", default=0.000
|
||||
)
|
||||
|
||||
# panel properties
|
||||
panel_depth: bpy.props.FloatProperty(name="Panel Depth", default=0.035)
|
||||
panel_width_ratio: bpy.props.FloatProperty(
|
||||
name="Panel Width Ratio",
|
||||
description="Width of this panel, given as ratio " \
|
||||
"relative to the total clear opening width of the door",
|
||||
default=1.0, soft_min=0, soft_max=1)
|
||||
name="Panel Width Ratio",
|
||||
description="Width of this panel, given as ratio " "relative to the total clear opening width of the door",
|
||||
default=1.0,
|
||||
soft_min=0,
|
||||
soft_max=1,
|
||||
)
|
||||
frame_thickness: bpy.props.FloatProperty(name="Window Frame Thickness", default=0.035)
|
||||
frame_depth: bpy.props.FloatProperty(name="Window Frame Depth", default=0.035)
|
||||
|
||||
@@ -493,30 +513,27 @@ class BIMDoorProperties(PropertyGroup):
|
||||
"lining_to_panel_offset_y": self.lining_to_panel_offset_y,
|
||||
}
|
||||
|
||||
kwargs['transom_thickness'] = self.transom_thickness
|
||||
kwargs["transom_thickness"] = self.transom_thickness
|
||||
if self.transom_thickness:
|
||||
kwargs['transom_offset'] = self.transom_offset
|
||||
kwargs["transom_offset"] = self.transom_offset
|
||||
|
||||
if not self.lining_offset:
|
||||
kwargs['casing_thickness'] = self.casing_thickness
|
||||
kwargs["casing_thickness"] = self.casing_thickness
|
||||
if self.casing_thickness:
|
||||
kwargs['casing_depth'] = self.casing_depth
|
||||
|
||||
kwargs['threshold_thickness'] = self.threshold_thickness
|
||||
kwargs["casing_depth"] = self.casing_depth
|
||||
|
||||
kwargs["threshold_thickness"] = self.threshold_thickness
|
||||
if self.threshold_thickness:
|
||||
kwargs['threshold_depth'] = self.threshold_depth
|
||||
kwargs['threshold_offset'] = self.threshold_offset
|
||||
kwargs["threshold_depth"] = self.threshold_depth
|
||||
kwargs["threshold_offset"] = self.threshold_offset
|
||||
|
||||
return kwargs
|
||||
|
||||
def get_panel_kwargs(self):
|
||||
kwargs = {
|
||||
"panel_depth": self.panel_depth,
|
||||
"panel_width_ratio": self.panel_width_ratio
|
||||
}
|
||||
kwargs = {"panel_depth": self.panel_depth, "panel_width_ratio": self.panel_width_ratio}
|
||||
|
||||
if self.transom_thickness:
|
||||
kwargs['frame_thickness'] = self.frame_thickness
|
||||
kwargs['frame_depth'] = self.frame_depth
|
||||
kwargs["frame_thickness"] = self.frame_thickness
|
||||
kwargs["frame_depth"] = self.frame_depth
|
||||
|
||||
return kwargs
|
||||
|
||||
@@ -84,7 +84,7 @@ def update_window_modifier_representation(context):
|
||||
"geometry.add_window_representation", ifc_file, **representation_data
|
||||
)
|
||||
replace_ifc_representation_for_object(ifc_file, ifc_context, obj, elevation_representation)
|
||||
|
||||
|
||||
# MODEL_VIEW representation
|
||||
ifc_context = ifcopenshell.util.representation.get_context(ifc_file, "Model", "Body", "MODEL_VIEW")
|
||||
representation_data["context"] = ifc_context
|
||||
@@ -93,9 +93,8 @@ def update_window_modifier_representation(context):
|
||||
ifc_element.PartitioningType = props.window_type
|
||||
|
||||
|
||||
|
||||
def create_bm_window_frame(bm, size: Vector, thickness: Vector, position: Vector = V(0,0,0)):
|
||||
"""`thickness` of the profile is defined as list in the following order:
|
||||
def create_bm_window_frame(bm, size: Vector, thickness: Vector, position: Vector = V(0,0,0).freeze()):
|
||||
"""`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.
|
||||
@@ -159,16 +158,17 @@ def create_bm_window_frame(bm, size: Vector, thickness: Vector, position: Vector
|
||||
return new_verts + translate_verts
|
||||
|
||||
|
||||
def create_bm_box(bm, size:Vector=V(1,1,1).freeze(), position:Vector=V(0,0,0).freeze()):
|
||||
def create_bm_box(bm, size: Vector = V(1,1,1).freeze(), position: Vector = V(0,0,0).freeze()):
|
||||
"""create a box of `size`, position box first vertex at `position`"""
|
||||
box_verts = bmesh.ops.create_cube(bm, size=1)['verts']
|
||||
box_verts = bmesh.ops.create_cube(bm, size=1)["verts"]
|
||||
bmesh.ops.translate(bm, vec=-box_verts[0].co, verts=box_verts)
|
||||
bmesh.ops.scale(bm, vec=size, verts=box_verts)
|
||||
bmesh.ops.translate(bm, vec=position, verts=box_verts)
|
||||
return box_verts
|
||||
|
||||
|
||||
def create_bm_window(bm,
|
||||
def create_bm_window(
|
||||
bm,
|
||||
lining_size: Vector,
|
||||
lining_thickness,
|
||||
lining_to_panel_offset_x,
|
||||
@@ -176,16 +176,13 @@ def create_bm_window(bm,
|
||||
frame_size,
|
||||
frame_thickness,
|
||||
glass_thickness,
|
||||
position: Vector):
|
||||
position: Vector,
|
||||
):
|
||||
# window lining
|
||||
window_lining_verts = create_bm_window_frame(bm, lining_size, lining_thickness)
|
||||
|
||||
# window frame
|
||||
frame_position = V(
|
||||
lining_to_panel_offset_x,
|
||||
lining_to_panel_offset_y_full,
|
||||
lining_to_panel_offset_x
|
||||
)
|
||||
frame_position = V(lining_to_panel_offset_x, lining_to_panel_offset_y_full, lining_to_panel_offset_x)
|
||||
frame_verts = create_bm_window_frame(bm, frame_size, frame_thickness, frame_position)
|
||||
|
||||
# window glass
|
||||
@@ -295,10 +292,10 @@ def update_window_modifier_bmesh(context):
|
||||
frame_size = window_lining_size.copy()
|
||||
frame_size.y = frame_depth
|
||||
frame_size = frame_size - V(lining_to_panel_offset_x * 2, 0, lining_to_panel_offset_x * 2)
|
||||
|
||||
|
||||
window_position = V(accumulated_width, 0, accumulated_height[column_i])
|
||||
lining_verts, panel_verts, glass_verts = create_bm_window(
|
||||
bm,
|
||||
bm,
|
||||
window_lining_size,
|
||||
window_lining_thickness,
|
||||
lining_to_panel_offset_x,
|
||||
@@ -306,7 +303,7 @@ def update_window_modifier_bmesh(context):
|
||||
frame_size,
|
||||
frame_thickness,
|
||||
glass_thickness,
|
||||
window_position
|
||||
window_position,
|
||||
)
|
||||
|
||||
built_panels.append(panel_i)
|
||||
@@ -376,7 +373,7 @@ class AddWindow(bpy.types.Operator, tool.Ifc.Operator):
|
||||
props = obj.BIMWindowProperties
|
||||
|
||||
if element.is_a() not in ("IfcWindow", "IfcWindowType"):
|
||||
self.report({"ERROR"}, "Object has to be IfcWindow/IfcWindowType type to add a stair.")
|
||||
self.report({"ERROR"}, "Object has to be IfcWindow/IfcWindowType type to add a window.")
|
||||
return {"CANCELLED"}
|
||||
|
||||
# need to make sure all default props will have correct units
|
||||
|
||||
@@ -167,7 +167,7 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
|
||||
body = ifcopenshell.util.representation.get_context(ifc_file, "Model", "Body", "MODEL_VIEW")
|
||||
if not body:
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
if template == "MESH":
|
||||
location = context.scene.cursor.location
|
||||
if context.active_object and context.selected_objects and context.active_object.data:
|
||||
@@ -289,7 +289,7 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
|
||||
obj=obj,
|
||||
predefined_type=predefined_type,
|
||||
ifc_class="IfcWindowType",
|
||||
should_add_representation=False
|
||||
should_add_representation=False,
|
||||
)
|
||||
bpy.ops.object.select_all(action="DESELECT")
|
||||
bpy.context.view_layer.objects.active = None
|
||||
@@ -306,7 +306,7 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
|
||||
obj=obj,
|
||||
predefined_type=predefined_type,
|
||||
ifc_class="IfcDoorType",
|
||||
should_add_representation=False
|
||||
should_add_representation=False,
|
||||
)
|
||||
bpy.ops.object.select_all(action="DESELECT")
|
||||
bpy.context.view_layer.objects.active = None
|
||||
|
||||
@@ -24,7 +24,9 @@ from mathutils import Vector
|
||||
import collections
|
||||
|
||||
|
||||
def create_ifc_door_lining_items(builder: ShapeBuilder, size: Vector, thickness: Vector, position:Vector=V(0,0,0).freeze()):
|
||||
def create_ifc_door_lining_items(
|
||||
builder: ShapeBuilder, size: Vector, thickness: Vector, position: Vector = V(0,0,0).freeze()
|
||||
):
|
||||
"""`thickness` of the profile is defined as list in the following order: `(SIDE, TOP)`
|
||||
|
||||
`thickness` can be also defined just as 1 float value.
|
||||
@@ -44,7 +46,8 @@ def create_ifc_door_lining_items(builder: ShapeBuilder, size: Vector, thickness:
|
||||
|
||||
return items
|
||||
|
||||
def create_ifc_box(builder: ShapeBuilder, size: Vector, position:Vector=V(0,0,0).freeze()):
|
||||
|
||||
def create_ifc_box(builder: ShapeBuilder, size: Vector, position: Vector = V(0,0,0).freeze()):
|
||||
rect = builder.rectangle(size.xy)
|
||||
box = builder.extrude(rect, size.z, position=position, extrusion_vector=V(0,0,1))
|
||||
return box
|
||||
@@ -59,61 +62,51 @@ class Usecase:
|
||||
# http://ifc43-docs.standards.buildingsmart.org/IFC/RELEASE/IFC4x3/HTML/lexical/IfcDoorLiningProperties.htm
|
||||
# http://ifc43-docs.standards.buildingsmart.org/IFC/RELEASE/IFC4x3/HTML/lexical/IfcDoorPanelProperties.htm
|
||||
self.settings = {"unit_scale": ifcopenshell.util.unit.calculate_unit_scale(self.file)}
|
||||
# TODO: remove upper window from default props after tests
|
||||
# TODO: check default values with blender props
|
||||
self.settings.update(
|
||||
{
|
||||
"context": None, # IfcGeometricRepresentationContext
|
||||
"overall_height": self.convert_si_to_unit(0.9),
|
||||
"overall_width": self.convert_si_to_unit(0.6),
|
||||
|
||||
# DOUBLE_DOOR_DOUBLE_SWING, DOUBLE_DOOR_FOLDING, DOUBLE_DOOR_LIFTING_VERTICAL,
|
||||
# DOUBLE_DOOR_SINGLE_SWING, DOUBLE_DOOR_SINGLE_SWING_OPPOSITE_LEFT,
|
||||
# DOUBLE_DOOR_SINGLE_SWING_OPPOSITE_RIGHT, DOUBLE_DOOR_SLIDING,
|
||||
# DOUBLE_SWING_LEFT, DOUBLE_SWING_RIGHT, FOLDING_TO_LEFT,
|
||||
# FOLDING_TO_RIGHT, LIFTING_HORIZONTAL, LIFTING_VERTICAL_LEFT,
|
||||
# LIFTING_VERTICAL_RIGHT, REVOLVING, REVOLVING_VERTICAL,
|
||||
# ROLLINGUP, SINGLE_SWING_LEFT, SINGLE_SWING_RIGHT, SLIDING_TO_LEFT,
|
||||
"overall_height": self.convert_si_to_unit(2.0),
|
||||
"overall_width": self.convert_si_to_unit(0.9),
|
||||
# DOUBLE_DOOR_DOUBLE_SWING, DOUBLE_DOOR_FOLDING, DOUBLE_DOOR_LIFTING_VERTICAL,
|
||||
# DOUBLE_DOOR_SINGLE_SWING, DOUBLE_DOOR_SINGLE_SWING_OPPOSITE_LEFT,
|
||||
# DOUBLE_DOOR_SINGLE_SWING_OPPOSITE_RIGHT, DOUBLE_DOOR_SLIDING,
|
||||
# DOUBLE_SWING_LEFT, DOUBLE_SWING_RIGHT, FOLDING_TO_LEFT,
|
||||
# FOLDING_TO_RIGHT, LIFTING_HORIZONTAL, LIFTING_VERTICAL_LEFT,
|
||||
# LIFTING_VERTICAL_RIGHT, REVOLVING, REVOLVING_VERTICAL,
|
||||
# ROLLINGUP, SINGLE_SWING_LEFT, SINGLE_SWING_RIGHT, SLIDING_TO_LEFT,
|
||||
# SLIDING_TO_RIGHT, SWING_FIXED_LEFT, SWING_FIXED_RIGHT
|
||||
# TODO: take into account door types
|
||||
"operation_type": "SINGLE_SWING_LEFT", # door type
|
||||
"operation_type": "SINGLE_SWING_LEFT", # door type
|
||||
"lining_properties": {
|
||||
"LiningDepth": self.convert_si_to_unit(0.050),
|
||||
"LiningThickness": self.convert_si_to_unit(0.050),
|
||||
|
||||
# offset from the outer side of the wall (by Y-axis)
|
||||
"LiningOffset": self.convert_si_to_unit(0.050),
|
||||
"LiningOffset": self.convert_si_to_unit(0.0),
|
||||
# offset from the wall
|
||||
"LiningToPanelOffsetX": self.convert_si_to_unit(0.025),
|
||||
"LiningToPanelOffsetX": self.convert_si_to_unit(0.025),
|
||||
# offset from the elevation view rectangle (unlike windows)
|
||||
"LiningToPanelOffsetY": self.convert_si_to_unit(0.025),
|
||||
|
||||
# transom - vertical distance between door and window panels
|
||||
"TransomThickness": self.convert_si_to_unit(0.000),
|
||||
# TransomOffset - distance from the bottom door opening
|
||||
# to the beginning of the transom
|
||||
# unlike windows TransomOffset which goes to the center of the transom
|
||||
"TransomOffset": self.convert_si_to_unit(1.525),
|
||||
"ShapeAspectStyle": None, # DEPRECATED
|
||||
# Casing cover wall faces around the opening
|
||||
# on the left, right and upper sides
|
||||
# Casing should be either on both sides of the wall or no casing
|
||||
# If `LiningOffset` is present then therefore casing is not possible on outer wall
|
||||
# therefore there will be no casing on inner wall either
|
||||
"CasingDepth": self.convert_si_to_unit(0.025),
|
||||
"CasingThickness": self.convert_si_to_unit(0.075), # by Z-axis
|
||||
|
||||
# TODO: link to wall thickness?
|
||||
# therefore there will be no casing on inner wall either
|
||||
"CasingDepth": self.convert_si_to_unit(0.005),
|
||||
"CasingThickness": self.convert_si_to_unit(0.075), # by Z-axis
|
||||
# Threshold covers the bottom side of the opening
|
||||
"ThresholdDepth": self.convert_si_to_unit(0.025),
|
||||
"ThresholdThickness": self.convert_si_to_unit(0.025), # by Z-axis
|
||||
# offset to X-axis
|
||||
# TODO: offset goes by Z-axis?
|
||||
"ThresholdOffset": self.convert_si_to_unit(0.025),
|
||||
|
||||
# transom - vertical distance between door and window panels
|
||||
"TransomThickness": self.convert_si_to_unit(0.050),
|
||||
# TransomOffset - distance from the bottom door opening
|
||||
# to the beginning of the transom
|
||||
# unlike windows TransomOffset which goes to the center of the transom
|
||||
"TransomOffset": self.convert_si_to_unit(0.6),
|
||||
"ShapeAspectStyle": None, # DEPRECATED
|
||||
"ThresholdDepth": self.convert_si_to_unit(0.1),
|
||||
"ThresholdThickness": self.convert_si_to_unit(0.025), # by Z-axis
|
||||
# offset by Y-axis
|
||||
"ThresholdOffset": self.convert_si_to_unit(0.000),
|
||||
},
|
||||
"panel_properties": {
|
||||
"PanelDepth": self.convert_si_to_unit(0.030), # by Y
|
||||
"PanelDepth": self.convert_si_to_unit(0.035), # by Y
|
||||
"PanelWidth": 1.0, # as ratio to the clear door opening
|
||||
"FrameDepth": self.convert_si_to_unit(0.035), # by Y
|
||||
"FrameThickness": self.convert_si_to_unit(0.035), # by X
|
||||
@@ -129,13 +122,13 @@ class Usecase:
|
||||
for key, value in settings.items():
|
||||
self.settings[key] = value
|
||||
|
||||
def execute(self):
|
||||
def execute(self):
|
||||
builder = ShapeBuilder(self.file)
|
||||
overall_height = self.settings["overall_height"]
|
||||
overall_width = self.settings["overall_width"]
|
||||
door_type = self.settings["operation_type"]
|
||||
|
||||
if door_type not in ('SINGLE_SWING_LEFT', 'SINGLE_SWING_RIGHT'):
|
||||
|
||||
if door_type not in ("SINGLE_SWING_LEFT", "SINGLE_SWING_RIGHT"):
|
||||
raise NotImplementedError(f'Door type "{door_type}" is not currently supported.')
|
||||
|
||||
if self.settings["context"].TargetView == "ELEVATION_VIEW":
|
||||
@@ -147,36 +140,36 @@ class Usecase:
|
||||
lining_props = self.settings["lining_properties"]
|
||||
|
||||
# lining params
|
||||
lining_depth = lining_props['LiningDepth']
|
||||
lining_thickness_default = lining_props['LiningThickness']
|
||||
lining_offset = lining_props['LiningOffset']
|
||||
lining_to_panel_offset_x = lining_props['LiningToPanelOffsetX']
|
||||
lining_to_panel_offset_y_full = lining_props['LiningToPanelOffsetY']
|
||||
lining_depth = lining_props["LiningDepth"]
|
||||
lining_thickness_default = lining_props["LiningThickness"]
|
||||
lining_offset = lining_props["LiningOffset"]
|
||||
lining_to_panel_offset_x = lining_props["LiningToPanelOffsetX"]
|
||||
lining_to_panel_offset_y_full = lining_props["LiningToPanelOffsetY"]
|
||||
|
||||
transom_thickness = lining_props['TransomThickness'] / 2
|
||||
transfom_offset = lining_props['TransomOffset']
|
||||
transom_thickness = lining_props["TransomThickness"] / 2
|
||||
transfom_offset = lining_props["TransomOffset"]
|
||||
if transom_thickness == 0:
|
||||
transfom_offset = 0
|
||||
|
||||
window_lining_height = overall_height - transfom_offset - transom_thickness
|
||||
top_lining_thickness = transom_thickness or lining_thickness_default
|
||||
panel_lining_overlap_x = max(lining_thickness_default - lining_to_panel_offset_x, 0)
|
||||
panel_top_lining_overlap_x = max(top_lining_thickness - lining_to_panel_offset_x, 0)
|
||||
door_opening_width = (overall_width - lining_to_panel_offset_x * 2)
|
||||
panel_lining_overlap_x = max(lining_thickness_default - lining_to_panel_offset_x, 0)
|
||||
panel_top_lining_overlap_x = max(top_lining_thickness - lining_to_panel_offset_x, 0)
|
||||
door_opening_width = overall_width - lining_to_panel_offset_x * 2
|
||||
|
||||
threshold_thickness = lining_props['ThresholdThickness']
|
||||
threshold_depth = lining_props['ThresholdDepth']
|
||||
threshold_offset = lining_props['ThresholdOffset']
|
||||
threshold_thickness = lining_props["ThresholdThickness"]
|
||||
threshold_depth = lining_props["ThresholdDepth"]
|
||||
threshold_offset = lining_props["ThresholdOffset"]
|
||||
threshold_width = overall_width - lining_thickness_default * 2
|
||||
|
||||
casing_thickness = lining_props['CasingThickness']
|
||||
casing_depth = lining_props['CasingDepth']
|
||||
casing_thickness = lining_props["CasingThickness"]
|
||||
casing_depth = lining_props["CasingDepth"]
|
||||
|
||||
# panel params
|
||||
panel_depth = panel_props['PanelDepth']
|
||||
panel_width = door_opening_width * panel_props['PanelWidth']
|
||||
frame_depth = panel_props['FrameDepth']
|
||||
frame_thickness = panel_props['FrameThickness']
|
||||
panel_depth = panel_props["PanelDepth"]
|
||||
panel_width = door_opening_width * panel_props["PanelWidth"]
|
||||
frame_depth = panel_props["FrameDepth"]
|
||||
frame_thickness = panel_props["FrameThickness"]
|
||||
frame_height = window_lining_height - lining_to_panel_offset_x * 2
|
||||
glass_thickness = self.convert_si_to_unit(0.01)
|
||||
|
||||
@@ -186,7 +179,7 @@ class Usecase:
|
||||
else:
|
||||
panel_height = overall_height - lining_to_panel_offset_x - threshold_thickness
|
||||
lining_height = overall_height
|
||||
|
||||
|
||||
# add lining
|
||||
lining_size = V(overall_width, lining_depth, lining_height)
|
||||
lining_thickness = [lining_thickness_default, top_lining_thickness]
|
||||
@@ -197,7 +190,6 @@ class Usecase:
|
||||
|
||||
# create 2d representation
|
||||
if self.settings["context"].TargetView == "PLAN_VIEW":
|
||||
|
||||
items_2d = []
|
||||
|
||||
# create lining
|
||||
@@ -215,13 +207,14 @@ class Usecase:
|
||||
lining = builder.rectangle(V(lining_thickness_default, lining_depth))
|
||||
|
||||
items_2d.append(lining)
|
||||
items_2d.append(builder.mirror(lining, mirror_axes=V(1,0), mirror_point=V(overall_width/2, 0), create_copy=True))
|
||||
items_2d.append(
|
||||
builder.mirror(lining, mirror_axes=V(1, 0), mirror_point=V(overall_width / 2, 0), create_copy=True)
|
||||
)
|
||||
|
||||
# create semi-semi-circle
|
||||
semicircle = builder.create_ellipse_curve(panel_width-panel_depth,
|
||||
panel_width,
|
||||
trim_points_mask=(0,1),
|
||||
position=V(panel_depth, 0))
|
||||
semicircle = builder.create_ellipse_curve(
|
||||
panel_width - panel_depth, panel_width, trim_points_mask=(0, 1), position=V(panel_depth, 0)
|
||||
)
|
||||
items_2d.append(semicircle)
|
||||
|
||||
# create door
|
||||
@@ -229,8 +222,8 @@ class Usecase:
|
||||
items_2d.append(door)
|
||||
|
||||
builder.translate([semicircle, door], V(lining_to_panel_offset_x, lining_depth))
|
||||
|
||||
if door_type == 'SINGLE_SWING_RIGHT':
|
||||
|
||||
if door_type == "SINGLE_SWING_RIGHT":
|
||||
builder.mirror([semicircle, door], mirror_axes=V(1,0), mirror_point=V(overall_width/2, 0))
|
||||
|
||||
representation_2d = builder.get_representation(self.settings["context"], items_2d)
|
||||
@@ -250,10 +243,9 @@ class Usecase:
|
||||
second_lining_position = V(0, lining_to_panel_offset_y_full, 0)
|
||||
second_lining_thickness = [min(th, lining_to_panel_offset_x) for th in lining_thickness]
|
||||
|
||||
second_lining = create_ifc_door_lining_items(builder,
|
||||
second_lining_size,
|
||||
second_lining_thickness,
|
||||
second_lining_position)
|
||||
second_lining = create_ifc_door_lining_items(
|
||||
builder, second_lining_size, second_lining_thickness, second_lining_position
|
||||
)
|
||||
lining_items.extend(second_lining)
|
||||
|
||||
main_lining = create_ifc_door_lining_items(builder, main_lining_size, lining_thickness)
|
||||
@@ -271,30 +263,24 @@ class Usecase:
|
||||
casing_items = []
|
||||
if not lining_offset and casing_thickness:
|
||||
casing_wall_overlap = max(casing_thickness - lining_thickness_default, 0)
|
||||
casing_size = V(overall_width + casing_wall_overlap*2, casing_depth, overall_height+casing_wall_overlap)
|
||||
casing_size = V(overall_width + casing_wall_overlap*2, casing_depth, overall_height + casing_wall_overlap)
|
||||
casing_position = V(-casing_wall_overlap, -casing_depth, 0)
|
||||
outer_casing_items = create_ifc_door_lining_items(builder, casing_size, casing_thickness, casing_position)
|
||||
casing_items.extend(outer_casing_items)
|
||||
|
||||
inner_casing_thickness = [
|
||||
casing_thickness-panel_lining_overlap_x,
|
||||
casing_thickness-panel_top_lining_overlap_x
|
||||
casing_thickness - panel_lining_overlap_x,
|
||||
casing_thickness - panel_top_lining_overlap_x,
|
||||
]
|
||||
inner_casing_position = V(-casing_wall_overlap, lining_depth, 0)
|
||||
inner_casing_items = create_ifc_door_lining_items(builder, casing_size, inner_casing_thickness, inner_casing_position)
|
||||
inner_casing_items = create_ifc_door_lining_items(
|
||||
builder, casing_size, inner_casing_thickness, inner_casing_position
|
||||
)
|
||||
casing_items.extend(inner_casing_items)
|
||||
|
||||
# add door panel
|
||||
panel_size = V(
|
||||
panel_width,
|
||||
panel_depth,
|
||||
panel_height
|
||||
)
|
||||
panel_position = V(
|
||||
lining_to_panel_offset_x,
|
||||
lining_to_panel_offset_y_full,
|
||||
threshold_thickness
|
||||
)
|
||||
panel_size = V(panel_width, panel_depth, panel_height)
|
||||
panel_position = V(lining_to_panel_offset_x, lining_to_panel_offset_y_full, threshold_thickness)
|
||||
panel_items = [create_ifc_box(builder, panel_size, panel_position)]
|
||||
|
||||
# add on top window
|
||||
@@ -303,21 +289,13 @@ class Usecase:
|
||||
frame_items = []
|
||||
glass_items = []
|
||||
else:
|
||||
window_lining_thickness = [lining_thickness_default] * 3
|
||||
window_lining_thickness = [lining_thickness_default] * 3
|
||||
window_lining_thickness.append(transom_thickness)
|
||||
window_lining_size = V(
|
||||
overall_width,
|
||||
lining_depth,
|
||||
window_lining_height
|
||||
)
|
||||
window_position = V(0, 0, overall_height-window_lining_height)
|
||||
frame_size = V(
|
||||
door_opening_width,
|
||||
frame_depth,
|
||||
frame_height
|
||||
)
|
||||
window_lining_size = V(overall_width, lining_depth, window_lining_height)
|
||||
window_position = V(0, 0, overall_height - window_lining_height)
|
||||
frame_size = V(door_opening_width, frame_depth, frame_height)
|
||||
window_lining_items, frame_items, glass_items = create_ifc_window(
|
||||
builder,
|
||||
builder,
|
||||
window_lining_size,
|
||||
window_lining_thickness,
|
||||
lining_to_panel_offset_x,
|
||||
@@ -325,10 +303,10 @@ class Usecase:
|
||||
frame_size,
|
||||
frame_thickness,
|
||||
glass_thickness,
|
||||
window_position
|
||||
window_position,
|
||||
)
|
||||
|
||||
lining_offset_items = lining_items+panel_items+window_lining_items+frame_items+glass_items
|
||||
lining_offset_items = lining_items + panel_items + window_lining_items + frame_items + glass_items
|
||||
builder.translate(lining_offset_items, V(0, lining_offset, 0))
|
||||
|
||||
ouput_items = lining_offset_items + threshold_items + casing_items
|
||||
|
||||
@@ -41,12 +41,9 @@ DEFAULT_PANEL_SCHEMAS = {
|
||||
"TRIPLE_PANEL_VERTICAL": [[0, 1, 2]],
|
||||
}
|
||||
|
||||
def create_ifc_window_frame_simple(
|
||||
builder,
|
||||
size: Vector,
|
||||
thickness: Vector,
|
||||
position: Vector = V(0,0,0)):
|
||||
"""`thickness` of the profile is defined as list in the following order:
|
||||
|
||||
def create_ifc_window_frame_simple(builder, size: Vector, thickness: Vector, position: Vector = V(0,0,0).freeze()):
|
||||
"""`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.
|
||||
@@ -59,21 +56,14 @@ def create_ifc_window_frame_simple(
|
||||
|
||||
panel_rect = builder.rectangle(size=size*V(1,0,1))
|
||||
|
||||
inner_rect_size = size - V(th_left+th_right, 0, th_bottom+th_up)
|
||||
inner_rect = builder.rectangle(
|
||||
size=inner_rect_size*V(1, 0, 1),
|
||||
position=V(th_left, 0, th_bottom)
|
||||
)
|
||||
inner_rect_size = size - V(th_left + th_right, 0, th_bottom + th_up)
|
||||
inner_rect = builder.rectangle(size=inner_rect_size * V(1, 0, 1), position=V(th_left, 0, th_bottom))
|
||||
|
||||
panel_profile = builder.profile(panel_rect, inner_curves=inner_rect)
|
||||
panel_extruded = builder.extrude(
|
||||
panel_profile,
|
||||
size.y,
|
||||
extrusion_vector=V(0, 1, 0),
|
||||
position=position
|
||||
)
|
||||
panel_extruded = builder.extrude(panel_profile, size.y, extrusion_vector=V(0, 1, 0), position=position)
|
||||
return panel_extruded
|
||||
|
||||
|
||||
def create_ifc_window(
|
||||
builder,
|
||||
lining_size: Vector,
|
||||
@@ -83,8 +73,8 @@ def create_ifc_window(
|
||||
frame_size,
|
||||
frame_thickness,
|
||||
glass_thickness,
|
||||
position: Vector):
|
||||
|
||||
position: Vector,
|
||||
):
|
||||
lining_items = []
|
||||
main_lining_size = lining_size
|
||||
|
||||
@@ -102,28 +92,21 @@ def create_ifc_window(
|
||||
second_lining_position = V(0, lining_to_panel_offset_y_full, 0)
|
||||
second_lining_thickness = [min(th, lining_to_panel_offset_x) for th in lining_thickness]
|
||||
|
||||
second_lining = create_ifc_window_frame_simple(builder,
|
||||
second_lining_size,
|
||||
second_lining_thickness,
|
||||
second_lining_position)
|
||||
second_lining = create_ifc_window_frame_simple(
|
||||
builder, second_lining_size, second_lining_thickness, second_lining_position
|
||||
)
|
||||
lining_items.append(second_lining)
|
||||
|
||||
main_lining = create_ifc_window_frame_simple(builder, main_lining_size, lining_thickness)
|
||||
lining_items.append(main_lining)
|
||||
|
||||
frame_position = V(
|
||||
lining_to_panel_offset_x,
|
||||
lining_to_panel_offset_y_full,
|
||||
lining_to_panel_offset_x
|
||||
)
|
||||
frame_position = V(lining_to_panel_offset_x, lining_to_panel_offset_y_full, lining_to_panel_offset_x)
|
||||
|
||||
frame_extruded = create_ifc_window_frame_simple(builder, frame_size, frame_thickness, frame_position)
|
||||
|
||||
glass_position = frame_position + V(0, frame_size.y / 2 - glass_thickness / 2, 0)
|
||||
glass_rect = builder.deep_copy(frame_extruded.SweptArea.InnerCurves[0])
|
||||
glass = builder.extrude(
|
||||
glass_rect, glass_thickness, extrusion_vector=V(0, 1, 0), position=glass_position
|
||||
)
|
||||
glass = builder.extrude(glass_rect, glass_thickness, extrusion_vector=V(0, 1, 0), position=glass_position)
|
||||
|
||||
output_items = [lining_items, [frame_extruded], [glass]]
|
||||
builder.translate(chain(*output_items), position)
|
||||
@@ -211,7 +194,6 @@ class Usecase:
|
||||
built_panels = []
|
||||
window_items = []
|
||||
|
||||
|
||||
lining_props = self.settings["lining_properties"]
|
||||
lining_thickness = lining_props["LiningThickness"]
|
||||
lining_depth = lining_props["LiningDepth"]
|
||||
@@ -295,7 +277,7 @@ class Usecase:
|
||||
|
||||
# create window panel
|
||||
current_window_items = create_ifc_window(
|
||||
builder,
|
||||
builder,
|
||||
window_lining_size,
|
||||
window_lining_thickness,
|
||||
lining_to_panel_offset_x,
|
||||
@@ -303,7 +285,7 @@ class Usecase:
|
||||
frame_size,
|
||||
frame_thickness,
|
||||
glass_thickness,
|
||||
window_panel_position
|
||||
window_panel_position,
|
||||
)
|
||||
built_panels.append(panel_i)
|
||||
window_items.extend(chain(*current_window_items))
|
||||
|
||||
Reference in New Issue
Block a user