diff --git a/CHANGELOG.md b/CHANGELOG.md index dfe28f280..e7474b8c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Added `ref_frame` attribute to `Beam`. * Added `ref_sides` attribute to `Beam`. +* Added `ref_edges` attribute to `Beam`. ### Changed diff --git a/src/compas_timber/elements/beam.py b/src/compas_timber/elements/beam.py index b48472885..4c0ff130a 100644 --- a/src/compas_timber/elements/beam.py +++ b/src/compas_timber/elements/beam.py @@ -57,6 +57,8 @@ class Beam(Element): Reference frame for machining processes according to BTLx standard. ref_sides : tuple(:class:`~compas.geometry.Frame`) A tuple containing the 6 frames representing the sides of the beam according to BTLx standard. + ref_edges : tuple(:class:`~compas.geometry.Line`) + A tuple containing the 4 lines representing the long edges of the beam according to BTLx standard. faces : list(:class:`~compas.geometry.Frame`) A list of frames representing the 6 faces of this beam. 0: +y (side's frame normal is equal to the beam's Y positive direction) @@ -190,6 +192,17 @@ def ref_sides(self): Frame(rs6_point, self.ref_frame.zaxis, -self.ref_frame.yaxis, name="RS_6"), ) + @property + def ref_edges(self): + # so tuple is not created every time + ref_sides = self.ref_sides + return ( + Line(ref_sides[0].point, ref_sides[0].point + ref_sides[0].xaxis * self.blank_length, name="RE_1"), + Line(ref_sides[1].point, ref_sides[1].point + ref_sides[1].xaxis * self.blank_length, name="RE_2"), + Line(ref_sides[2].point, ref_sides[2].point + ref_sides[2].xaxis * self.blank_length, name="RE_3"), + Line(ref_sides[3].point, ref_sides[3].point + ref_sides[3].xaxis * self.blank_length, name="RE_4"), + ) + @property def centerline(self): return Line(self.centerline_start, self.centerline_end) diff --git a/tests/compas_timber/test_btlx.py b/tests/compas_timber/test_btlx.py index 53cb46328..28942bb5e 100644 --- a/tests/compas_timber/test_btlx.py +++ b/tests/compas_timber/test_btlx.py @@ -65,3 +65,31 @@ def test_beam_ref_faces_attribute(mock_beam): ref_side = mock_beam.ref_sides[index] assert ref_side_frames_expected[index] == ref_side assert ref_side.name == "RS_{}".format(index + 1) + + +def test_beam_ref_edges(mock_beam): + + ref_edges_expected = ( + Line( + Point(x=-48.67193560518159, y=20.35704602012424, z=0.0005429194857271558), + Point(x=-38.61153715338159, y=24.06100004952424, z=0.5005429194857273), + ), + Line( + Point(x=-48.7156552451492, y=20.340949685829152, z=0.9994570805142728), + Point(x=-38.6552567933492, y=24.04490371522915, z=1.499457080514273), + ), + Line( + Point(x=-48.37015592401841, y=19.402530686075757, z=0.9994570805142728), + Point(x=-38.309757472218415, y=23.106484715475755, z=1.499457080514273), + ), + Line( + Point(x=-48.3264362840508, y=19.41862702037084, z=0.000542919485727154), + Point(x=-38.2660378322508, y=23.12258104977084, z=0.5005429194857273), + ), + ) + assert len(mock_beam.ref_edges) == 4 + + for index in range(4): + ref_edge = mock_beam.ref_edges[index] + assert ref_edges_expected[index] == ref_edge + assert ref_edge.name == "RE_{}".format(index + 1)