Add ports to MEP bends/transitions types instead of occurences

This commit is contained in:
Andrej730
2023-09-26 14:45:45 +05:00
parent ca2b804337
commit ae483f7aca
2 changed files with 10 additions and 3 deletions
@@ -586,6 +586,8 @@ class MEPGenerator:
obstruction_obj.matrix_world = segment_matrix
profile_joiner.set_depth(obstruction_obj, length)
# NOTE: we add ports to the obstruction occurence and not to the type
# since it's material profile based like segments
obstruction_port = tool.System.add_ports(
obstruction_obj,
add_start_port=not at_segment_start,
@@ -855,6 +857,7 @@ class MEPAddTransition(bpy.types.Operator, tool.Ifc.Operator):
pset=pset,
properties={"Data": json.dumps(transition_data, default=list)},
)
tool.System.add_ports(obj, offset_end_port=profile_offset_ws)
# NOTE: at this point we loose current blender objects selection
# create transition element
@@ -878,7 +881,7 @@ class MEPAddTransition(bpy.types.Operator, tool.Ifc.Operator):
transition_obj.location = start_segment_extend_point if start_port_match else end_segment_extend_point
# add ports and connect them
ports = tool.System.add_ports(transition_obj, offset_end_port=profile_offset_ws)
ports = tool.System.get_ports(tool.Ifc.get_entity(transition_obj))
if not start_port_match:
start_port, end_port = end_port, start_port
tool.Ifc.run("system.connect_port", port1=ports[0], port2=start_port, direction="NOTDEFINED")
@@ -1197,6 +1200,7 @@ class MEPAddBend(bpy.types.Operator, tool.Ifc.Operator):
pset=pset,
properties={"Data": json.dumps(bend_data, default=list)},
)
tool.System.add_ports(obj, offset_end_port=start_object_rotation @ (radial_offset * V(1, 1, 0)))
# NOTE: at this point we loose current blender objects selection
# create transition element
@@ -1240,7 +1244,7 @@ class MEPAddBend(bpy.types.Operator, tool.Ifc.Operator):
fitting_obj.matrix_world = get_fitting_matrix()
# add ports and connect them
ports = tool.System.add_ports(fitting_obj, offset_end_port=start_object_rotation @ (radial_offset * V(1, 1, 0)))
ports = tool.System.get_ports(tool.Ifc.get_entity(fitting_obj))
if not start_port_match:
start_port, end_port = end_port, start_port
tool.Ifc.run("system.connect_port", port1=ports[0], port2=start_port, direction="NOTDEFINED")
+4 -1
View File
@@ -106,7 +106,10 @@ class System(blenderbim.core.tool.System):
@classmethod
def get_port_predefined_type(cls, mep_element):
split_camel_case = lambda x: re.findall("[A-Z][^A-Z]*", x)
class_name = "".join(split_camel_case(mep_element.is_a())[1:-1]).upper()
mep_class = mep_element.is_a()
if mep_class.endswith("Type"):
mep_class = mep_class[:-4]
class_name = "".join(split_camel_case(mep_class)[1:-1]).upper()
if class_name == "CONVEYOR":
return "NOTDEFINED"
return class_name