mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-09 13:52:23 +00:00
Simplified door ifc representation
This commit is contained in:
@@ -85,18 +85,30 @@ def update_door_modifier_representation(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)
|
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", "Body", "PLAN_VIEW")
|
|
||||||
representation_data["context"] = ifc_context
|
|
||||||
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
|
# MODEL_VIEW representation
|
||||||
ifc_context = ifcopenshell.util.representation.get_context(ifc_file, "Model", "Body", "MODEL_VIEW")
|
ifc_context = ifcopenshell.util.representation.get_context(ifc_file, "Model", "Body", "MODEL_VIEW")
|
||||||
representation_data["context"] = ifc_context
|
representation_data["context"] = ifc_context
|
||||||
model_representation = ifcopenshell.api.run("geometry.add_door_representation", ifc_file, **representation_data)
|
model_representation = ifcopenshell.api.run("geometry.add_door_representation", ifc_file, **representation_data)
|
||||||
replace_ifc_representation_for_object(ifc_file, ifc_context, obj, model_representation)
|
replace_ifc_representation_for_object(ifc_file, ifc_context, obj, model_representation)
|
||||||
|
|
||||||
|
# PLAN_VIEW representation
|
||||||
|
ifc_context = get_ifc_context_or_create(ifc_file, "Plan", "Body", "PLAN_VIEW")
|
||||||
|
representation_data["context"] = ifc_context
|
||||||
|
plan_representation = ifcopenshell.api.run("geometry.add_door_representation", ifc_file, **representation_data)
|
||||||
|
replace_ifc_representation_for_object(ifc_file, ifc_context, obj, plan_representation)
|
||||||
|
|
||||||
|
# adding switch representation at the end instead of changing order of representations
|
||||||
|
# to prevent #2744
|
||||||
|
core.switch_representation(
|
||||||
|
tool.Ifc,
|
||||||
|
tool.Geometry,
|
||||||
|
obj=obj,
|
||||||
|
representation=model_representation,
|
||||||
|
should_reload=True,
|
||||||
|
is_global=False,
|
||||||
|
should_sync_changes_first=True,
|
||||||
|
)
|
||||||
|
|
||||||
ifc_element.OperationType = props.door_type
|
ifc_element.OperationType = props.door_type
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ from mathutils import Vector
|
|||||||
import collections
|
import collections
|
||||||
|
|
||||||
|
|
||||||
def create_ifc_door_lining_items(
|
def create_ifc_door_lining(
|
||||||
builder: ShapeBuilder, size: Vector, thickness: Vector, position: Vector = V(0,0,0).freeze()
|
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` of the profile is defined as list in the following order: `(SIDE, TOP)`
|
||||||
@@ -36,15 +36,22 @@ def create_ifc_door_lining_items(
|
|||||||
|
|
||||||
th_side, th_up = thickness
|
th_side, th_up = thickness
|
||||||
|
|
||||||
left_lining = builder.rectangle(V(th_side, 0, size.z))
|
points = [
|
||||||
right_lining = builder.translate(left_lining, V(size.x-th_side, 0, 0), create_copy=True)
|
V(0.0, 0.0, 0.0),
|
||||||
top_lining = builder.rectangle(V(size.x, 0, th_up), V(0, 0, size.z-th_up))
|
V(0.0, 0.0, size.z),
|
||||||
items = [left_lining, right_lining, top_lining]
|
V(size.x, 0.0, size.z),
|
||||||
|
V(size.x, 0.0, 0.0),
|
||||||
|
V(size.x - th_side, 0.0, 0.0),
|
||||||
|
V(size.x - th_side, 0.0, size.z-th_up),
|
||||||
|
V(th_side, 0.0, size.z-th_up),
|
||||||
|
V(th_side, 0.0, 0.0),
|
||||||
|
]
|
||||||
|
|
||||||
items = [builder.extrude(l, size.y, extrusion_vector=V(0,1,0)) for l in items]
|
door_lining = builder.polyline(points, closed=True)
|
||||||
builder.translate(items, position)
|
door_lining = builder.extrude(door_lining, size.y, extrusion_vector=V(0,1,0))
|
||||||
|
builder.translate(door_lining, position)
|
||||||
|
|
||||||
return items
|
return door_lining
|
||||||
|
|
||||||
|
|
||||||
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()):
|
||||||
@@ -243,13 +250,13 @@ class Usecase:
|
|||||||
second_lining_position = V(0, lining_to_panel_offset_y_full, 0)
|
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_thickness = [min(th, lining_to_panel_offset_x) for th in lining_thickness]
|
||||||
|
|
||||||
second_lining = create_ifc_door_lining_items(
|
second_lining = create_ifc_door_lining(
|
||||||
builder, second_lining_size, second_lining_thickness, second_lining_position
|
builder, second_lining_size, second_lining_thickness, second_lining_position
|
||||||
)
|
)
|
||||||
lining_items.extend(second_lining)
|
lining_items.append(second_lining)
|
||||||
|
|
||||||
main_lining = create_ifc_door_lining_items(builder, main_lining_size, lining_thickness)
|
main_lining = create_ifc_door_lining(builder, main_lining_size, lining_thickness)
|
||||||
lining_items.extend(main_lining)
|
lining_items.append(main_lining)
|
||||||
|
|
||||||
# add threshold
|
# add threshold
|
||||||
if not threshold_thickness:
|
if not threshold_thickness:
|
||||||
@@ -265,18 +272,18 @@ class Usecase:
|
|||||||
casing_wall_overlap = max(casing_thickness - lining_thickness_default, 0)
|
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)
|
casing_position = V(-casing_wall_overlap, -casing_depth, 0)
|
||||||
outer_casing_items = create_ifc_door_lining_items(builder, casing_size, casing_thickness, casing_position)
|
outer_casing = create_ifc_door_lining(builder, casing_size, casing_thickness, casing_position)
|
||||||
casing_items.extend(outer_casing_items)
|
casing_items.append(outer_casing)
|
||||||
|
|
||||||
inner_casing_thickness = [
|
inner_casing_thickness = [
|
||||||
casing_thickness - panel_lining_overlap_x,
|
casing_thickness - panel_lining_overlap_x,
|
||||||
casing_thickness - panel_top_lining_overlap_x,
|
casing_thickness - panel_top_lining_overlap_x,
|
||||||
]
|
]
|
||||||
inner_casing_position = V(-casing_wall_overlap, lining_depth, 0)
|
inner_casing_position = V(-casing_wall_overlap, lining_depth, 0)
|
||||||
inner_casing_items = create_ifc_door_lining_items(
|
inner_casing = create_ifc_door_lining(
|
||||||
builder, casing_size, inner_casing_thickness, inner_casing_position
|
builder, casing_size, inner_casing_thickness, inner_casing_position
|
||||||
)
|
)
|
||||||
casing_items.extend(inner_casing_items)
|
casing_items.append(inner_casing)
|
||||||
|
|
||||||
# add door panel
|
# add door panel
|
||||||
panel_size = V(panel_width, panel_depth, panel_height)
|
panel_size = V(panel_width, panel_depth, panel_height)
|
||||||
@@ -309,8 +316,9 @@ class Usecase:
|
|||||||
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))
|
builder.translate(lining_offset_items, V(0, lining_offset, 0))
|
||||||
|
|
||||||
ouput_items = lining_offset_items + threshold_items + casing_items
|
output_items = lining_offset_items + threshold_items + casing_items
|
||||||
representation = builder.get_representation(self.settings["context"], ouput_items)
|
|
||||||
|
representation = builder.get_representation(self.settings["context"], output_items)
|
||||||
return representation
|
return representation
|
||||||
|
|
||||||
def convert_si_to_unit(self, value):
|
def convert_si_to_unit(self, value):
|
||||||
|
|||||||
Reference in New Issue
Block a user