From ff0c2d484f50a97ccfdbc172e7088b8772014e4a Mon Sep 17 00:00:00 2001 From: obucklin Date: Tue, 19 Mar 2024 13:41:35 +0100 Subject: [PATCH] Changelog, format, lint, test --- CHANGELOG.md | 2 ++ src/compas_timber/connections/butt_joint.py | 36 ++++++++++++------- src/compas_timber/fabrication/__init__.py | 2 ++ .../fabrication/btlx_processes/lap.py | 27 ++++++-------- .../joint_factories/l_butt_factory.py | 3 ++ .../joint_factories/t_butt_factory.py | 12 ++----- 6 files changed, 43 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70ac6b349..2af21c521 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Added new `NullJoint`. * Added `mill_depth` argument to butt joints, with geometric representation of milled recess in cross beam. * Added `ButtJoint` class with methods common to `LButtJoint` and `TButtJoint` +* Added BTLx support for `TButtJoint` and `LButtJoint` +* Added `BTLxLap` process class ### Changed diff --git a/src/compas_timber/connections/butt_joint.py b/src/compas_timber/connections/butt_joint.py index cf5b8a6b2..ce9290838 100644 --- a/src/compas_timber/connections/butt_joint.py +++ b/src/compas_timber/connections/butt_joint.py @@ -73,7 +73,6 @@ def __init__( self.features = [] self.test = [] - @property def __data__(self): data_dict = { @@ -110,15 +109,20 @@ def joint_type(self): return "Butt" def get_main_cutting_plane(self): + """Returns the cutting plane for the main beam and the beam.face from which it is derived.""" assert self.main_beam and self.cross_beam - self.reference_side_index_cross, _ = self.get_face_most_towards_beam(self.main_beam, self.cross_beam, ignore_ends=False) + self.reference_side_index_cross, _ = self.get_face_most_towards_beam( + self.main_beam, self.cross_beam, ignore_ends=False + ) if self.reject_i and self.reference_side_index in [4, 5]: raise BeamJoinningError( beams=self.beams, joint=self, debug_info="Beams are in I topology and reject_i flag is True" ) - self.reference_side_index_cross, cfr = self.get_face_most_ortho_to_beam(self.main_beam, self.cross_beam, ignore_ends=True) + self.reference_side_index_cross, cfr = self.get_face_most_ortho_to_beam( + self.main_beam, self.cross_beam, ignore_ends=True + ) self.btlx_params_cross["reference_plane_id"] = self.reference_side_index_cross cross_mating_frame = cfr.copy() cfr = Frame(cfr.point, cfr.xaxis, cfr.yaxis * -1.0) # flip normal @@ -131,15 +135,19 @@ def restore_beams_from_keys(self, assemly): self.cross_beam = assemly.find_by_key(self.cross_beam_key) def side_surfaces_cross(self): + """Returns the two side surfaces of the cross beam.""" if self.reference_side_index_cross == 0: return self.cross_beam.faces[3], self.cross_beam.faces[1] - elif self.reference_side_index_cross < 3: # 1 or 2 - return self.cross_beam.faces[self.reference_side_index_cross-1], self.cross_beam.faces[self.reference_side_index_cross+1] + elif self.reference_side_index_cross < 3: # 1 or 2 + return ( + self.cross_beam.faces[self.reference_side_index_cross - 1], + self.cross_beam.faces[self.reference_side_index_cross + 1], + ) else: return self.cross_beam.faces[2], self.cross_beam.faces[0] - def front_back_surface_main(self): + """Returns the front and back surfaces of the main beam.""" face_dict = Joint._beam_side_incidence(self.cross_beam, self.main_beam, ignore_ends=True) face_indices = face_dict.keys() angles = face_dict.values() @@ -147,6 +155,7 @@ def front_back_surface_main(self): return self.main_beam.faces[face_indices[0]], self.main_beam.faces[face_indices[3]] def subtraction_volume(self): + """Returns the volume to be subtracted from the cross beam.""" vertices = [] front_frame, back_frame = self.front_back_surface_main() top_frame, bottom_frame = self.get_main_cutting_plane() @@ -164,7 +173,7 @@ def subtraction_volume(self): dots = [dot_vectors(v, self.cross_beam.centerline.direction) for v in pv] dots, points = zip(*sorted(zip(dots, points))) min_pt, max_pt = points[0], points[-1] - if i ==1: + if i == 1: self.btlx_params_cross["start_x"] = abs(dots[0]) top_line = Line(*intersection_plane_plane(Plane.from_frame(side), Plane.from_frame(top_frame))) @@ -184,15 +193,18 @@ def subtraction_volume(self): print(_len) front_line = Line(*intersection_plane_plane(Plane.from_frame(front_frame), Plane.from_frame(top_frame))) - back_line = Line(*intersection_plane_plane(Plane.from_frame(back_frame), Plane.from_frame(top_frame))) self.btlx_params_cross["depth"] = self.mill_depth - self.btlx_params_cross["width"] = self.cross_beam.width if self.reference_side_index_cross % 2 == 0 else self.cross_beam.height + self.btlx_params_cross["width"] = ( + self.cross_beam.width if self.reference_side_index_cross % 2 == 0 else self.cross_beam.height + ) - self.btlx_params_cross["length"] = _len #distance_line_line(front_line, back_line) + self.btlx_params_cross["length"] = _len if dot_vectors(top_frame.yaxis, front_line.direction) < 0: front_line = Line(front_line.end, front_line.start) - self.btlx_params_cross["angle"] = abs(angle_vectors_signed(top_frame.xaxis, front_line.direction, top_frame.zaxis, deg=True)) + self.btlx_params_cross["angle"] = abs( + angle_vectors_signed(top_frame.xaxis, front_line.direction, top_frame.zaxis, deg=True) + ) center = (vertices[0] + vertices[1] + vertices[2] + vertices[3]) * 0.25 angle = angle_vectors_signed( @@ -209,8 +221,6 @@ def subtraction_volume(self): # self.test = vertices return ph - - def add_features(self): """Adds the required extension and trimming features to both beams. diff --git a/src/compas_timber/fabrication/__init__.py b/src/compas_timber/fabrication/__init__.py index 7b68314d2..a88b89c7e 100644 --- a/src/compas_timber/fabrication/__init__.py +++ b/src/compas_timber/fabrication/__init__.py @@ -2,6 +2,7 @@ from .btlx import BTLxProcess from .btlx_processes.btlx_french_ridge_lap import BTLxFrenchRidgeLap from .btlx_processes.btlx_jack_cut import BTLxJackCut +from .btlx_processes.lap import BTLxLap from .joint_factories.french_ridge_factory import FrenchRidgeFactory from .joint_factories.l_butt_factory import LButtFactory from .joint_factories.l_miter_factory import LMiterFactory @@ -11,6 +12,7 @@ "BTLx", "BTLxProcess", "BTLxJackCut", + "BTLxLap", "BTLxFrenchRidgeLap", "LButtFactory", "TButtFactory", diff --git a/src/compas_timber/fabrication/btlx_processes/lap.py b/src/compas_timber/fabrication/btlx_processes/lap.py index 20b251179..a887ad61a 100644 --- a/src/compas_timber/fabrication/btlx_processes/lap.py +++ b/src/compas_timber/fabrication/btlx_processes/lap.py @@ -1,14 +1,6 @@ -import math from collections import OrderedDict - -from compas.geometry import Line -from compas.geometry import Plane -from compas.geometry import angle_vectors_signed -from compas.geometry import cross_vectors - from compas_timber.fabrication import BTLx from compas_timber.fabrication import BTLxProcess -from compas_timber.utils.compas_extra import intersection_line_plane class BTLxLap(object): @@ -17,12 +9,12 @@ class BTLxLap(object): Parameters ---------- - part : :class:`~compas_timber.fabrication.btlx_part.BTLxPart` - The BTLxPart object representing the beam. - frame : :class:`~compas.geometry.Frame` - The frame object representing the cutting plane. - joint_name : str, optional - The name of the joint. Defaults to None. + param_dict : dict + A dictionary containing the parameters for the BTLx lap process. + joint_name : str + The name of the joint. If not provided, the default name is "lap". + kwargs : dict + Additional keyword arguments to be added to the object. """ @@ -65,12 +57,12 @@ def header_attributes(self): "Process": "yes", "Priority": "0", "ProcessID": "0", - "ReferencePlaneID": str(self.reference_plane_id + 1) + "ReferencePlaneID": str(self.reference_plane_id + 1), } @property def process_params(self): - """This property is required for all process types. It returns a dict with the geometric parameters to fabricate the joint. """ + """This property is required for all process types. It returns a dict with the geometric parameters to fabricate the joint.""" if self.apply_process: """the following attributes are specific to Lap""" @@ -89,7 +81,7 @@ def process_params(self): ("LeadAngle", "{:.{prec}f}".format(self.lead_angle, prec=BTLx.ANGLE_PRECISION)), ("LeadInclinationParallel", "yes"), ("LeadInclination", "{:.{prec}f}".format(self.lead_inclination, prec=BTLx.ANGLE_PRECISION)), - ("MachiningLimits", self.machining_limits) + ("MachiningLimits", self.machining_limits), ] ) print("param dict", od) @@ -99,5 +91,6 @@ def process_params(self): @classmethod def create_process(cls, param_dict, joint_name=None, **kwargs): + """Creates a lap process from a dictionary of parameters.""" lap = BTLxLap(param_dict, joint_name, **kwargs) return BTLxProcess(BTLxLap.PROCESS_TYPE, lap.header_attributes, lap.process_params) 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 5ac826e71..1d5364659 100644 --- a/src/compas_timber/fabrication/joint_factories/l_butt_factory.py +++ b/src/compas_timber/fabrication/joint_factories/l_butt_factory.py @@ -1,6 +1,7 @@ from compas_timber.connections import LButtJoint from compas_timber.fabrication import BTLx from compas_timber.fabrication import BTLxJackCut +from compas_timber.fabrication import BTLxLap class LButtFactory(object): @@ -36,6 +37,8 @@ def apply_processings(cls, joint, parts): cross_part.processings.append( BTLxJackCut.create_process(cross_part, joint.get_cross_cutting_plane(), "L-Butt Joint") ) + if joint.mill_depth > 0: + cross_part.processings.append(BTLxLap.create_process(joint.btlx_params_cross, "T-Butt Joint")) BTLx.register_joint(LButtJoint, LButtFactory) 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 ce7e65555..dbba7b08c 100644 --- a/src/compas_timber/fabrication/joint_factories/t_butt_factory.py +++ b/src/compas_timber/fabrication/joint_factories/t_butt_factory.py @@ -32,15 +32,9 @@ def apply_processings(cls, joint, parts): cut_plane = joint.get_main_cutting_plane()[0] main_part.processings.append(BTLxJackCut.create_process(main_part, cut_plane, "T-Butt Joint")) - cross_part = parts[str(joint.cross_beam.key)] - cross_part.processings.append(BTLxLap.create_process(joint.btlx_params_cross, "T-Butt Joint")) - - - - - + if joint.mill_depth > 0: + cross_part = parts[str(joint.cross_beam.key)] + cross_part.processings.append(BTLxLap.create_process(joint.btlx_params_cross, "T-Butt Joint")) BTLx.register_joint(TButtJoint, TButtFactory) - -