Skip to content

Commit 43fbb17

Browse files
committed
updated elbows and HorizontalCurve
1 parent 8ef4d04 commit 43fbb17

File tree

5 files changed

+373
-169
lines changed

5 files changed

+373
-169
lines changed

src/bim2fem/ifcplus/api/distribution_element.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,18 @@
2626
import numpy as np
2727
import bim2fem.ifcplus.api.system
2828
import ifcopenshell.util.representation
29+
import bim2fem.ifcplus.api.material
2930

3031

3132
ELBOW_RADIUS_TYPE = Literal["LONG", "SHORT"]
3233

3334

3435
def create_elbow(
36+
ifc4_file: ifcopenshell.file,
3537
horizontal_curve: bim2fem.ifcplus.util.geometry.HorizontalCurve,
3638
nominal_diameter: float,
3739
thickness: float,
38-
material: ifcopenshell.entity_instance,
40+
material: ifcopenshell.entity_instance | None = None,
3941
elbow: ifcopenshell.entity_instance | None = None,
4042
name: str | None = None,
4143
spatial_element: ifcopenshell.entity_instance | None = None,
@@ -44,8 +46,6 @@ def create_elbow(
4446
add_shape_representation_to_ports: bool = False,
4547
) -> ifcopenshell.entity_instance:
4648

47-
ifc4_file = material.file
48-
4949
if elbow is None:
5050
elbow = ifcopenshell.api.root.create_entity(
5151
file=ifc4_file,
@@ -128,6 +128,18 @@ def create_elbow(
128128
place_object_relative_to_parent=place_object_relative_to_parent,
129129
)
130130

131+
if material is None:
132+
material = bim2fem.ifcplus.api.material.add_material_with_structural_properties(
133+
ifc4_file=ifc4_file,
134+
name="Galvanized Steel",
135+
category="steel",
136+
mass_density=7850.0,
137+
young_modulus=200.0e9,
138+
poisson_ratio=0.3,
139+
thermal_expansion_coefficient=1.2e-6,
140+
check_for_duplicate=True,
141+
)
142+
131143
ifcopenshell.api.material.assign_material(
132144
file=ifc4_file,
133145
products=[elbow],

src/bim2fem/ifcplus/api/system.py

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
import ifcopenshell.util.placement
1313
import ifcopenshell.util.representation
1414
from bim2fem.ifcplus.api.distribution_element import ELBOW_RADIUS_TYPE
15+
import bim2fem.ifcplus.util.system
1516

1617

1718
def add_shape_representation_to_distribution_ports(
1819
ports: list[ifcopenshell.entity_instance],
1920
arrow_size: float = 0.1,
20-
):
21+
) -> None:
2122
ifc4_file = ports[0].file
2223

2324
sink_arrow = None
@@ -71,7 +72,8 @@ def add_shape_representation_to_distribution_ports(
7172
representation_type = ifcopenshell.util.representation.guess_type(
7273
items=[csg_solid]
7374
)
74-
assert isinstance(representation_type, str)
75+
if representation_type is None:
76+
return None
7577

7678
shape_model = bim2fem.ifcplus.api.geometry.add_shape_model(
7779
ifc4_file=ifc4_file,
@@ -104,7 +106,8 @@ def remove_items_by_indices(lst: list, indices: list) -> list:
104106
# Use list comprehension to create a new list without the specified indices
105107
return [item for idx, item in enumerate(lst) if idx not in indices_set]
106108

107-
assert len(polyline) >= 3
109+
if len(polyline) < 3:
110+
return polyline
108111

109112
indices_of_points_to_remove = []
110113

@@ -158,7 +161,8 @@ def create_piping_system_from_polyline(
158161

159162
ifc4_file = material.file
160163

161-
assert len(polyline) >= 2
164+
if len(polyline) < 2:
165+
return []
162166

163167
if len(polyline) == 2:
164168
pipe_segment = bim2fem.ifcplus.api.distribution_element.create_pipe_segment(
@@ -208,9 +212,9 @@ def create_piping_system_from_polyline(
208212

209213
horizontal_curve = (
210214
bim2fem.ifcplus.util.geometry.HorizontalCurve.from_3pt_polyline(
211-
p1=polyline[index],
212-
p2=polyline[index + 1],
213-
p3=polyline[index + 2],
215+
first_point=polyline[index],
216+
second_point=polyline[index + 1],
217+
third_point=polyline[index + 2],
214218
radius_of_curvature=radius_of_curvature,
215219
)
216220
)
@@ -293,38 +297,19 @@ def connect_two_distribution_ports_via_piping_with_no_intelligence(
293297
"""Connect two IfcDistributionPorts using a single path pipe branch formed via no
294298
intelligent method."""
295299

296-
source_port_local_placement_in_global_coordinates = (
297-
ifcopenshell.util.placement.get_local_placement(
298-
placement=source_port.ObjectPlacement
299-
)
300-
)
301-
source_port_origin = tuple(
302-
[
303-
float(row[3])
304-
for row in source_port_local_placement_in_global_coordinates[0:-1]
305-
]
300+
source_port_origin = bim2fem.ifcplus.util.system.get_port_location(
301+
distribution_port=source_port,
306302
)
307-
source_port_z_axis = tuple(
308-
[
309-
float(row[2])
310-
for row in source_port_local_placement_in_global_coordinates[0:-1]
311-
]
303+
source_port_z_axis = bim2fem.ifcplus.util.system.get_port_z_axis(
304+
distribution_port=source_port
312305
)
313306

314-
sink_port_local_placement_in_global_coordinates = (
315-
ifcopenshell.util.placement.get_local_placement(
316-
placement=sink_port.ObjectPlacement
317-
)
307+
sink_port_origin = bim2fem.ifcplus.util.system.get_port_location(
308+
distribution_port=sink_port,
318309
)
319-
sink_port_origin = tuple(
320-
[float(row[3]) for row in sink_port_local_placement_in_global_coordinates[0:-1]]
310+
sink_port_z_axis = bim2fem.ifcplus.util.system.get_port_z_axis(
311+
distribution_port=sink_port
321312
)
322-
sink_port_z_axis = tuple(
323-
[float(row[2]) for row in sink_port_local_placement_in_global_coordinates[0:-1]]
324-
)
325-
326-
assert len(source_port_origin) == 3
327-
assert len(sink_port_origin) == 3
328313

329314
outer_diameter_of_piping = nominal_diameter + thickness
330315

0 commit comments

Comments
 (0)