mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 17:57:02 +00:00
fix the errors occured trying to find compatible fitting type
1) It would stop if the first occurence would be connected to a segment without type 2) It would raise an error if one of the fitting's ports was not connected.
This commit is contained in:
@@ -416,25 +416,35 @@ class MEPGenerator:
|
|||||||
fittings = tool.Ifc.get_all_element_occurrences(fitting_type)
|
fittings = tool.Ifc.get_all_element_occurrences(fitting_type)
|
||||||
if not fittings:
|
if not fittings:
|
||||||
continue
|
continue
|
||||||
fitting = fittings[0]
|
|
||||||
|
|
||||||
ports = ifcopenshell.util.system.get_ports(fitting)
|
for fitting in fittings:
|
||||||
fitting_data = []
|
ports = ifcopenshell.util.system.get_ports(fitting)
|
||||||
fitting_connected_to_none_type = False
|
fitting_data = []
|
||||||
for port in ports:
|
skipped_the_occurrence = False
|
||||||
connected_port = tool.System.get_connected_port(port)
|
for port in ports:
|
||||||
connected_element = tool.System.get_port_relating_element(connected_port)
|
connected_port = tool.System.get_connected_port(port)
|
||||||
element_type = ifcopenshell.util.element.get_type(connected_element)
|
|
||||||
if element_type is None:
|
|
||||||
fitting_connected_to_none_type = True
|
|
||||||
break
|
|
||||||
fitting_data.append((element_type, port.PredefinedType, port.SystemType))
|
|
||||||
|
|
||||||
if fitting_connected_to_none_type:
|
# fitting port is not connected to anything
|
||||||
continue
|
if not connected_port:
|
||||||
|
skipped_the_occurrence = True
|
||||||
|
break
|
||||||
|
|
||||||
if are_connected_elements_compatible(segments_data, fitting_data):
|
connected_element = tool.System.get_port_relating_element(connected_port)
|
||||||
return pack_return_data(fitting_type, ports, segments_data)
|
element_type = ifcopenshell.util.element.get_type(connected_element)
|
||||||
|
|
||||||
|
# fitting is connected to none type
|
||||||
|
if element_type is None:
|
||||||
|
skipped_the_occurrence = True
|
||||||
|
break
|
||||||
|
|
||||||
|
fitting_data.append((element_type, port.PredefinedType, port.SystemType))
|
||||||
|
|
||||||
|
# if we skipped the occurrence we still can other occurrences
|
||||||
|
# otherwise checking 1 occurrence is enough
|
||||||
|
if not skipped_the_occurrence:
|
||||||
|
if are_connected_elements_compatible(segments_data, fitting_data):
|
||||||
|
return pack_return_data(fitting_type, ports, segments_data)
|
||||||
|
return
|
||||||
|
|
||||||
def create_obstruction_type(self, segment):
|
def create_obstruction_type(self, segment):
|
||||||
# code is very similar to "bim.add_type"
|
# code is very similar to "bim.add_type"
|
||||||
|
|||||||
Reference in New Issue
Block a user