Skip to content

Commit

Permalink
Merge pull request #324 from gramaziokohler/fix_joint_init_data
Browse files Browse the repository at this point in the history
Fix joint init data
  • Loading branch information
chenkasirer authored Nov 14, 2024
2 parents f79fccf + f757750 commit 295c3ff
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 22 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Renamed `intersection_line_line_3D` to `intersection_line_line_param`.
* Adjusted functions in `compas_timber._fabrication.DovetailMortise` and `compas_timber.connections.TDovetailJoint`.
* Added `conda-forge` channel to installation instructions.
* Fixed `**kwargs` inheritance in `__init__` for joint modules: `LMiterJoint`, `TStepJoint`, `TDovetailJoint`, `TBirdsmouthJoint`.
* Fixed GUID assignment logic from `**kwargs` to ensure correct fallback behavior for joint modules: `LMiterJoint`, `TStepJoint`, `TDovetailJoint`, `TBirdsmouthJoint`.
* Changed `model.element_by_guid()` instead of direct `elementsdict[]` access for beam retrieval in joint modules: `LMiterJoint`, `TStepJoint`, `TDovetailJoint`, `TBirdsmouthJoint`.

### Removed

Expand Down
12 changes: 6 additions & 6 deletions src/compas_timber/connections/l_miter.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ def __data__(self):
data["cutoff"] = self.cutoff
return data

def __init__(self, beam_a=None, beam_b=None, cutoff=None):
super(LMiterJoint, self).__init__()
def __init__(self, beam_a=None, beam_b=None, cutoff=None, **kwargs):
super(LMiterJoint, self).__init__(**kwargs)
self.beam_a = beam_a
self.beam_b = beam_b
self.beam_a_guid = str(beam_a.guid) if beam_a else None
self.beam_b_guid = str(beam_b.guid) if beam_b else None
self.beam_a_guid = kwargs.get("beam_a_guid", None) or str(beam_a.guid)
self.beam_b_guid = kwargs.get("beam_b_guid", None) or str(beam_b.guid)
self.cutoff = cutoff # for very acute angles, limit the extension of the tip/beak of the joint
self.features = []

Expand Down Expand Up @@ -148,5 +148,5 @@ def add_features(self):

def restore_beams_from_keys(self, model):
"""After de-serialization, restores references to the main and cross beams saved in the model."""
self.beam_a = model.elementdict[self.beam_a_guid]
self.beam_b = model.elementdict[self.beam_b_guid]
self.beam_a = model.element_by_guid(self.beam_a_guid)
self.beam_b = model.element_by_guid(self.beam_b_guid)
12 changes: 6 additions & 6 deletions src/compas_timber/connections/t_birdsmouth.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ def __data__(self):
data["cross_beam"] = self.cross_beam_guid
return data

def __init__(self, main_beam, cross_beam):
super(TBirdsmouthJoint, self).__init__()
def __init__(self, main_beam, cross_beam, **kwargs):
super(TBirdsmouthJoint, self).__init__(**kwargs)
self.main_beam = main_beam
self.cross_beam = cross_beam
self.main_beam_guid = str(main_beam.guid) if main_beam else None
self.cross_beam_guid = str(cross_beam.guid) if cross_beam else None
self.main_beam_guid = kwargs.get("main_beam_guid", None) or str(main_beam.guid)
self.cross_beam_guid = kwargs.get("cross_beam_guid", None) or str(cross_beam.guid)

self.features = []

Expand Down Expand Up @@ -124,5 +124,5 @@ def add_features(self):

def restore_beams_from_keys(self, model):
"""After de-serialization, restores references to the main and cross beams saved in the model."""
self.main_beam = model.elementdict[self.main_beam_guid]
self.cross_beam = model.elementdict[self.cross_beam_guid]
self.main_beam = model.element_by_guid(self.main_beam_guid)
self.cross_beam = model.element_by_guid(self.cross_beam_guid)
12 changes: 7 additions & 5 deletions src/compas_timber/connections/t_dovetail.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def __data__(self):
data["tool_height"] = self.tool_height
return data

# fmt: off
def __init__(
self,
main_beam,
Expand All @@ -117,12 +118,13 @@ def __init__(
tool_angle=None,
tool_diameter=None,
tool_height=None,
**kwargs
):
super(TDovetailJoint, self).__init__()
super(TDovetailJoint, self).__init__(**kwargs)
self.main_beam = main_beam
self.cross_beam = cross_beam
self.main_beam_guid = str(main_beam.guid) if main_beam else None
self.cross_beam_guid = str(cross_beam.guid) if cross_beam else None
self.main_beam_guid = kwargs.get("main_beam_guid", None) or str(main_beam.guid)
self.cross_beam_guid = kwargs.get("cross_beam_guid", None) or str(cross_beam.guid)

# Default values if not provided
self.start_y = start_y if start_y is not None else 0.0
Expand Down Expand Up @@ -285,5 +287,5 @@ def define_dovetail_tool(self, tool_angle, tool_diameter, tool_height):

def restore_beams_from_keys(self, model):
"""After de-serialization, restores references to the main and cross beams saved in the model."""
self.main_beam = model.elementdict[self.main_beam_guid]
self.cross_beam = model.elementdict[self.cross_beam_guid]
self.main_beam = model.element_by_guid(self.main_beam_guid)
self.cross_beam = model.element_by_guid(self.cross_beam_guid)
12 changes: 7 additions & 5 deletions src/compas_timber/connections/t_step_joint.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def __data__(self):
data["tenon_mortise_height"] = self.tenon_mortise_height
return data

# fmt: off
def __init__(
self,
main_beam,
Expand All @@ -76,12 +77,13 @@ def __init__(
heel_depth=None,
tapered_heel=None,
tenon_mortise_height=None,
**kwargs
):
super(TStepJoint, self).__init__()
super(TStepJoint, self).__init__(**kwargs)
self.main_beam = main_beam
self.cross_beam = cross_beam
self.main_beam_guid = str(main_beam.guid) if main_beam else None
self.cross_beam_guid = str(cross_beam.guid) if cross_beam else None
self.main_beam_guid = kwargs.get("main_beam_guid", None) or str(main_beam.guid)
self.cross_beam_guid = kwargs.get("cross_beam_guid", None) or str(cross_beam.guid)

self.step_shape = 0 if step_shape is None else step_shape
self.step_depth, self.heel_depth = self.set_step_depths(step_depth, heel_depth)
Expand Down Expand Up @@ -195,5 +197,5 @@ def add_features(self):

def restore_beams_from_keys(self, model):
"""After de-serialization, restores references to the main and cross beams saved in the model."""
self.main_beam = model.elementdict[self.main_beam_guid]
self.cross_beam = model.elementdict[self.cross_beam_guid]
self.main_beam = model.element_by_guid(self.main_beam_guid)
self.cross_beam = model.element_by_guid(self.cross_beam_guid)

0 comments on commit 295c3ff

Please sign in to comment.