From 3daa8c618e4ed70cd4b1923efe32f48f62247c89 Mon Sep 17 00:00:00 2001 From: Chen Kasirer Date: Thu, 15 Feb 2024 12:17:05 +0100 Subject: [PATCH 1/3] implemented a null joint --- CHANGELOG.md | 1 + src/compas_timber/connections/__init__.py | 2 + src/compas_timber/connections/null_joint.py | 82 ++++++++++++++++++ .../CT_Joint_Options_NullJoint/code.py | 12 +++ .../CT_Joint_Options_NullJoint/icon.png | Bin 0 -> 409 bytes .../CT_Joint_Options_NullJoint/metadata.json | 20 +++++ 6 files changed, 117 insertions(+) create mode 100644 src/compas_timber/connections/null_joint.py create mode 100644 src/compas_timber/ghpython/components/CT_Joint_Options_NullJoint/code.py create mode 100644 src/compas_timber/ghpython/components/CT_Joint_Options_NullJoint/icon.png create mode 100644 src/compas_timber/ghpython/components/CT_Joint_Options_NullJoint/metadata.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 231fdc1f04..11d6e3ad2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * (Re)added `BooleanSubtraction` feature. * Added flag `modify_cross` to `L-Butt` joint. * Added flag `reject_i` to `L-Butt` joint. +* Added new `NullJoint`. ### Changed diff --git a/src/compas_timber/connections/__init__.py b/src/compas_timber/connections/__init__.py index 0debd44543..f459a0dda7 100644 --- a/src/compas_timber/connections/__init__.py +++ b/src/compas_timber/connections/__init__.py @@ -11,6 +11,7 @@ from .solver import JointTopology from .solver import find_neighboring_beams from .t_butt import TButtJoint +from .null_joint import NullJoint __all__ = [ "Joint", @@ -22,6 +23,7 @@ "XHalfLapJoint", "THalfLapJoint", "LHalfLapJoint", + "NullJoint", "FrenchRidgeLapJoint", "JointTopology", "ConnectionSolver", diff --git a/src/compas_timber/connections/null_joint.py b/src/compas_timber/connections/null_joint.py new file mode 100644 index 0000000000..73621630e3 --- /dev/null +++ b/src/compas_timber/connections/null_joint.py @@ -0,0 +1,82 @@ +from compas.geometry import Frame +from .joint import Joint +from .solver import JointTopology + + +class NullJoint(Joint): + """A null joint is a joint that does not have any features. + + Can be used to join to beams which shouldn't join. + + Please use `NullJoint.create()` to properly create an instance of this class and associate it with an assembly. + + Parameters + ---------- + beam_a : :class:`~compas_timber.parts.Beam` + First beam to be joined. + beam_b : :class:`~compas_timber.parts.Beam` + Second beam to be joined. + + Attributes + ---------- + beams : list(:class:`~compas_timber.parts.Beam`) + The beams joined by this joint. + joint_type : str + A string representation of this joint's type. + + """ + + SUPPORTED_TOPOLOGY = JointTopology.TOPO_L # TODO: this really supports all.. + + def __init__(self, beam_a=None, beam_b=None, **kwargs): + super(NullJoint, self).__init__(**kwargs) + + self.beam_a = beam_a + self.beam_b = beam_b + self.beam_a_key = beam_a.key if beam_a else None + self.beam_b_key = beam_b.key if beam_b else None + self.features = [] + + @property + def __data__(self): + data_dict = { + "beam_a_key": self.beam_a_key, + "beam_b_key": self.beam_b_key, + } + data_dict.update(super(NullJoint, self).__data__) + return data_dict + + @classmethod + def __from_data__(cls, value): + instance = cls( + frame=Frame.__from_data__(value["frame"]), + key=value["key"], + small_beam_butts=value["small_beam_butts"], + modify_cross=value["modify_cross"], + reject_i=value["reject_i"], + ) + instance.beam_a_key = value["main_beam_key"] + instance.beam_b_key = value["cross_beam_key"] + return instance + + @property + def beams(self): + return [self.beam_a, self.beam_b] + + @property + def joint_type(self): + return "L-Butt" + + + def restore_beams_from_keys(self, assemly): + """After de-serialization, resotres references to the main and cross beams saved in the assembly.""" + self.beam_a = assemly.find_by_key(self.beam_a_key) + self.beam_b = assemly.find_by_key(self.beam_b_key) + + def add_features(self): + """Adds the required extension and trimming features to both beams. + + This method is automatically called when joint is created by the call to `Joint.create()`. + + """ + pass diff --git a/src/compas_timber/ghpython/components/CT_Joint_Options_NullJoint/code.py b/src/compas_timber/ghpython/components/CT_Joint_Options_NullJoint/code.py new file mode 100644 index 0000000000..30de1c26a7 --- /dev/null +++ b/src/compas_timber/ghpython/components/CT_Joint_Options_NullJoint/code.py @@ -0,0 +1,12 @@ +from ghpythonlib.componentbase import executingcomponent as component + + +from compas_timber.connections import NullJoint +from compas_timber.ghpython import JointOptions + + +class NullJointComponent(component): + def RunScript(self): + + options = JointOptions(NullJoint, **{}) + return options diff --git a/src/compas_timber/ghpython/components/CT_Joint_Options_NullJoint/icon.png b/src/compas_timber/ghpython/components/CT_Joint_Options_NullJoint/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3d0760fe79a45b1474eed4684eded132a0f6b28d GIT binary patch literal 409 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjoCO|{#S9GGLLkg|>2BR01_nlN zPZ!4!kItl!Y2iQimptWSt5LABX?l3B`FBr+Xd*KY4-Zf$!~g$DO76lJ8yXuK!MsIl zS>ZAR#ZF=ryuLnmaqmmGOPHoFGcleEb0gF5hJZp}vxI~Mhz}O!$`}|JK-tuCf390H b%zS2sxv_j%?HY!4AUix={an^LB{Ts58?Sk) literal 0 HcmV?d00001 diff --git a/src/compas_timber/ghpython/components/CT_Joint_Options_NullJoint/metadata.json b/src/compas_timber/ghpython/components/CT_Joint_Options_NullJoint/metadata.json new file mode 100644 index 0000000000..6bc831eda0 --- /dev/null +++ b/src/compas_timber/ghpython/components/CT_Joint_Options_NullJoint/metadata.json @@ -0,0 +1,20 @@ +{ + "name": "Null-Joint Options", + "nickname": "NullJoint", + "category": "COMPAS Timber", + "subcategory": "Joints", + "description": "defines and gives access to NullJoint joint and its parameters", + "exposure": 2, + "ghpython": { + "isAdvancedMode": true, + "iconDisplay": 0, + "inputParameters": [ + ], + "outputParameters": [ + { + "name": "NullJoint", + "description": "NullJoint Joint Options." + } + ] + } +} From 739fac13a1a1d0f2aa12c7ace8c6ab788766b059 Mon Sep 17 00:00:00 2001 From: jonashaldemann <104436733+jonashaldemann@users.noreply.github.com> Date: Thu, 15 Feb 2024 12:24:13 +0100 Subject: [PATCH 2/3] Icon added to NullJoint --- .../CT_Joint_Options_NullJoint/icon.png | Bin 409 -> 647 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/compas_timber/ghpython/components/CT_Joint_Options_NullJoint/icon.png b/src/compas_timber/ghpython/components/CT_Joint_Options_NullJoint/icon.png index 3d0760fe79a45b1474eed4684eded132a0f6b28d..d6855f0072c173b645b15439ff641d64e0cd61b0 100644 GIT binary patch delta 444 zcmbQq+|D||f{Dp;qSeCsBuDWX_5bA$ub%&3vM6MR=?MutP8>Ke!C?xLX;JmF+>Wan{^44g_(Nam_<x>ZcP(3NW*i}rVxjRUG3kY;gf=h)Ao`R3{FlF4bMxO~X$Mciy9yIdCr+EeWoR@d z+d=0TH!uL8wurg#&v-ZYXn|@6uMo4O-Z8(FuV)S%fJ%N~zopr0H}Snu>b%7 delta 107 zcmZo?oyk1Gf{D?4qSeBQ^CirZ7zMAdk6qmRl81+f0SNy8XPUmu#CUFFBO`?OyCI;^ u*DN6+0V2C7SH{4=U}B@cVy;^ Date: Thu, 15 Feb 2024 12:25:30 +0100 Subject: [PATCH 3/3] linting --- src/compas_timber/connections/null_joint.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/compas_timber/connections/null_joint.py b/src/compas_timber/connections/null_joint.py index 73621630e3..a6990213d1 100644 --- a/src/compas_timber/connections/null_joint.py +++ b/src/compas_timber/connections/null_joint.py @@ -67,7 +67,6 @@ def beams(self): def joint_type(self): return "L-Butt" - def restore_beams_from_keys(self, assemly): """After de-serialization, resotres references to the main and cross beams saved in the assembly.""" self.beam_a = assemly.find_by_key(self.beam_a_key)