diff --git a/CHANGELOG.md b/CHANGELOG.md index b83e297bd..6ddf31405 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Changed `CategoryJointRule` and `DirectJointRule` to a dynamic interface where joint type is selected with right click menu * Changed `Assembly` GH component to apply category joints if the detected topology is in `CategoryRule.topos` * Changed `TopologyJoints` GH component to `DefaultJoints` Component, which applies default joints based on topology. +* Changed `Beam.faces` to match position and orientation of BTLx `ReferenceSide` ### Removed diff --git a/src/compas_timber/connections/butt_joint.py b/src/compas_timber/connections/butt_joint.py index 71b94f8f7..4a0b66ac4 100644 --- a/src/compas_timber/connections/butt_joint.py +++ b/src/compas_timber/connections/butt_joint.py @@ -111,7 +111,7 @@ def subtraction_volume(self): dir_pts = [] vertices = [] sides = self.side_surfaces_cross() - for i, side in enumerate(sides): + for side in sides: points = [] top_frame, bottom_frame = self.get_main_cutting_plane() for frame in [top_frame, bottom_frame]: diff --git a/src/compas_timber/fabrication/btlx.py b/src/compas_timber/fabrication/btlx.py index 76ad9e695..2e0f8912b 100644 --- a/src/compas_timber/fabrication/btlx.py +++ b/src/compas_timber/fabrication/btlx.py @@ -158,76 +158,13 @@ def __init__(self, beam): self.beam = beam self.key = beam.key self.length = beam.length - self.width = beam.height - self.height = beam.width - self.frame = Frame( - self.beam.long_edges[2].closest_point(self.beam.blank_frame.point), - beam.frame.xaxis, - beam.frame.yaxis, - ) # I used long_edge[2] because it is in Y and Z negative. Using that as reference puts the beam entirely in positive coordinates. + self.width = beam.width + self.height = beam.height + self.frame = beam.part_ref self.blank_length = beam.blank_length - self._reference_surfaces = [] self.processings = [] self._et_element = None - - def reference_surface_from_beam_face(self, beam_face): - """Finds the reference surface with normal that matches the normal of the beam face argument - - Parameters - ----------- - beam_face : :class:`~compas.geometry.Frame` - The frame of a beam face from beam.faces. - - Returns - -------- - key : str - The key(index 1-6) of the reference surface. - - """ - for key, face in self.reference_surfaces.items(): - if face.normal == beam_face.normal: - return key - - def reference_surface_planes(self, index): - """Returns the reference surface planes for a given index per BTLx docs. - - Parameters - ---------- - index : int - The index of the reference surface. - - Returns - ------- - dict - The BTLx reference surface frame. - - """ - if len(self._reference_surfaces) != 6: - self._reference_surfaces = { - "1": Frame(self.frame.point, self.frame.xaxis, self.frame.zaxis), - "2": Frame( - self.frame.point + self.frame.yaxis * self.width, - self.frame.xaxis, - -self.frame.yaxis, - ), - "3": Frame( - self.frame.point + self.frame.yaxis * self.width + self.frame.zaxis * self.height, - self.frame.xaxis, - -self.frame.zaxis, - ), - "4": Frame( - self.frame.point + self.frame.zaxis * self.height, - self.frame.xaxis, - self.frame.yaxis, - ), - "5": Frame(self.frame.point, self.frame.zaxis, self.frame.yaxis), - "6": Frame( - self.frame.point + self.frame.xaxis * self.blank_length + self.frame.yaxis * self.width, - self.frame.zaxis, - -self.frame.yaxis, - ), - } - return self._reference_surfaces[str(index)] + self.faces = beam.faces @property def attr(self): diff --git a/src/compas_timber/fabrication/btlx_processes/btlx_french_ridge_lap.py b/src/compas_timber/fabrication/btlx_processes/btlx_french_ridge_lap.py index e274649bc..d22ae6fb7 100644 --- a/src/compas_timber/fabrication/btlx_processes/btlx_french_ridge_lap.py +++ b/src/compas_timber/fabrication/btlx_processes/btlx_french_ridge_lap.py @@ -66,7 +66,7 @@ def __init__(self, part, joint, is_top): self.drill_hole_diameter = 10.0 self.ref_face_index = self.joint.reference_face_indices[str(self.beam.key)] - self.ref_face = self.part.reference_surfaces[str(self.ref_face_index)] + self.ref_face = self.part.faces[self.ref_face_index] """ the following attributes are required for all processes, but the keys and values of header_attributes are process specific. diff --git a/src/compas_timber/fabrication/btlx_processes/btlx_jack_cut.py b/src/compas_timber/fabrication/btlx_processes/btlx_jack_cut.py index 8d47b2a58..fb328b715 100644 --- a/src/compas_timber/fabrication/btlx_processes/btlx_jack_cut.py +++ b/src/compas_timber/fabrication/btlx_processes/btlx_jack_cut.py @@ -32,7 +32,7 @@ def __init__(self, part, frame, joint_name=None): self.cut_plane = frame self.part = part self.apply_process = True - self.reference_surface = self.part.reference_surface_planes(1) + self.reference_side = self.part.faces[0] self.generate_process() if joint_name: self.name = joint_name @@ -75,25 +75,23 @@ def generate_process(self): self.startY = 0.0 self.start_depth = 0.0 - self.x_edge = Line.from_point_and_vector(self.reference_surface.point, self.reference_surface.xaxis) + self.x_edge = Line.from_point_and_vector(self.reference_side.point, self.reference_side.xaxis) self.startX = intersection_line_plane(self.x_edge, Plane.from_frame(self.cut_plane))[1] * self.x_edge.length if self.startX < self.part.blank_length / 2: self.orientation = "start" else: self.orientation = "end" - angle_direction = cross_vectors(self.reference_surface.normal, self.cut_plane.normal) + angle_direction = cross_vectors(self.reference_side.normal, self.cut_plane.normal) self.angle = ( - angle_vectors_signed(self.reference_surface.xaxis, angle_direction, self.reference_surface.zaxis) - * 180 - / math.pi + angle_vectors_signed(self.reference_side.xaxis, angle_direction, self.reference_side.zaxis) * 180 / math.pi ) self.angle = abs(self.angle) self.angle = 90 - (self.angle - 90) self.inclination = ( - angle_vectors_signed(self.reference_surface.zaxis, self.cut_plane.normal, angle_direction) * 180 / math.pi + angle_vectors_signed(self.reference_side.zaxis, self.cut_plane.normal, angle_direction) * 180 / math.pi ) self.inclination = abs(self.inclination) self.inclination = 90 - (self.inclination - 90) diff --git a/src/compas_timber/fabrication/joint_factories/french_ridge_factory.py b/src/compas_timber/fabrication/joint_factories/french_ridge_factory.py index 8d2ec7411..f4ca677c3 100644 --- a/src/compas_timber/fabrication/joint_factories/french_ridge_factory.py +++ b/src/compas_timber/fabrication/joint_factories/french_ridge_factory.py @@ -31,14 +31,10 @@ def apply_processings(cls, joint, parts): top_key = joint.beams[0].key top_part = parts[str(top_key)] - top_part._test.append(top_part.reference_surface_planes(joint.reference_face_indices[str(top_part.beam.key)])) top_part.processings.append(BTLxFrenchRidgeLap.create_process(top_part, joint, True)) bottom_key = joint.beams[1].key bottom_part = parts[str(bottom_key)] - bottom_part._test.append( - bottom_part.reference_surface_planes(joint.reference_face_indices[str(bottom_part.beam.key)]) - ) bottom_part.processings.append(BTLxFrenchRidgeLap.create_process(bottom_part, joint, False)) diff --git a/src/compas_timber/fabrication/joint_factories/l_butt_factory.py b/src/compas_timber/fabrication/joint_factories/l_butt_factory.py index 28916536c..5ac826e71 100644 --- a/src/compas_timber/fabrication/joint_factories/l_butt_factory.py +++ b/src/compas_timber/fabrication/joint_factories/l_butt_factory.py @@ -30,8 +30,12 @@ def apply_processings(cls, joint, parts): main_part = parts[str(joint.main_beam.key)] cross_part = parts[str(joint.cross_beam.key)] - main_part.processings.append(BTLxJackCut.create_process(main_part, joint.cutting_plane_main, "L-Butt Joint")) - cross_part.processings.append(BTLxJackCut.create_process(cross_part, joint.cutting_plane_cross, "L-Butt Joint")) + main_part.processings.append( + BTLxJackCut.create_process(main_part, joint.get_main_cutting_plane()[0], "L-Butt Joint") + ) + cross_part.processings.append( + BTLxJackCut.create_process(cross_part, joint.get_cross_cutting_plane(), "L-Butt Joint") + ) BTLx.register_joint(LButtJoint, LButtFactory) diff --git a/src/compas_timber/fabrication/joint_factories/l_miter_factory.py b/src/compas_timber/fabrication/joint_factories/l_miter_factory.py index 55c43dfda..f6627ecd4 100644 --- a/src/compas_timber/fabrication/joint_factories/l_miter_factory.py +++ b/src/compas_timber/fabrication/joint_factories/l_miter_factory.py @@ -30,10 +30,10 @@ def apply_processings(cls, joint, parts): """ parts[str(joint.beams[0].key)].processings.append( - BTLxJackCut.create_process(parts[str(joint.beams[0].key)], joint.cutting_planes[0], "L-Miter Joint") + BTLxJackCut.create_process(parts[str(joint.beams[0].key)], joint.get_cutting_planes()[0], "L-Miter Joint") ) parts[str(joint.beams[1].key)].processings.append( - BTLxJackCut.create_process(parts[str(joint.beams[1].key)], joint.cutting_planes[1], "L-Miter Joint") + BTLxJackCut.create_process(parts[str(joint.beams[1].key)], joint.get_cutting_planes()[1], "L-Miter Joint") ) diff --git a/src/compas_timber/fabrication/joint_factories/t_butt_factory.py b/src/compas_timber/fabrication/joint_factories/t_butt_factory.py index dc21d3251..1cfa5f4b4 100644 --- a/src/compas_timber/fabrication/joint_factories/t_butt_factory.py +++ b/src/compas_timber/fabrication/joint_factories/t_butt_factory.py @@ -28,7 +28,7 @@ def apply_processings(cls, joint, parts): """ part = parts[str(joint.main_beam.key)] - cut_plane = joint.cutting_plane + cut_plane = joint.get_main_cutting_plane()[0] part.processings.append(BTLxJackCut.create_process(part, cut_plane, "T-Butt Joint")) diff --git a/src/compas_timber/parts/beam.py b/src/compas_timber/parts/beam.py index 1440767c7..3c9045125 100644 --- a/src/compas_timber/parts/beam.py +++ b/src/compas_timber/parts/beam.py @@ -127,34 +127,44 @@ def blank_frame(self): frame.point += -frame.xaxis * start # "extension" to the start edge return frame + @property + def part_ref(self): + frame = self.blank_frame + return Frame( + Point(*(frame.point + (frame.yaxis * self.width * 0.5) - (frame.zaxis * self.height * 0.5))), + frame.xaxis, + frame.zaxis, + ) + @property def faces(self): + frame = self.part_ref return [ Frame( - Point(*add_vectors(self.midpoint, self.frame.yaxis * self.width * 0.5)), - self.frame.xaxis, - -self.frame.zaxis, - ), - Frame( - Point(*add_vectors(self.midpoint, -self.frame.zaxis * self.height * 0.5)), + frame.point, self.frame.xaxis, -self.frame.yaxis, ), Frame( - Point(*add_vectors(self.midpoint, -self.frame.yaxis * self.width * 0.5)), + Point(*add_vectors(frame.point, self.frame.zaxis * self.height)), self.frame.xaxis, - self.frame.zaxis, + -self.frame.zaxis, ), Frame( - Point(*add_vectors(self.midpoint, self.frame.zaxis * self.height * 0.5)), + Point(*(frame.point - self.frame.yaxis * self.width + self.frame.zaxis * self.height)), self.frame.xaxis, self.frame.yaxis, ), - Frame(self.frame.point, -self.frame.yaxis, self.frame.zaxis), # small face at start point Frame( - Point(*add_vectors(self.frame.point, self.frame.xaxis * self.length)), - self.frame.yaxis, + Point(*add_vectors(frame.point, -self.frame.yaxis * self.width)), + self.frame.xaxis, self.frame.zaxis, + ), + Frame(frame.point, -self.frame.yaxis, self.frame.zaxis), # small face at start point + Frame( + Point(*(frame.point + self.frame.xaxis * self.blank_length + self.frame.zaxis * self.height)), + -self.frame.yaxis, + -self.frame.zaxis, ), # small face at end point ]