Skip to content

Commit

Permalink
Merge branch 'main' into fix_surface_model_tolerance
Browse files Browse the repository at this point in the history
  • Loading branch information
chenkasirer authored Sep 9, 2024
2 parents 52fe753 + 857bf0d commit 8a3da2d
Show file tree
Hide file tree
Showing 37 changed files with 706 additions and 167 deletions.
15 changes: 13 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

* Added `SurfaceModelJointOverride` GH Component
* Added `SurfaceModelJointOverride` GH Component.
* Added `Plate` element.
* Added attribute `plates` to `TimberModel`.

### Changed

* Fixed missing input parameter in `SurfaceModelOptions` GH Component
* Fixed missing input parameter in `SurfaceModelOptions` GH Component.
* Fixed error with tolerances for `SurfaceModel`s modeled in meters.
* Renamed `beam` to `element` in different locations to make it more generic.

### Removed

* Removed `add_beam` from `TimberModel`, use `add_element` instead.
* Removed `add_plate` from `TimberModel`, use `add_element` instead.
* Removed `add_wall` from `TimberModel`, use `add_element` instead.


## [0.9.1] 2024-07-05

Expand All @@ -30,6 +37,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

* Fixed error in BakeWithBoxMap component.
* Added `add_extensions` to `Joint` interface.
* Added `process_joinery` to `TimberModel`.
* Features are not automatically added when creating a joint using `Joint.create()`.
* Features are not automatically added when de-serializing.

### Removed

Expand Down
Binary file modified examples/Grasshopper/dynamic_gh_demo.gh
Binary file not shown.
17 changes: 16 additions & 1 deletion src/compas_timber/connections/joint.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,22 @@ def add_features(self):
"""
raise NotImplementedError

def add_extensions(self):
"""Adds the extensions defined by this joint to affected beam(s).
This is optional and should only be implemented by joints that require it.
Note
----
Extensions are added to all beams before the features are added.
Raises
------
:class:`~compas_timber.connections.BeamJoinningError`
Should be raised whenever the joint was not able to calculate the extensions to be applied to the beams.
"""
pass

def restore_beams_from_keys(self, model):
"""Restores the reference to the beams associate with this joint.
Expand Down Expand Up @@ -124,7 +140,6 @@ def create(cls, model, *beams, **kwargs):
raise ValueError("Expected at least 2 beams. Got instead: {}".format(len(beams)))
joint = cls(*beams, **kwargs)
model.add_joint(joint, beams)
joint.add_features()
return joint

@property
Expand Down
49 changes: 33 additions & 16 deletions src/compas_timber/connections/l_butt.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,37 @@ def get_main_cutting_plane(self):
)
return super(LButtJoint, self).get_main_cutting_plane()

def add_extensions(self):
"""Calculates and adds the necessary extensions to the beams.
This method is automatically called when joint is created by the call to `Joint.create()`.
Raises
------
BeamJoinningError
If the extension could not be calculated.
"""
assert self.main_beam and self.cross_beam # should never happen

try:
main_cutting_plane = self.get_main_cutting_plane()[0]
start_main, end_main = self.main_beam.extension_to_plane(main_cutting_plane)
extension_tolerance = 0.01 # TODO: this should be proportional to the unit used
self.main_beam.add_blank_extension(
start_main + extension_tolerance, end_main + extension_tolerance, self.guid
)

if self.modify_cross:
cross_cutting_plane = self.get_cross_cutting_plane()
start_cross, end_cross = self.cross_beam.extension_to_plane(cross_cutting_plane)
self.cross_beam.add_blank_extension(
start_cross + extension_tolerance, end_cross + extension_tolerance, self.guid
)
except Exception as ex:
debug_info = getattr(ex, "debug_info", str(ex))
raise BeamJoinningError(beams=self.beams, joint=self, debug_info=debug_info)

def add_features(self):
"""Adds the required extension and trimming features to both beams.
Expand All @@ -93,33 +124,19 @@ def add_features(self):
assert self.main_beam and self.cross_beam # should never happen
if self.features:
self.main_beam.remove_features(self.features)
start_main, start_cross = None, None

try:
main_cutting_plane = self.get_main_cutting_plane()[0]
cross_cutting_plane = self.get_cross_cutting_plane()
start_main, end_main = self.main_beam.extension_to_plane(main_cutting_plane)
start_cross, end_cross = self.cross_beam.extension_to_plane(cross_cutting_plane)
except BeamJoinningError as be:
raise be
except AttributeError as ae:
# I want here just the plane that caused the error
geometries = [cross_cutting_plane] if start_main is not None else [main_cutting_plane]
raise BeamJoinningError(beams=self.beams, joint=self, debug_info=str(ae), debug_geometries=geometries)
except Exception as ex:
raise BeamJoinningError(beams=self.beams, joint=self, debug_info=str(ex))

extension_tolerance = 0.01 # TODO: this should be proportional to the unit used
debug_info = getattr(ex, "debug_info", str(ex))
raise BeamJoinningError(beams=self.beams, joint=self, debug_info=debug_info)

if self.modify_cross:
self.cross_beam.add_blank_extension(
start_cross + extension_tolerance, end_cross + extension_tolerance, self.guid
)
f_cross = CutFeature(cross_cutting_plane)
self.cross_beam.add_features(f_cross)
self.features.append(f_cross)

self.main_beam.add_blank_extension(start_main + extension_tolerance, end_main + extension_tolerance, self.guid)
f_main = CutFeature(main_cutting_plane)
if self.mill_depth:
self.cross_beam.add_features(MillVolume(self.subtraction_volume()))
Expand Down
24 changes: 21 additions & 3 deletions src/compas_timber/connections/l_halflap.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,21 @@ class LHalfLapJoint(LapJoint):
def __init__(self, main_beam=None, cross_beam=None, flip_lap_side=False, cut_plane_bias=0.5, **kwargs):
super(LHalfLapJoint, self).__init__(main_beam, cross_beam, flip_lap_side, cut_plane_bias, **kwargs)

def add_features(self):
assert self.main_beam and self.cross_beam
def add_extensions(self):
"""Calculates and adds the necessary extensions to the beams.
This method is automatically called when joint is created by the call to `Joint.create()`.
Raises
------
BeamJoinningError
If the extension could not be calculated.
"""
assert self.main_beam and self.cross_beam
try:
main_cutting_frame = self.get_main_cutting_frame()
cross_cutting_frame = self.get_cross_cutting_frame()
negative_brep_main_beam, negative_brep_cross_beam = self._create_negative_volumes()
except Exception as ex:
raise BeamJoinningError(beams=self.beams, joint=self, debug_info=str(ex))

Expand All @@ -70,6 +78,16 @@ def add_features(self):
start_cross + extension_tolerance, end_cross + extension_tolerance, self.guid
)

def add_features(self):
assert self.main_beam and self.cross_beam

try:
main_cutting_frame = self.get_main_cutting_frame()
cross_cutting_frame = self.get_cross_cutting_frame()
negative_brep_main_beam, negative_brep_cross_beam = self._create_negative_volumes()
except Exception as ex:
raise BeamJoinningError(beams=self.beams, joint=self, debug_info=str(ex))

main_volume = MillVolume(negative_brep_main_beam)
cross_volume = MillVolume(negative_brep_cross_beam)

Expand Down
35 changes: 26 additions & 9 deletions src/compas_timber/connections/l_miter.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,18 @@ def get_cutting_planes(self):
plnB = Frame.from_plane(plnB)
return plnA, plnB

def add_features(self):
"""Adds the required extension and trimming features to both beams.
def add_extensions(self):
"""Calculates and adds the necessary extensions to the beams.
This method is automatically called when joint is created by the call to `Joint.create()`.
"""
assert self.beam_a and self.beam_b # should never happen

if self.features:
self.beam_a.remove_features(self.features)
self.beam_b.remove_features(self.features)
Raises
------
BeamJoinningError
If the extension could not be calculated.
"""
assert self.beam_a and self.beam_b
start_a, start_b = None, None
try:
plane_a, plane_b = self.get_cutting_planes()
Expand All @@ -121,9 +121,26 @@ def add_features(self):
raise BeamJoinningError(self.beams, self, debug_info=str(ae), debug_geometries=geometries)
except Exception as ex:
raise BeamJoinningError(self.beams, self, debug_info=str(ex))

self.beam_a.add_blank_extension(start_a, end_a, self.guid)
self.beam_b.add_blank_extension(start_b, end_b, self.guid)

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()`.
"""
assert self.beam_a and self.beam_b # should never happen

if self.features:
self.beam_a.remove_features(self.features)
self.beam_b.remove_features(self.features)

try:
plane_a, plane_b = self.get_cutting_planes()
except Exception as ex:
raise BeamJoinningError(self.beams, self, debug_info=str(ex))

f1, f2 = CutFeature(plane_a), CutFeature(plane_b)
self.beam_a.add_features(f1)
self.beam_b.add_features(f2)
Expand Down
27 changes: 23 additions & 4 deletions src/compas_timber/connections/t_butt.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,28 @@ def restore_beams_from_keys(self, model):
self.main_beam = model.beam_by_guid(self.main_beam_guid)
self.cross_beam = model.beam_by_guid(self.cross_beam_guid)

def add_extensions(self):
"""Calculates and adds the necessary extensions to the beams.
This method is automatically called when joint is created by the call to `Joint.create()`.
Raises
------
BeamJoinningError
If the extension could not be calculated.
"""
assert self.main_beam and self.cross_beam
try:
cutting_plane = self.get_main_cutting_plane()[0]
start_main, end_main = self.main_beam.extension_to_plane(cutting_plane)
except AttributeError as ae:
raise BeamJoinningError(beams=self.beams, joint=self, debug_info=str(ae), debug_geometries=[cutting_plane])
except Exception as ex:
raise BeamJoinningError(beams=self.beams, joint=self, debug_info=str(ex))
extension_tolerance = 0.01 # TODO: this should be proportional to the unit used
self.main_beam.add_blank_extension(start_main + extension_tolerance, end_main + extension_tolerance, self.guid)

def add_features(self):
"""Adds the trimming plane to the main beam (no features for the cross beam).
Expand All @@ -50,18 +72,15 @@ def add_features(self):

if self.features:
self.main_beam.remove_features(self.features)

cutting_plane = None
try:
cutting_plane = self.get_main_cutting_plane()[0]
start_main, end_main = self.main_beam.extension_to_plane(cutting_plane)
except AttributeError as ae:
raise BeamJoinningError(beams=self.beams, joint=self, debug_info=str(ae), debug_geometries=[cutting_plane])
except Exception as ex:
raise BeamJoinningError(beams=self.beams, joint=self, debug_info=str(ex))

extension_tolerance = 0.01 # TODO: this should be proportional to the unit used
self.main_beam.add_blank_extension(start_main + extension_tolerance, end_main + extension_tolerance, self.guid)

trim_feature = CutFeature(cutting_plane)
if self.mill_depth:
self.cross_beam.add_features(MillVolume(self.subtraction_volume()))
Expand Down
30 changes: 28 additions & 2 deletions src/compas_timber/connections/t_halflap.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,22 @@ class THalfLapJoint(LapJoint):
def __init__(self, main_beam=None, cross_beam=None, flip_lap_side=False, cut_plane_bias=0.5):
super(THalfLapJoint, self).__init__(main_beam, cross_beam, flip_lap_side, cut_plane_bias)

def add_features(self):
def add_extensions(self):
"""Calculates and adds the necessary extensions to the beams.
This method is automatically called when joint is created by the call to `Joint.create()`.
Raises
------
BeamJoinningError
If the extension could not be calculated.
"""
assert self.main_beam and self.cross_beam # should never happen

main_cutting_frame = None
try:
main_cutting_frame = self.get_main_cutting_frame()
negative_brep_main_beam, negative_brep_cross_beam = self._create_negative_volumes()
start_main, end_main = self.main_beam.extension_to_plane(main_cutting_frame)
except AttributeError as ae:
raise BeamJoinningError(
Expand All @@ -52,6 +61,23 @@ def add_features(self):
extension_tolerance = 0.01 # TODO: this should be proportional to the unit used
self.main_beam.add_blank_extension(start_main + extension_tolerance, end_main + extension_tolerance, self.guid)

def add_features(self):
assert self.main_beam and self.cross_beam # should never happen

if self.features:
self.main_beam.remove_features(self.features)

main_cutting_frame = None
try:
main_cutting_frame = self.get_main_cutting_frame()
negative_brep_main_beam, negative_brep_cross_beam = self._create_negative_volumes()
except AttributeError as ae:
raise BeamJoinningError(
beams=self.beams, joint=self, debug_info=str(ae), debug_geometries=[main_cutting_frame]
)
except Exception as ex:
raise BeamJoinningError(beams=self.beams, joint=self, debug_info=str(ex))

main_volume = MillVolume(negative_brep_main_beam)
cross_volume = MillVolume(negative_brep_cross_beam)
self.main_beam.add_features(main_volume)
Expand Down
6 changes: 3 additions & 3 deletions src/compas_timber/design/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ class FeatureDefinition(object):
"""

def __init__(self, feature, beams):
def __init__(self, feature, elements):
self.feature = feature
self.beams = beams
self.elements = elements

def __repr__(self):
return "{}({}, {})".format(FeatureDefinition.__name__, repr(self.feature), self.beams)
return "{}({}, {})".format(FeatureDefinition.__name__, repr(self.feature), self.elements)

def ToString(self):
return repr(self)
Expand Down
2 changes: 2 additions & 0 deletions src/compas_timber/elements/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .beam import Beam
from .plate import Plate
from .wall import Wall
from .features import BrepSubtraction
from .features import CutFeature
Expand All @@ -9,6 +10,7 @@
__all__ = [
"Wall",
"Beam",
"Plate",
"CutFeature",
"DrillFeature",
"MillVolume",
Expand Down
Loading

0 comments on commit 8a3da2d

Please sign in to comment.