|
28 | 28 | import ifcopenshell.util.representation |
29 | 29 |
|
30 | 30 |
|
31 | | -ELBOW_RADIUS_TYPE = Literal["LONG", "SHORT"] |
32 | | - |
33 | | - |
34 | 31 | def create_elbow( |
35 | 32 | ifc4_file: ifcopenshell.file, |
36 | 33 | horizontal_curve: bim2fem.ifcplus.util.geometry.HorizontalCurve, |
@@ -59,10 +56,6 @@ def create_elbow( |
59 | 56 | products=[elbow], |
60 | 57 | relating_structure=spatial_element, |
61 | 58 | ) |
62 | | - bim2fem.ifcplus.api.placement.edit_object_placement( |
63 | | - product=elbow, |
64 | | - place_object_relative_to_parent=True, |
65 | | - ) |
66 | 59 |
|
67 | 60 | if isinstance(distribution_system, ifcopenshell.entity_instance): |
68 | 61 | ifcopenshell.api.system.assign_system( |
@@ -100,6 +93,7 @@ def create_elbow( |
100 | 93 | representation_type=cast(str, representation_type), |
101 | 94 | items=[revolved_area_solid], |
102 | 95 | ) |
| 96 | + |
103 | 97 | ifcopenshell.api.geometry.assign_representation( |
104 | 98 | file=ifc4_file, |
105 | 99 | product=elbow, |
@@ -132,65 +126,51 @@ def create_elbow( |
132 | 126 | material=material, |
133 | 127 | ) |
134 | 128 |
|
135 | | - port1_origin_in_object_coordinates = (0.0, 0.0, 0.0) |
136 | | - port1_z_axis_in_object_coordinates = (0.0, 0.0, 1.0) |
137 | | - port1_x_axis_in_object_coordinates = (1.0, 0.0, 0.0) |
138 | | - port1 = ifcopenshell.api.system.add_port(file=ifc4_file, element=elbow) |
139 | | - port1.FlowDirection = "SINK" |
140 | | - port1.PredefinedType = "PIPE" |
141 | | - if isinstance(distribution_system, ifcopenshell.entity_instance): |
142 | | - port1.SystemType = distribution_system.PredefinedType |
143 | | - bim2fem.ifcplus.api.placement.edit_object_placement( |
144 | | - product=port1, |
145 | | - place_object_relative_to_parent=False, |
146 | | - ) |
147 | | - port1.ObjectPlacement.PlacementRelTo = elbow.ObjectPlacement |
148 | | - bim2fem.ifcplus.api.placement.edit_object_placement( |
149 | | - product=port1, |
150 | | - repositioned_origin=port1_origin_in_object_coordinates, |
151 | | - repositioned_z_axis=port1_z_axis_in_object_coordinates, |
152 | | - repositioned_x_axis=port1_x_axis_in_object_coordinates, |
153 | | - place_object_relative_to_parent=True, |
| 129 | + sink_port_origin = (0.0, 0.0, 0.0) |
| 130 | + sink_port_z_axis = (0.0, 0.0, 1.0) |
| 131 | + sink_port_x_axis = (1.0, 0.0, 0.0) |
| 132 | + sink_port = bim2fem.ifcplus.api.system.create_distribution_port( |
| 133 | + ifc4_file=ifc4_file, |
| 134 | + port_origin_in_distribution_element_coordinates=sink_port_origin, |
| 135 | + port_z_axis_in_distribution_element_coordinates=sink_port_z_axis, |
| 136 | + port_x_axis_in_distribution_element_coordinates=sink_port_x_axis, |
| 137 | + distribution_element=elbow, |
| 138 | + flow_direction="SINK", |
| 139 | + predefined_type="PIPE", |
| 140 | + distribution_system=distribution_system, |
154 | 141 | ) |
155 | 142 |
|
156 | 143 | radius_of_curvature = horizontal_curve.radius_of_curvature |
157 | 144 | central_angle = horizontal_curve.central_angle |
158 | | - port2_origin_in_object_coordinates = ( |
| 145 | + source_port_origin_in_object_coordinates = ( |
159 | 146 | float(radius_of_curvature - radius_of_curvature * np.cos(central_angle)), |
160 | 147 | 0.0, |
161 | 148 | float(radius_of_curvature * np.sin(central_angle)), |
162 | 149 | ) |
163 | | - port2_z_axis_in_object_coordinates = ( |
| 150 | + source_port_z_axis_in_object_coordinates = ( |
164 | 151 | float(np.sin(horizontal_curve.central_angle)), |
165 | 152 | 0.0, |
166 | 153 | float(np.cos(horizontal_curve.central_angle)), |
167 | 154 | ) |
168 | | - port2_x_axis_in_object_coordinates = ( |
| 155 | + source_port_x_axis_in_object_coordinates = ( |
169 | 156 | float(np.cos(horizontal_curve.central_angle)), |
170 | 157 | 0.0, |
171 | 158 | float(-1 * np.sin(horizontal_curve.central_angle)), |
172 | 159 | ) |
173 | | - port2 = ifcopenshell.api.system.add_port(file=ifc4_file, element=elbow) |
174 | | - port2.FlowDirection = "SOURCE" |
175 | | - port2.PredefinedType = "PIPE" |
176 | | - if isinstance(distribution_system, ifcopenshell.entity_instance): |
177 | | - port2.SystemType = distribution_system.PredefinedType |
178 | | - bim2fem.ifcplus.api.placement.edit_object_placement( |
179 | | - product=port2, |
180 | | - place_object_relative_to_parent=False, |
181 | | - ) |
182 | | - port2.ObjectPlacement.PlacementRelTo = elbow.ObjectPlacement |
183 | | - bim2fem.ifcplus.api.placement.edit_object_placement( |
184 | | - product=port2, |
185 | | - repositioned_origin=port2_origin_in_object_coordinates, |
186 | | - repositioned_z_axis=port2_z_axis_in_object_coordinates, |
187 | | - repositioned_x_axis=port2_x_axis_in_object_coordinates, |
188 | | - place_object_relative_to_parent=True, |
| 160 | + source_port = bim2fem.ifcplus.api.system.create_distribution_port( |
| 161 | + ifc4_file=ifc4_file, |
| 162 | + port_origin_in_distribution_element_coordinates=source_port_origin_in_object_coordinates, |
| 163 | + port_z_axis_in_distribution_element_coordinates=source_port_z_axis_in_object_coordinates, |
| 164 | + port_x_axis_in_distribution_element_coordinates=source_port_x_axis_in_object_coordinates, |
| 165 | + distribution_element=elbow, |
| 166 | + flow_direction="SOURCE", |
| 167 | + predefined_type="PIPE", |
| 168 | + distribution_system=distribution_system, |
189 | 169 | ) |
190 | 170 |
|
191 | 171 | if add_shape_representation_to_ports: |
192 | 172 | bim2fem.ifcplus.api.system.add_shape_representation_to_distribution_ports( |
193 | | - ports=[port1, port2], |
| 173 | + ports=[sink_port, source_port], |
194 | 174 | arrow_size=nominal_diameter * 0.10, |
195 | 175 | ) |
196 | 176 |
|
|
0 commit comments