mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
Fix bug in cut decorator layersets where walls could be joined to odd non-layered things.
This commit is contained in:
@@ -2008,7 +2008,7 @@ class CutDecorator:
|
|||||||
|
|
||||||
imat = obj.matrix_world.inverted()
|
imat = obj.matrix_world.inverted()
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
if "LAYER" not in (tool.Model.get_usage_type(element) or ""):
|
if tool.Model.get_usage_type(element) != "LAYER2":
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
layers = self.get_layer_data(element)
|
layers = self.get_layer_data(element)
|
||||||
@@ -2191,22 +2191,30 @@ class CutDecorator:
|
|||||||
def get_connections(self, wall, obj, centerline, min_edge, max_edge):
|
def get_connections(self, wall, obj, centerline, min_edge, max_edge):
|
||||||
connections = {"ATEND": None, "ATSTART": None, "ATPATH": [], "MINPATH": [], "MAXPATH": []}
|
connections = {"ATEND": None, "ATSTART": None, "ATPATH": [], "MINPATH": [], "MAXPATH": []}
|
||||||
for rel in wall.ConnectedTo:
|
for rel in wall.ConnectedTo:
|
||||||
|
# How do you join to a non layered element? Not sure.
|
||||||
|
if tool.Model.get_usage_type(rel.RelatedElement) != "LAYER2":
|
||||||
|
continue
|
||||||
if rel.RelatingConnectionType == "ATPATH":
|
if rel.RelatingConnectionType == "ATPATH":
|
||||||
connections["ATPATH"].append(
|
metadata = self.get_connection_metadata(obj, rel.RelatedElement, centerline, min_edge, max_edge)
|
||||||
self.get_connection_metadata(obj, rel.RelatedElement, centerline, min_edge, max_edge)
|
if not metadata:
|
||||||
)
|
continue
|
||||||
|
connections["ATPATH"].append(metadata)
|
||||||
else:
|
else:
|
||||||
connections[rel.RelatingConnectionType] = self.get_connection_metadata(
|
metadata = self.get_connection_metadata(obj, rel.RelatedElement, centerline, min_edge, max_edge)
|
||||||
obj, rel.RelatedElement, centerline, min_edge, max_edge
|
if not metadata:
|
||||||
)
|
continue
|
||||||
|
connections[rel.RelatingConnectionType] = metadata
|
||||||
for rel in wall.ConnectedFrom:
|
for rel in wall.ConnectedFrom:
|
||||||
|
if tool.Model.get_usage_type(rel.RelatingElement) != "LAYER2":
|
||||||
|
continue
|
||||||
# We only consider ATPATH since in this situation, we have the
|
# We only consider ATPATH since in this situation, we have the
|
||||||
# priority. The non-priority wall never has any layers that need to
|
# priority. The non-priority wall never has any layers that need to
|
||||||
# "turn a corner".
|
# "turn a corner".
|
||||||
if rel.RelatedConnectionType == "ATPATH":
|
if rel.RelatedConnectionType == "ATPATH":
|
||||||
connections["ATPATH"].append(
|
metadata = self.get_connection_metadata(obj, rel.RelatingElement, centerline, min_edge, max_edge)
|
||||||
self.get_connection_metadata(obj, rel.RelatingElement, centerline, min_edge, max_edge)
|
if not metadata:
|
||||||
)
|
continue
|
||||||
|
connections["ATPATH"].append(metadata)
|
||||||
connections["ATPATH"] = sorted(connections["ATPATH"], key=lambda c: c["intersection"].x)
|
connections["ATPATH"] = sorted(connections["ATPATH"], key=lambda c: c["intersection"].x)
|
||||||
for connection in connections["ATPATH"]:
|
for connection in connections["ATPATH"]:
|
||||||
if connection["angle"] > 0:
|
if connection["angle"] > 0:
|
||||||
@@ -2227,7 +2235,11 @@ class CutDecorator:
|
|||||||
]
|
]
|
||||||
rel_centerline = [obj.matrix_world.inverted() @ rel_obj.matrix_world @ v.to_3d() for v in rel_centerline]
|
rel_centerline = [obj.matrix_world.inverted() @ rel_obj.matrix_world @ v.to_3d() for v in rel_centerline]
|
||||||
rel_centerline = [v.to_2d() for v in rel_centerline]
|
rel_centerline = [v.to_2d() for v in rel_centerline]
|
||||||
intersection, _ = tool.Cad.intersect_edges(centerline, rel_centerline)
|
intersection = tool.Cad.intersect_edges(centerline, rel_centerline)
|
||||||
|
if intersection:
|
||||||
|
intersection, _ = intersection
|
||||||
|
else:
|
||||||
|
return
|
||||||
closest_centerline_point = tool.Cad.closest_vector(intersection, tuple(rel_centerline))
|
closest_centerline_point = tool.Cad.closest_vector(intersection, tuple(rel_centerline))
|
||||||
if closest_centerline_point == rel_centerline[1]:
|
if closest_centerline_point == rel_centerline[1]:
|
||||||
rel_centerline = [rel_centerline[1], rel_centerline[0]]
|
rel_centerline = [rel_centerline[1], rel_centerline[0]]
|
||||||
|
|||||||
Reference in New Issue
Block a user