From ee27964b9daed9cddd3c75f77a6bd12e30c1bc12 Mon Sep 17 00:00:00 2001 From: Chen Kasirer Date: Wed, 11 Sep 2024 10:52:00 +0200 Subject: [PATCH 1/2] key is back, back again --- CHANGELOG.md | 1 + src/compas_timber/elements/beam.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63bea00f8..41b622c68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Added attribute `plates` to `TimberModel`. * Added `SurfaceModelJointOverride` GH Component * Added `ShowSurfaceModelBeamType` GH Component +* Re-introduced attribute `key` in `Beam`. ### Changed diff --git a/src/compas_timber/elements/beam.py b/src/compas_timber/elements/beam.py index 4c0ff130a..2d7968687 100644 --- a/src/compas_timber/elements/beam.py +++ b/src/compas_timber/elements/beam.py @@ -79,6 +79,8 @@ class Beam(Element): A list containing the 4 lines along the long axis of this beam. midpoint : :class:`~compas.geometry.Point` The point at the middle of the centerline of this beam. + key : int, optional + Once beam is added to a model, it will have this model-unique integer key. """ @@ -239,6 +241,11 @@ def has_features(self): # TODO: move to compas_future... Part return len(self.features) > 0 + @property + def key(self): + # type: () -> int | None + return self.graph_node + def __str__(self): return "Beam {:.3f} x {:.3f} x {:.3f} at {}".format( self.width, From 709f646bed92accdfc8040f08b36dceb99dd5c48 Mon Sep 17 00:00:00 2001 From: Chen Kasirer Date: Wed, 11 Sep 2024 11:08:44 +0200 Subject: [PATCH 2/2] added key to Plate as well --- CHANGELOG.md | 1 + src/compas_timber/elements/beam.py | 4 ++-- src/compas_timber/elements/plate.py | 10 ++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41b622c68..3119d4e70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Added `SurfaceModelJointOverride` GH Component * Added `ShowSurfaceModelBeamType` GH Component * Re-introduced attribute `key` in `Beam`. +* Added attribute `key` to `Plate`. ### Changed diff --git a/src/compas_timber/elements/beam.py b/src/compas_timber/elements/beam.py index 2d7968687..0a5e3f42e 100644 --- a/src/compas_timber/elements/beam.py +++ b/src/compas_timber/elements/beam.py @@ -80,7 +80,7 @@ class Beam(Element): midpoint : :class:`~compas.geometry.Point` The point at the middle of the centerline of this beam. key : int, optional - Once beam is added to a model, it will have this model-unique integer key. + Once beam is added to a model, it will have this model-wide-unique integer key. """ @@ -238,7 +238,7 @@ def midpoint(self): @property def has_features(self): - # TODO: move to compas_future... Part + # TODO: consider removing, this is not used anywhere return len(self.features) > 0 @property diff --git a/src/compas_timber/elements/plate.py b/src/compas_timber/elements/plate.py index 362abe838..a4b04a873 100644 --- a/src/compas_timber/elements/plate.py +++ b/src/compas_timber/elements/plate.py @@ -37,7 +37,8 @@ class Plate(Element): Thickness of the plate material. aabb : tuple(float, float, float, float, float, float) An axis-aligned bounding box of this plate as a 6 valued tuple of (xmin, ymin, zmin, xmax, ymax, zmax). - + key : int, optional + Once plate is added to a model, it will have this model-wide-unique integer key. """ @@ -91,9 +92,14 @@ def shape(self): @property def has_features(self): - # TODO: move to compas_future... Part + # TODO: consider removing, this is not used anywhere return len(self.features) > 0 + @property + def key(self): + # type: () -> int | None + return self.graph_node + # ========================================================================== # Implementations of abstract methods # ==========================================================================