FingerJointEdges: Better deal with short edges

Shrink surroundingspaces when need to still fit at least one finger. If
even one regular finger won't fit use a small rectangular style finger.

This is a bit hacky as the same logic is copied in both
FingerJointEdge and FingerHoles
This commit is contained in:
Florian Festi 2022-09-25 14:00:28 +02:00
parent 0745ec4695
commit d782eb281c
2 changed files with 25 additions and 5 deletions

View File

@ -833,7 +833,7 @@ Values:
* absolute * absolute
* style : "rectangular" : style of the fingers * style : "rectangular" : style of the fingers
* surroundingspaces : 2.0 : minimal space at the start and end in multiple of normal spaces * surroundingspaces : 2.0 : space at the start and end in multiple of normal spaces
* angle: 90 : Angle of the walls meeting * angle: 90 : Angle of the walls meeting
* relative (in multiples of thickness) * relative (in multiples of thickness)
@ -878,6 +878,9 @@ class FingerJointBase:
space, finger = self.settings.space, self.settings.finger space, finger = self.settings.space, self.settings.finger
fingers = int((length - (self.settings.surroundingspaces - 1) * space) // fingers = int((length - (self.settings.surroundingspaces - 1) * space) //
(space + finger)) (space + finger))
# shrink surrounding space up to half a thickness each side
if fingers == 0 and length > finger + 1.0 * self.settings.thickness:
fingers = 1
if not finger: if not finger:
fingers = 0 fingers = 0
if bedBolts: if bedBolts:
@ -955,12 +958,22 @@ class FingerJointEdge(BaseEdge, FingerJointBase):
positive = self.positive positive = self.positive
t = self.settings.thickness t = self.settings.thickness
s, f, thickness = self.settings.space, self.settings.finger, self.settings.thickness s, f = self.settings.space, self.settings.finger
thickness = self.settings.thickness
style = self.settings.style
play = self.settings.play
fingers, leftover = self.calcFingers(length, bedBolts) fingers, leftover = self.calcFingers(length, bedBolts)
# not enough space for normal fingers - use small rectangular one
if (fingers == 0 and f and
leftover > 0.75*thickness and leftover > 4*play):
fingers = 1
f = leftover = leftover / 2.0
bedBolts = None
style = "rectangular"
if not positive: if not positive:
play = self.settings.play
f += play f += play
s -= play s -= play
leftover -= play leftover -= play
@ -982,7 +995,7 @@ class FingerJointEdge(BaseEdge, FingerJointBase):
self.bedBoltHole(s, bedBoltSettings) self.bedBoltHole(s, bedBoltSettings)
else: else:
self.edge(s) self.edge(s)
self.draw_finger(f, h, self.settings.style, self.draw_finger(f, h, style,
positive, i < fingers//2) positive, i < fingers//2)
self.edge(leftover / 2.0, tabs=1) self.edge(leftover / 2.0, tabs=1)
@ -1036,6 +1049,13 @@ class FingerHoles(FingerJointBase):
b = self.boxes.burn b = self.boxes.burn
fingers, leftover = self.calcFingers(length, bedBolts) fingers, leftover = self.calcFingers(length, bedBolts)
# not enough space for normal fingers - use small rectangular one
if (fingers == 0 and f and
leftover > 0.75*self.settings.thickness and leftover > 4*p):
fingers = 1
f = leftover = leftover / 2.0
bedBolts = None
if self.boxes.debug: if self.boxes.debug:
self.ctx.rectangle(b, -self.settings.width / 2 + b, self.ctx.rectangle(b, -self.settings.width / 2 + b,
length - 2 * b, self.settings.width - 2 * b) length - 2 * b, self.settings.width - 2 * b)

View File

@ -199,7 +199,7 @@ Finger Joint Settings
width of the spaces between fingers in multiples of the thickness width of the spaces between fingers in multiples of the thickness
surroundingspaces surroundingspaces
minimal amount of space before the first and after the last finger. This is in multiples of regular space between fingers. Reduce this if there are no fingers fitting on short edges. amount of space before the first and after the last finger. This is in multiples of regular space between fingers. The actual space is larger when needed but can be smaller for very short edges.
style style
how finger joints should look like. There may be more styles to choose from in the future. Note that snap fingers will only be drawn for fingers of width 1.9 and above. how finger joints should look like. There may be more styles to choose from in the future. Note that snap fingers will only be drawn for fingers of width 1.9 and above.