Sliding doors - moved annotation arrow to Annotation/PLAN_VIEW #2919

This commit is contained in:
Andrej730
2023-04-04 18:29:49 +05:00
parent b44cd7e153
commit 5d4ecb7177
3 changed files with 75 additions and 42 deletions
@@ -43,6 +43,7 @@ def update_door_modifier_representation(context):
props = obj.BIMDoorProperties
element = tool.Ifc.get_entity(obj)
ifc_file = tool.Ifc.get()
sliding_door = "SLIDING" in props.door_type
representation_data = {
"operation_type": props.door_type,
@@ -87,13 +88,37 @@ def update_door_modifier_representation(context):
model_representation = ifcopenshell.api.run("geometry.add_door_representation", ifc_file, **representation_data)
tool.Model.replace_object_ifc_representation(body, obj, model_representation)
# PLAN_VIEW representation
plan = ifcopenshell.util.representation.get_context(ifc_file, "Plan", "Body", "PLAN_VIEW")
if plan:
representation_data["context"] = plan
# Body/PLAN_VIEW representation
plan_body = ifcopenshell.util.representation.get_context(ifc_file, "Plan", "Body", "PLAN_VIEW")
if plan_body:
representation_data["context"] = plan_body
plan_representation = ifcopenshell.api.run("geometry.add_door_representation", ifc_file, **representation_data)
tool.Model.replace_object_ifc_representation(plan, obj, plan_representation)
tool.Model.replace_object_ifc_representation(plan_body, obj, plan_representation)
# Annotation/PLAN_VIEW representation
plan_annotation = ifcopenshell.util.representation.get_context(ifc_file, "Plan", "Annotation", "PLAN_VIEW")
if plan_annotation:
if not sliding_door:
# only sliding doors have Annotation/PLAN_VIEW
# for other types we just check for old representation and remove it if it's there
old_representation = ifcopenshell.util.representation.get_representation(
element, "Plan", "Annotation", "PLAN_VIEW"
)
if old_representation:
core.remove_representation(
tool.Ifc,
tool.Geometry,
obj=obj,
representation=old_representation,
)
else:
representation_data["context"] = plan_annotation
plan_representation = ifcopenshell.api.run(
"geometry.add_door_representation", ifc_file, **representation_data
)
tool.Model.replace_object_ifc_representation(plan_annotation, obj, plan_representation)
if plan_body or plan_annotation:
# adding switch representation at the end instead of changing order of representations
# to prevent #2744
core.switch_representation(
@@ -236,8 +236,44 @@ class Usecase:
# create 2d representation
if self.settings["context"].TargetView == "PLAN_VIEW":
items_2d = []
door_items = []
panel_size = V(panel_width, panel_depth)
if not sliding_door:
panel_position = V(lining_to_panel_offset_x, lining_depth)
else:
panel_position = V(lining_to_panel_offset_x, -panel_size.y)
if self.settings["context"].ContextIdentifier == "Annotation":
# only sliding door has annotation representation
if not sliding_door:
return None
# arrow symbol
arrow_symbol = []
arrow_offset = slider_arrow_symbol_size / cos(radians(15))
arrow_symbol.append(
builder.polyline(
points=(V(0.35 * panel_size.x, 0), V(0.65 * panel_size.x, 0)),
)
)
arrow_symbol.append(
builder.polyline(
points=(
V(slider_arrow_symbol_size, arrow_offset),
V(0, 0),
V(slider_arrow_symbol_size, -arrow_offset),
),
position_offset=V(0.35 * panel_size.x, 0),
)
)
builder.translate(arrow_symbol, panel_position + V(0, -arrow_offset * 1.5))
items_2d.extend(arrow_symbol)
representation_2d = builder.get_representation(self.settings["context"], items_2d, "Curve2D")
return representation_2d
door_items = []
# create lining
if l_shape_check([side_lining_thickness]):
lining_points = [
@@ -302,30 +338,7 @@ class Usecase:
door_items.append(
builder.rectangle(size=handle_size.zz, position=V(panel_size.x * 0.1, -handle_size.z * 0.5))
)
# arrow symbol
arrow_symbol = []
arrow_offset = slider_arrow_symbol_size / cos(radians(15))
arrow_symbol.append(
builder.polyline(
points=(V(0.35 * panel_size.x, 0), V(0.65 * panel_size.x, 0)),
)
)
arrow_symbol.append(
builder.polyline(
points=(
V(slider_arrow_symbol_size, arrow_offset),
V(0, 0),
V(slider_arrow_symbol_size, -arrow_offset),
),
position_offset=V(0.35 * panel_size.x, 0),
)
)
builder.translate(arrow_symbol, panel_position + V(0, -arrow_offset * 1.5))
builder.translate(door_items, panel_position - V(panel_size.x * 0.2, 0))
door_items.extend(arrow_symbol)
if door_swing_type == "RIGHT":
mirror_point = panel_position + V(panel_size.x / 2, 0)
@@ -333,12 +346,6 @@ class Usecase:
return door_items
door_items = []
panel_size = V(panel_width, panel_depth)
if not sliding_door:
panel_position = V(lining_to_panel_offset_x, lining_depth)
else:
panel_position = V(lining_to_panel_offset_x, -panel_size.y)
if double_door:
panel_size.x = panel_size.x / 2
door_items.extend(create_ifc_door_panel_2d(panel_size, panel_position, "LEFT", sliding_door))
@@ -513,18 +513,19 @@ class ShapeBuilder:
)
return extruded_area
def get_representation(self, context, items):
def get_representation(self, context, items, representation_type=None):
# > items - could be a list or single curve/IfcExtrudedAreaSolid
# < IfcShapeRepresentation
if not isinstance(items, collections.abc.Iterable):
items = [items]
if items[0].is_a("IfcExtrudedAreaSolid"):
representation_type = "SweptSolid"
elif items[0].is_a("IfcCurve") and items[0].Dim == 3:
representation_type = "Curve3D"
else:
representation_type = "Curve2D"
if not representation_type:
if items[0].is_a("IfcExtrudedAreaSolid"):
representation_type = "SweptSolid"
elif items[0].is_a("IfcCurve") and items[0].Dim == 3:
representation_type = "Curve3D"
else:
representation_type = "Curve2D"
representation = self.file.createIfcShapeRepresentation(
ContextOfItems=context,