mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 22:50:21 +00:00
Wall representations now distinguish between auto and manual booleans and manual booleans move with the wall
This commit is contained in:
@@ -365,7 +365,7 @@ class HideBooleans(Operator, tool.Ifc.Operator):
|
|||||||
props = bpy.context.scene.BIMModelProperties
|
props = bpy.context.scene.BIMModelProperties
|
||||||
for opening in props.openings:
|
for opening in props.openings:
|
||||||
obj = opening.obj
|
obj = opening.obj
|
||||||
if obj.data.BIMMeshProperties.ifc_boolean_id:
|
if obj and obj.data.BIMMeshProperties.ifc_boolean_id:
|
||||||
bpy.data.objects.remove(obj)
|
bpy.data.objects.remove(obj)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|||||||
@@ -961,9 +961,14 @@ class DumbWallJoiner:
|
|||||||
)
|
)
|
||||||
|
|
||||||
new_matrix = copy.deepcopy(obj.matrix_world)
|
new_matrix = copy.deepcopy(obj.matrix_world)
|
||||||
new_matrix.col[3] = self.body[0].to_4d()
|
new_matrix.col[3] = self.body[0].to_4d().copy()
|
||||||
new_matrix.invert()
|
new_matrix.invert()
|
||||||
self.clippings = [new_matrix @ c for c in self.clippings]
|
|
||||||
|
for clipping in self.clippings:
|
||||||
|
if clipping["operand_type"] == "IfcHalfSpaceSolid":
|
||||||
|
clipping["matrix"] = new_matrix @ clipping["matrix"]
|
||||||
|
|
||||||
|
self.get_manual_clippings(element, new_matrix)
|
||||||
|
|
||||||
length = (self.body[1] - self.body[0]).length
|
length = (self.body[1] - self.body[0]).length
|
||||||
|
|
||||||
@@ -1022,6 +1027,28 @@ class DumbWallJoiner:
|
|||||||
)
|
)
|
||||||
tool.Geometry.record_object_materials(obj)
|
tool.Geometry.record_object_materials(obj)
|
||||||
|
|
||||||
|
def get_manual_clippings(self, element, new_matrix):
|
||||||
|
body = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
|
||||||
|
if not body:
|
||||||
|
return
|
||||||
|
clippings = []
|
||||||
|
items = list(body.Items)
|
||||||
|
while items:
|
||||||
|
item = items.pop()
|
||||||
|
if item.is_a() == "IfcBooleanResult":
|
||||||
|
clippings.append(item.SecondOperand)
|
||||||
|
items.append(item.FirstOperand)
|
||||||
|
elif item.is_a("IfcBooleanClippingResult"):
|
||||||
|
items.append(item.FirstOperand)
|
||||||
|
for clipping in clippings:
|
||||||
|
if clipping.is_a("IfcHalfSpaceSolid") and clipping.BaseSurface.is_a("IfcPlane"):
|
||||||
|
placement = Matrix(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement).tolist())
|
||||||
|
position = clipping.BaseSurface.Position
|
||||||
|
position = Matrix(ifcopenshell.util.placement.get_axis2placement(position).tolist())
|
||||||
|
self.clippings.append(
|
||||||
|
{"type": "IfcBooleanResult", "operand_type": "IfcHalfSpaceSolid", "matrix": position}
|
||||||
|
)
|
||||||
|
|
||||||
def create_matrix(self, p, x, y, z):
|
def create_matrix(self, p, x, y, z):
|
||||||
return Matrix(
|
return Matrix(
|
||||||
(
|
(
|
||||||
@@ -1133,7 +1160,13 @@ class DumbWallJoiner:
|
|||||||
y_axis = Vector((0, 0, -1))
|
y_axis = Vector((0, 0, -1))
|
||||||
x_axis = (clip1 - clip2).normalized().to_3d()
|
x_axis = (clip1 - clip2).normalized().to_3d()
|
||||||
z_axis = x_axis.cross(y_axis)
|
z_axis = x_axis.cross(y_axis)
|
||||||
self.clippings.append(self.create_matrix(clip1.to_3d(), x_axis, y_axis, z_axis))
|
self.clippings.append(
|
||||||
|
{
|
||||||
|
"type": "IfcBooleanClippingResult",
|
||||||
|
"operand_type": "IfcHalfSpaceSolid",
|
||||||
|
"matrix": self.create_matrix(clip1.to_3d(), x_axis, y_axis, z_axis),
|
||||||
|
}
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
base_target = tool.Cad.furthest_vector(axis1["base"][1], (intersect1, intersect2))
|
base_target = tool.Cad.furthest_vector(axis1["base"][1], (intersect1, intersect2))
|
||||||
if tool.Cad.is_x(abs(angle), (90, 270), tolerance=0.001):
|
if tool.Cad.is_x(abs(angle), (90, 270), tolerance=0.001):
|
||||||
@@ -1166,7 +1199,13 @@ class DumbWallJoiner:
|
|||||||
y_axis = Vector((0, 0, 1))
|
y_axis = Vector((0, 0, 1))
|
||||||
x_axis = (clip1 - clip2).normalized().to_3d()
|
x_axis = (clip1 - clip2).normalized().to_3d()
|
||||||
z_axis = x_axis.cross(y_axis)
|
z_axis = x_axis.cross(y_axis)
|
||||||
self.clippings.append(self.create_matrix(clip1.to_3d(), x_axis, y_axis, z_axis))
|
self.clippings.append(
|
||||||
|
{
|
||||||
|
"type": "IfcBooleanClippingResult",
|
||||||
|
"operand_type": "IfcHalfSpaceSolid",
|
||||||
|
"matrix": self.create_matrix(clip1.to_3d(), x_axis, y_axis, z_axis),
|
||||||
|
}
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
# This is the standard L and T joints described by IFC
|
# This is the standard L and T joints described by IFC
|
||||||
if connection1 == "ATEND":
|
if connection1 == "ATEND":
|
||||||
@@ -1189,14 +1228,26 @@ class DumbWallJoiner:
|
|||||||
x_axis = (side_target - base_target).normalized().to_3d()
|
x_axis = (side_target - base_target).normalized().to_3d()
|
||||||
y_axis = Vector((0, 0, 1))
|
y_axis = Vector((0, 0, 1))
|
||||||
z_axis = x_axis.cross(y_axis)
|
z_axis = x_axis.cross(y_axis)
|
||||||
self.clippings.append(self.create_matrix(clip, x_axis, y_axis, z_axis))
|
self.clippings.append(
|
||||||
|
{
|
||||||
|
"type": "IfcBooleanClippingResult",
|
||||||
|
"operand_type": "IfcHalfSpaceSolid",
|
||||||
|
"matrix": self.create_matrix(clip, x_axis, y_axis, z_axis),
|
||||||
|
}
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
self.body[1] = tool.Cad.point_on_edge(side_target, axis1["reference"])
|
self.body[1] = tool.Cad.point_on_edge(side_target, axis1["reference"])
|
||||||
clip = base_target.to_3d()
|
clip = base_target.to_3d()
|
||||||
x_axis = (side_target - base_target).normalized().to_3d()
|
x_axis = (side_target - base_target).normalized().to_3d()
|
||||||
y_axis = Vector((0, 0, 1))
|
y_axis = Vector((0, 0, 1))
|
||||||
z_axis = x_axis.cross(y_axis)
|
z_axis = x_axis.cross(y_axis)
|
||||||
self.clippings.append(self.create_matrix(clip, x_axis, y_axis, z_axis))
|
self.clippings.append(
|
||||||
|
{
|
||||||
|
"type": "IfcBooleanClippingResult",
|
||||||
|
"operand_type": "IfcHalfSpaceSolid",
|
||||||
|
"matrix": self.create_matrix(clip, x_axis, y_axis, z_axis),
|
||||||
|
}
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
if is_relating:
|
if is_relating:
|
||||||
base_target = tool.Cad.furthest_vector(axis1["base"][1], (intersect1, intersect2))
|
base_target = tool.Cad.furthest_vector(axis1["base"][1], (intersect1, intersect2))
|
||||||
@@ -1217,14 +1268,26 @@ class DumbWallJoiner:
|
|||||||
x_axis = (side_target - base_target).normalized().to_3d()
|
x_axis = (side_target - base_target).normalized().to_3d()
|
||||||
y_axis = Vector((0, 0, 1))
|
y_axis = Vector((0, 0, 1))
|
||||||
z_axis = y_axis.cross(x_axis)
|
z_axis = y_axis.cross(x_axis)
|
||||||
self.clippings.append(self.create_matrix(clip, x_axis, y_axis, z_axis))
|
self.clippings.append(
|
||||||
|
{
|
||||||
|
"type": "IfcBooleanClippingResult",
|
||||||
|
"operand_type": "IfcHalfSpaceSolid",
|
||||||
|
"matrix": self.create_matrix(clip, x_axis, y_axis, z_axis),
|
||||||
|
}
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
self.body[0] = tool.Cad.point_on_edge(side_target, axis1["reference"])
|
self.body[0] = tool.Cad.point_on_edge(side_target, axis1["reference"])
|
||||||
clip = base_target.to_3d()
|
clip = base_target.to_3d()
|
||||||
x_axis = (side_target - base_target).normalized().to_3d()
|
x_axis = (side_target - base_target).normalized().to_3d()
|
||||||
y_axis = Vector((0, 0, 1))
|
y_axis = Vector((0, 0, 1))
|
||||||
z_axis = y_axis.cross(x_axis)
|
z_axis = y_axis.cross(x_axis)
|
||||||
self.clippings.append(self.create_matrix(clip, x_axis, y_axis, z_axis))
|
self.clippings.append(
|
||||||
|
{
|
||||||
|
"type": "IfcBooleanClippingResult",
|
||||||
|
"operand_type": "IfcHalfSpaceSolid",
|
||||||
|
"matrix": self.create_matrix(clip, x_axis, y_axis, z_axis),
|
||||||
|
}
|
||||||
|
)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ class Usecase:
|
|||||||
"offset": 0.0,
|
"offset": 0.0,
|
||||||
"thickness": 0.2,
|
"thickness": 0.2,
|
||||||
# Planes are defined as a matrix. The XY plane is the clipping boundary and +Z is removed.
|
# Planes are defined as a matrix. The XY plane is the clipping boundary and +Z is removed.
|
||||||
|
# [{"type": "IfcBooleanClippingResult", "operand_type": "IfcHalfSpaceSolid", "matrix": [...]}, {...}]
|
||||||
"clippings": [], # A list of planes that define clipping half space solids
|
"clippings": [], # A list of planes that define clipping half space solids
|
||||||
}
|
}
|
||||||
for key, value in settings.items():
|
for key, value in settings.items():
|
||||||
@@ -74,23 +75,25 @@ class Usecase:
|
|||||||
def apply_clippings(self, first_operand):
|
def apply_clippings(self, first_operand):
|
||||||
while self.settings["clippings"]:
|
while self.settings["clippings"]:
|
||||||
clipping = self.settings["clippings"].pop()
|
clipping = self.settings["clippings"].pop()
|
||||||
second_operand = self.file.createIfcHalfSpaceSolid(
|
if clipping["operand_type"] == "IfcHalfSpaceSolid":
|
||||||
self.file.createIfcPlane(
|
matrix = clipping["matrix"]
|
||||||
self.file.createIfcAxis2Placement3D(
|
second_operand = self.file.createIfcHalfSpaceSolid(
|
||||||
self.file.createIfcCartesianPoint(
|
self.file.createIfcPlane(
|
||||||
(
|
self.file.createIfcAxis2Placement3D(
|
||||||
self.convert_si_to_unit(clipping[0][3]),
|
self.file.createIfcCartesianPoint(
|
||||||
self.convert_si_to_unit(clipping[1][3]),
|
(
|
||||||
self.convert_si_to_unit(clipping[2][3]),
|
self.convert_si_to_unit(matrix[0][3]),
|
||||||
)
|
self.convert_si_to_unit(matrix[1][3]),
|
||||||
),
|
self.convert_si_to_unit(matrix[2][3]),
|
||||||
self.file.createIfcDirection((clipping[0][2], clipping[1][2], clipping[2][2])),
|
)
|
||||||
self.file.createIfcDirection((clipping[0][0], clipping[1][0], clipping[2][0])),
|
),
|
||||||
)
|
self.file.createIfcDirection((matrix[0][2], matrix[1][2], matrix[2][2])),
|
||||||
),
|
self.file.createIfcDirection((matrix[0][0], matrix[1][0], matrix[2][0])),
|
||||||
False,
|
)
|
||||||
)
|
),
|
||||||
first_operand = self.file.createIfcBooleanClippingResult("DIFFERENCE", first_operand, second_operand)
|
False,
|
||||||
|
)
|
||||||
|
first_operand = self.file.create_entity(clipping["type"], "DIFFERENCE", first_operand, second_operand)
|
||||||
return first_operand
|
return first_operand
|
||||||
|
|
||||||
def convert_si_to_unit(self, co):
|
def convert_si_to_unit(self, co):
|
||||||
|
|||||||
Reference in New Issue
Block a user