Skip to content

Commit

Permalink
minor adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
papachap committed Oct 30, 2024
1 parent af6b6d5 commit 6c80b1a
Show file tree
Hide file tree
Showing 8 changed files with 9,630 additions and 17,531 deletions.
7,290 changes: 7,290 additions & 0 deletions examples/Grasshopper/tests/test_dovetail_joint.ghx

Large diffs are not rendered by default.

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions src/compas_timber/_fabrication/btlx_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,16 @@ class TenonShapeType(object):
Attributes
----------
STEP : literal("step")
A step shape.
HEEL : literal("heel")
A heel shape.
TAPERED_HEEL : literal("taperedheel")
A tapered heel shape.
DOUBLE : literal("double")
A double shape.
AUTOMATIC : literal("automatic")
Automatic tenon shape.
SQUARE : literal("square")
Square tenon shape.
ROUND : literal("round")
Round tenon shape.
ROUNDED : literal("rounded")
Rounded tenon shape.
RADIUS : literal("radius")
Radius tenon shape.
"""

AUTOMATIC = "automatic"
Expand Down
21 changes: 11 additions & 10 deletions src/compas_timber/_fabrication/dovetail_mortise.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class DovetailMortise(BTLxProcess):
PROCESS_NAME = "DovetailMortise" # type: ignore

# Class-level attribute
_dovetail_tool_params = {}
_DOVETAIL_TOOL_PARAMS = {}

@property
def __data__(self):
Expand All @@ -87,6 +87,7 @@ def __data__(self):
data["shape_radius"] = self.shape_radius
return data

# fmt: off
def __init__(
self,
start_x=0.0,
Expand Down Expand Up @@ -449,7 +450,7 @@ def _calculate_start_x(ref_side, ref_edge, cutting_frame):
########################################################################

@classmethod
def define_dovetail_tool(self, tool_angle, tool_diameter, tool_height):
def define_dovetail_tool(cls, tool_angle, tool_diameter, tool_height):
"""Define the parameters for the dovetail feature based on a defined dovetail cutting tool.
Parameters
Expand All @@ -463,7 +464,7 @@ def define_dovetail_tool(self, tool_angle, tool_diameter, tool_height):
"""
# type: (float, float, float) -> None
self._dovetail_tool_params = {
cls._DOVETAIL_TOOL_PARAMS = {
"tool_angle": tool_angle,
"tool_diameter": tool_diameter,
"tool_height": tool_height,
Expand Down Expand Up @@ -509,10 +510,10 @@ def apply(self, geometry, beam):
if (
self.shape != TenonShapeType.SQUARE and not self.length_limited_bottom
): # TODO: Change negation to affirmation once Brep.fillet is implemented
edge_ideces = [4, 7] if self.length_limited_bottom else [5, 8]
edge_idexes = [4, 7] if self.length_limited_bottom else [5, 8]
try:
dovetail_volume.fillet(
self.shape_radius, [dovetail_volume.edges[edge_ideces[0]], dovetail_volume.edges[edge_ideces[1]]]
self.shape_radius, [dovetail_volume.edges[edge_idexes[0]], dovetail_volume.edges[edge_idexes[1]]]
) # TODO: NotImplementedError
except Exception as e:
raise FeatureApplicationError(
Expand Down Expand Up @@ -562,8 +563,8 @@ def frame_from_params_and_beam(self, beam):

return cutting_frame

def dovetail_cutting_planes_from_params_and_beam(self, beam):
"""Calculates the cutting planes for the dovetail mortise from the machining parameters in this instance and the given beam.
def dovetail_cutting_frames_from_params_and_beam(self, beam):
"""Calculates the cutting frames for the dovetail mortise from the machining parameters in this instance and the given beam.
Parameters
----------
Expand All @@ -573,7 +574,7 @@ def dovetail_cutting_planes_from_params_and_beam(self, beam):
Returns
-------
list of :class:`compas.geometry.Frame`
The cutting planes for the dovetail mortise.
The cutting frames for the dovetail mortise.
"""
assert self.angle is not None
assert self.depth is not None
Expand Down Expand Up @@ -667,8 +668,8 @@ def dovetail_volume_from_params_and_beam(self, beam):
)
)

# get the cutting planes for the dovetail tenon
trimming_frames = self.dovetail_cutting_planes_from_params_and_beam(beam)
# get the cutting frames for the dovetail tenon
trimming_frames = self.dovetail_cutting_frames_from_params_and_beam(beam)

# trim the box to create the dovetail volume
for frame in trimming_frames:
Expand Down
33 changes: 17 additions & 16 deletions src/compas_timber/_fabrication/dovetail_tenon.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class DovetailTenon(BTLxProcess):
PROCESS_NAME = "DovetailTenon" # type: ignore

# Class-level attribute
_dovetail_tool_params = {}
_DOVETAIL_TOOL_PARAMS = {}

@property
def __data__(self):
Expand All @@ -91,6 +91,7 @@ def __data__(self):
data["shape_radius"] = self.shape_radius
return data

# fmt: off
def __init__(
self,
orientation,
Expand Down Expand Up @@ -392,11 +393,11 @@ def from_plane_and_beam(
"""
# type: (Plane|Frame, Beam, float, float, bool, int) -> DovetailTenon

if cls._dovetail_tool_params:
if cls._DOVETAIL_TOOL_PARAMS:
# get the tool parameters
tool_angle = cls._dovetail_tool_params["tool_angle"]
tool_diameter = cls._dovetail_tool_params["tool_diameter"]
tool_height = cls._dovetail_tool_params["tool_height"]
tool_angle = cls._DOVETAIL_TOOL_PARAMS["tool_angle"]
tool_diameter = cls._DOVETAIL_TOOL_PARAMS["tool_diameter"]
tool_height = cls._DOVETAIL_TOOL_PARAMS["tool_height"]
tool_top_radius = tool_diameter / 2 - tool_height * (math.tan(math.radians(tool_angle)))
# update parameters related to the tool if a tool is defined
height = min(height, tool_height)
Expand Down Expand Up @@ -569,7 +570,7 @@ def _bound_start_depth(start_depth, inclination, height):
########################################################################

@classmethod
def define_dovetail_tool(self, tool_angle, tool_diameter, tool_height):
def define_dovetail_tool(cls, tool_angle, tool_diameter, tool_height):
"""Define the parameters for the dovetail feature based on a defined dovetail cutting tool.
Parameters
Expand All @@ -583,7 +584,7 @@ def define_dovetail_tool(self, tool_angle, tool_diameter, tool_height):
"""
# type: (float, float, float) -> None
self._dovetail_tool_params = {
cls._DOVETAIL_TOOL_PARAMS = {
"tool_angle": tool_angle,
"tool_diameter": tool_diameter,
"tool_height": tool_height,
Expand All @@ -607,7 +608,7 @@ def apply(self, geometry, beam):
Raises
------
:class:`~compas_timber.elements.FeatureApplicationError`
If the cutting planes do not create a volume that itersects with beam geometry or any step fails.
If the cutting frames do not create a volume that itersects with beam geometry or any step fails.
Returns
-------
Expand All @@ -622,7 +623,7 @@ def apply(self, geometry, beam):
cutting_plane = Plane.from_frame(self.frame_from_params_and_beam(beam))
except ValueError as e:
raise FeatureApplicationError(
None, geometry, "Failed to generate cutting plane from parameters and beam: {}".format(str(e))
None, geometry, "Failed to generate cutting frame from parameters and beam: {}".format(str(e))
)

# get dovetail volume from params and beam
Expand All @@ -637,10 +638,10 @@ def apply(self, geometry, beam):
if (
self.shape != TenonShapeType.SQUARE and not self.length_limited_bottom
): # TODO: Change negation to affirmation once Brep.fillet is implemented
edge_ideces = [4, 7] if self.length_limited_top else [5, 8]
edge_idexes = [4, 7] if self.length_limited_top else [5, 8]
try:
dovetail_volume.fillet(
self.shape_radius, [dovetail_volume.edges[edge_ideces[0]], dovetail_volume.edges[edge_ideces[1]]]
self.shape_radius, [dovetail_volume.edges[edge_idexes[0]], dovetail_volume.edges[edge_idexes[1]]]
) # TODO: NotImplementedError
except Exception as e:
raise FeatureApplicationError(
Expand Down Expand Up @@ -723,8 +724,8 @@ def frame_from_params_and_beam(self, beam):

return cutting_frame

def dovetail_cutting_planes_from_params_and_beam(self, beam):
"""Calculates the cutting planes for the dovetail tenon from the machining parameters in this instance and the given beam."""
def dovetail_cutting_frames_from_params_and_beam(self, beam):
"""Calculates the cutting frames for the dovetail tenon from the machining parameters in this instance and the given beam."""

# get the cutting frame
cutting_frame = self.frame_from_params_and_beam(beam)
Expand Down Expand Up @@ -814,16 +815,16 @@ def dovetail_volume_from_params_and_beam(self, beam):
)
)

# get the cutting planes for the dovetail tenon
trimming_frames = self.dovetail_cutting_planes_from_params_and_beam(beam)
# get the cutting frames for the dovetail tenon
trimming_frames = self.dovetail_cutting_frames_from_params_and_beam(beam)

# trim the box to create the dovetail volume
for frame in trimming_frames:
try:
dovetail_volume.trim(frame)
except Exception as e:
raise FeatureApplicationError(
frame, dovetail_volume, "Failed to trim tenon volume with cutting plane: {}".format(str(e))
frame, dovetail_volume, "Failed to trim tenon volume with cutting frame: {}".format(str(e))
)

return dovetail_volume
Expand Down
1 change: 1 addition & 0 deletions src/compas_timber/_fabrication/step_joint.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def __data__(self):
data["tenon_height"] = self.tenon_height
return data

# fmt: off
def __init__(
self,
orientation,
Expand Down
1 change: 1 addition & 0 deletions src/compas_timber/_fabrication/step_joint_notch.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def __data__(self):
data["mortise_height"] = self.mortise_height
return data

# fmt: off
def __init__(
self,
orientation,
Expand Down
Loading

0 comments on commit 6c80b1a

Please sign in to comment.