|
12 | 12 | import ifcopenshell.util.placement |
13 | 13 | import ifcopenshell.util.representation |
14 | 14 | from bim2fem.ifcplus.api.distribution_element import ELBOW_RADIUS_TYPE |
| 15 | +import bim2fem.ifcplus.util.system |
15 | 16 |
|
16 | 17 |
|
17 | 18 | def add_shape_representation_to_distribution_ports( |
18 | 19 | ports: list[ifcopenshell.entity_instance], |
19 | 20 | arrow_size: float = 0.1, |
20 | | -): |
| 21 | +) -> None: |
21 | 22 | ifc4_file = ports[0].file |
22 | 23 |
|
23 | 24 | sink_arrow = None |
@@ -71,7 +72,8 @@ def add_shape_representation_to_distribution_ports( |
71 | 72 | representation_type = ifcopenshell.util.representation.guess_type( |
72 | 73 | items=[csg_solid] |
73 | 74 | ) |
74 | | - assert isinstance(representation_type, str) |
| 75 | + if representation_type is None: |
| 76 | + return None |
75 | 77 |
|
76 | 78 | shape_model = bim2fem.ifcplus.api.geometry.add_shape_model( |
77 | 79 | ifc4_file=ifc4_file, |
@@ -104,7 +106,8 @@ def remove_items_by_indices(lst: list, indices: list) -> list: |
104 | 106 | # Use list comprehension to create a new list without the specified indices |
105 | 107 | return [item for idx, item in enumerate(lst) if idx not in indices_set] |
106 | 108 |
|
107 | | - assert len(polyline) >= 3 |
| 109 | + if len(polyline) < 3: |
| 110 | + return polyline |
108 | 111 |
|
109 | 112 | indices_of_points_to_remove = [] |
110 | 113 |
|
@@ -158,7 +161,8 @@ def create_piping_system_from_polyline( |
158 | 161 |
|
159 | 162 | ifc4_file = material.file |
160 | 163 |
|
161 | | - assert len(polyline) >= 2 |
| 164 | + if len(polyline) < 2: |
| 165 | + return [] |
162 | 166 |
|
163 | 167 | if len(polyline) == 2: |
164 | 168 | pipe_segment = bim2fem.ifcplus.api.distribution_element.create_pipe_segment( |
@@ -208,9 +212,9 @@ def create_piping_system_from_polyline( |
208 | 212 |
|
209 | 213 | horizontal_curve = ( |
210 | 214 | 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], |
214 | 218 | radius_of_curvature=radius_of_curvature, |
215 | 219 | ) |
216 | 220 | ) |
@@ -293,38 +297,19 @@ def connect_two_distribution_ports_via_piping_with_no_intelligence( |
293 | 297 | """Connect two IfcDistributionPorts using a single path pipe branch formed via no |
294 | 298 | intelligent method.""" |
295 | 299 |
|
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, |
306 | 302 | ) |
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 |
312 | 305 | ) |
313 | 306 |
|
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, |
318 | 309 | ) |
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 |
321 | 312 | ) |
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 |
328 | 313 |
|
329 | 314 | outer_diameter_of_piping = nominal_diameter + thickness |
330 | 315 |
|
|
0 commit comments