Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implemented a null joint #230

Merged
merged 3 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions src/compas_timber/connections/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -22,6 +23,7 @@
"XHalfLapJoint",
"THalfLapJoint",
"LHalfLapJoint",
"NullJoint",
"FrenchRidgeLapJoint",
"JointTopology",
"ConnectionSolver",
Expand Down
81 changes: 81 additions & 0 deletions src/compas_timber/connections/null_joint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
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
Original file line number Diff line number Diff line change
@@ -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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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."
}
]
}
}
Loading