mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-14 10:01:44 +00:00
Sliding doors - moved annotation arrow to Annotation/PLAN_VIEW #2919
This commit is contained in:
@@ -43,6 +43,7 @@ def update_door_modifier_representation(context):
|
|||||||
props = obj.BIMDoorProperties
|
props = obj.BIMDoorProperties
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
ifc_file = tool.Ifc.get()
|
ifc_file = tool.Ifc.get()
|
||||||
|
sliding_door = "SLIDING" in props.door_type
|
||||||
|
|
||||||
representation_data = {
|
representation_data = {
|
||||||
"operation_type": props.door_type,
|
"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)
|
model_representation = ifcopenshell.api.run("geometry.add_door_representation", ifc_file, **representation_data)
|
||||||
tool.Model.replace_object_ifc_representation(body, obj, model_representation)
|
tool.Model.replace_object_ifc_representation(body, obj, model_representation)
|
||||||
|
|
||||||
# PLAN_VIEW representation
|
# Body/PLAN_VIEW representation
|
||||||
plan = ifcopenshell.util.representation.get_context(ifc_file, "Plan", "Body", "PLAN_VIEW")
|
plan_body = ifcopenshell.util.representation.get_context(ifc_file, "Plan", "Body", "PLAN_VIEW")
|
||||||
if plan:
|
if plan_body:
|
||||||
representation_data["context"] = plan
|
representation_data["context"] = plan_body
|
||||||
plan_representation = ifcopenshell.api.run("geometry.add_door_representation", ifc_file, **representation_data)
|
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
|
# adding switch representation at the end instead of changing order of representations
|
||||||
# to prevent #2744
|
# to prevent #2744
|
||||||
core.switch_representation(
|
core.switch_representation(
|
||||||
|
|||||||
@@ -236,8 +236,44 @@ class Usecase:
|
|||||||
# create 2d representation
|
# create 2d representation
|
||||||
if self.settings["context"].TargetView == "PLAN_VIEW":
|
if self.settings["context"].TargetView == "PLAN_VIEW":
|
||||||
items_2d = []
|
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
|
# create lining
|
||||||
if l_shape_check([side_lining_thickness]):
|
if l_shape_check([side_lining_thickness]):
|
||||||
lining_points = [
|
lining_points = [
|
||||||
@@ -302,30 +338,7 @@ class Usecase:
|
|||||||
door_items.append(
|
door_items.append(
|
||||||
builder.rectangle(size=handle_size.zz, position=V(panel_size.x * 0.1, -handle_size.z * 0.5))
|
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))
|
builder.translate(door_items, panel_position - V(panel_size.x * 0.2, 0))
|
||||||
door_items.extend(arrow_symbol)
|
|
||||||
|
|
||||||
if door_swing_type == "RIGHT":
|
if door_swing_type == "RIGHT":
|
||||||
mirror_point = panel_position + V(panel_size.x / 2, 0)
|
mirror_point = panel_position + V(panel_size.x / 2, 0)
|
||||||
@@ -333,12 +346,6 @@ class Usecase:
|
|||||||
return door_items
|
return door_items
|
||||||
|
|
||||||
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:
|
if double_door:
|
||||||
panel_size.x = panel_size.x / 2
|
panel_size.x = panel_size.x / 2
|
||||||
door_items.extend(create_ifc_door_panel_2d(panel_size, panel_position, "LEFT", sliding_door))
|
door_items.extend(create_ifc_door_panel_2d(panel_size, panel_position, "LEFT", sliding_door))
|
||||||
|
|||||||
@@ -513,18 +513,19 @@ class ShapeBuilder:
|
|||||||
)
|
)
|
||||||
return extruded_area
|
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
|
# > items - could be a list or single curve/IfcExtrudedAreaSolid
|
||||||
# < IfcShapeRepresentation
|
# < IfcShapeRepresentation
|
||||||
if not isinstance(items, collections.abc.Iterable):
|
if not isinstance(items, collections.abc.Iterable):
|
||||||
items = [items]
|
items = [items]
|
||||||
|
|
||||||
if items[0].is_a("IfcExtrudedAreaSolid"):
|
if not representation_type:
|
||||||
representation_type = "SweptSolid"
|
if items[0].is_a("IfcExtrudedAreaSolid"):
|
||||||
elif items[0].is_a("IfcCurve") and items[0].Dim == 3:
|
representation_type = "SweptSolid"
|
||||||
representation_type = "Curve3D"
|
elif items[0].is_a("IfcCurve") and items[0].Dim == 3:
|
||||||
else:
|
representation_type = "Curve3D"
|
||||||
representation_type = "Curve2D"
|
else:
|
||||||
|
representation_type = "Curve2D"
|
||||||
|
|
||||||
representation = self.file.createIfcShapeRepresentation(
|
representation = self.file.createIfcShapeRepresentation(
|
||||||
ContextOfItems=context,
|
ContextOfItems=context,
|
||||||
|
|||||||
Reference in New Issue
Block a user