Fix #4052. Bug where invalid plane was generated due to missing X axis.

This commit is contained in:
Dion Moult
2023-11-28 11:52:56 +11:00
parent 6e932ec2fb
commit 3e268be5c7
2 changed files with 21 additions and 13 deletions
@@ -171,6 +171,19 @@ class ShapeBuilder:
# self.file_file.createIfcAxis2Placement2D(tool.Ifc.get().createIfcCartesianPoint(center[0:2]))
return ifc_curve
def plane(
self, location: Vector = Vector((0.0, 0.0, 0.0)).freeze(), normal: Vector = Vector((0.0, 0.0, 1.0)).freeze()
):
location = self.file.createIfcCartesianPoint(location)
direction = self.file.createIfcDirection(normal)
if normal.to_tuple(2) == Vector((0.0, 0.0, 1.0)):
arbitrary_vector = Vector((0.0, 1.0, 0.0))
else:
arbitrary_vector = Vector((0.0, 0.0, 1.0))
x_axis = self.file.createIfcDirection(normal.cross(arbitrary_vector).normalized())
axis_placement = self.file.createIfcAxis2Placement3D(location, direction, x_axis)
return self.file.createIfcPlane(axis_placement)
# TODO: explain points order for the curve_between_two_points
# because the order is important and defines the center of the curve
# currently it seems like the first point shifted by x-axis defines the center
@@ -846,9 +859,9 @@ class ShapeBuilder:
# )
points, segments, ifc_curve = self.get_simple_2dcurve_data(
coords,
fillets = (0, 1, 4, 5, 6, 7, 10, 11),
fillet_radius=(r+t, r+t, r, r, r+t, r+t, r, r),
coords,
fillets = (0, 1, 4, 5, 6, 7, 10, 11),
fillet_radius=(r+t, r+t, r, r, r+t, r+t, r, r),
closed=True, create_ifc_curve=True)
# fmt: on