Skip to content

Commit

Permalink
Detached male joints for added strength (#51)
Browse files Browse the repository at this point in the history
Add support for detached male joints, which can be printed horizontally for added strength.

The detached joints can be rendered manually or by setting $detached_joints = true (which can be used in combination with $auto_layout = true).
  • Loading branch information
aaron-siegel authored Apr 13, 2022
1 parent 18cc9c2 commit 90fa872
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 3 deletions.
30 changes: 30 additions & 0 deletions src/main/scad/puzzlecad-examples.scad
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,32 @@ include <puzzlecad.scad>
// print it with a smooth surface that maintains a clean, accurate fit. Combining these techniques
// provides a great deal of flexibility in how the puzzle joints are laid out.

// ======================================
// DETACHED CONNECTORS

// puzzlecad 2.3 introduces an option to print "detached" male connectors. This is most easily
// demonstrated with an example:

*burr_plate([["x..|xxx{connect=mz+y+,clabel=A}"], ["x{connect=fz+y+,clabel=A}|x"]],
$detached_joints = true);

// Note this is identical to the first example from the previous section; the only difference is
// that we set $detached_joints = true. Instead of a male joint, puzzlecad renders "connect=mz+y+"
// as a second female joint, and separately generates a strut that can be used to connect them.

// The advantage of using detached joints is that the connectors are printed horizontally, making
// them substantially stronger. This is particularly useful in applications involving complex
// pieces with sensitive connection points.

// $detached_joints can also be used in combination with $auto_layout; here is the same piece
// rendered with both $auto_layout = true and $detached_joints = true:

*burr_piece(["x..|xxx|...", "...|..x|..x"], $auto_layout = true, $detached_joints = true);

// If you want to manually generate an individual connector, use detached_male_connector():

*detached_male_connector();

// ======================================
// SQUARE CONNECTORS

Expand All @@ -234,11 +260,15 @@ include <puzzlecad.scad>
// puzzlecad, but they're still there if you want to use them.

// To render a square snap joint, simply omit the second orientation coordinate. Like so:

*burr_plate([["x..|xxx{connect=mz+,clabel=Ay-}"], ["x{connect=fz+,clabel=Ay-}|x"]]);

// Note that you now have to specify an orientation for the clabel; the square connectors are
// symmetric, so it's otherwise ambiguous where to render the label.

// NOTE: As of puzzlecad 2.3, square connectors are deprecated, and various new features (such
// as detached joints) will not work properly with them.

// ======================================
// LABELS

Expand Down
1 change: 1 addition & 0 deletions src/main/scad/puzzlecad.scad
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ $diag_joint_position = 0.1;

$unit_beveled = false;
$auto_layout = false;
$detached_joints = false;
$post_rotate = [0, 0, 0];

// Optional parameters that can be used to increase
Expand Down
36 changes: 33 additions & 3 deletions src/main/scad/puzzlecad/puzzlecad-burr.scad
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@ module burr_plate(burr_specs, num_copies = 1) {

burr_plate_r(expanded_burr_infos);

if ($detached_joints) {
// If using $detached_joints, we need to render the detached joints separately.
male_joint_count = sum([
for (burr_info = expanded_burr_infos, layer = burr_info, row = layer, voxel = row)
let (connect = lookup_kv(voxel[1], "connect"))
connect[0] == "m" ? 1 : 0
]);
if (male_joint_count > 0) {
for (i = [0:male_joint_count-1]) {
translate([(i + 0.5) * $burr_scale, -1 * ($burr_scale / 2 + $plate_sep), 0])
detached_male_connector();
}
}
}

}

module burr_plate_r(burr_infos, i = 0, y = 0, x = 0, row_depth = 0) {
Expand Down Expand Up @@ -227,9 +242,10 @@ module burr_piece_base(burr_spec, test_poly = undef) {

translate(cw(scale_vec, [x,y,z])) {

if (connect[0] == "m")
if (connect[0] == "m" && !$detached_joints)
male_connector_cutout(orient);
else if (connect[0] == "f")
else if (connect[0] == "f" || connect[0] == "m")
// If using $detached_joints, we also render "m" connectors as "f"
female_connector(orient, clabel[0], substr(clabel, 1, 2));
else if (connect[0] == "d" && connect[1] == "m")
male_diag_snap_connector_cutout(orient, twist = connect[6] == "~");
Expand Down Expand Up @@ -320,7 +336,7 @@ module burr_piece_base(burr_spec, test_poly = undef) {
connect = connect_list[i];
clabel = clabel_list[i];

if (connect[0] == "m") {
if (connect[0] == "m" && !$detached_joints) {
translate(cw(scale_vec, [x, y, z]))
male_connector(substr(connect, 1, 4), clabel[0], substr(clabel, 1, 2));
} else if (connect[0] == "d" && connect[1] == "m") {
Expand Down Expand Up @@ -743,6 +759,20 @@ module male_connector(orient, label, explicit_label_orient) {

}

module detached_male_connector() {

size = $burr_scale * 2/3 - $burr_inset * 2 - $joint_inset * 2;
total_length = size - 0.35;
translate([0, 0, size / 2])
rotate([90, 0, 0]) {
tapered_pentagon([size, size, total_length], center = false, clipped = true);
translate([0, 0, iota])
mirror([0, 0, 1])
tapered_pentagon([size, size, total_length], center = false, clipped = true);
}

}

module female_diag_snap_connector(orient, label, twist = false) {

rot = cube_face_rotation(orient);
Expand Down

0 comments on commit 90fa872

Please sign in to comment.