Last active
February 6, 2016 03:57
-
-
Save hovissimo/ce5366a35834c3690488 to your computer and use it in GitHub Desktop.
Just a quick experiment in printing K'nex-compatible parts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Hovis's experiments in K'nex-compatible parts for home fabrication | |
* Author: Hovis Biddle | |
* Contact: [email protected] | |
* License: ISC | |
* Url: http://openjscad.org https://gist.github.com/hovissimo/ce5366a35834c3690488 | |
* | |
* All units in inches/degrees unless noted or obviously wrong. | |
* These models fit well on MY printer, which is almost certainly calibrated differently than your printer. | |
* Use at your own risk. | |
*/ | |
var shaft_radius = 0.127; | |
var shaft_hole_radius = 0.130; | |
var wall_thickness = 0.062; | |
var peg_insert_depth = 0.366; | |
var shaft_hole_to_peg_seat_radius = 0.369; // distance from center of connector to the outer limits of the coupler jaws | |
function frame_bounds() { | |
/* This shape is used to form the frame, and also to trim at the end of rendering. */ | |
return union( | |
cube({ | |
size: [peg_insert_depth + shaft_hole_to_peg_seat_radius, 2*shaft_radius + 2*wall_thickness, 2*shaft_radius ], | |
center: [ false, true, true ] | |
}), | |
CSG.cylinder({ | |
start: [ 0, 0, -shaft_radius ], | |
end: [ 0, 0, shaft_radius ], | |
radius: wall_thickness + shaft_radius, | |
}) | |
); | |
} | |
function knex_female_coupler() { | |
function frame() { | |
// The main structure of the female connector clamp | |
return difference( | |
frame_bounds(), | |
frame_cutter().translate([shaft_hole_to_peg_seat_radius, 0, 0]) | |
); | |
} | |
function frame_cutter() { | |
/* Subtracting this cutter shape from the frame_bounds forms a U shape. | |
* The legs of the U form the jaws of the connector. | |
*/ | |
return cube({ | |
size: [ peg_insert_depth, 2*shaft_radius, 2*shaft_radius ], | |
center: [ false, true, true ] | |
}); | |
} | |
function groove_bump() { | |
/* The groove bump is the cylindrical feature that is perpendicular to the joined peg near the base of the jaws. | |
* This feature serves to lock the peg at the right depth. | |
*/ | |
return cylinder({ | |
r: groove_bump_radius, | |
h: 2*shaft_radius, | |
center: true | |
}).rotateZ(90); | |
} | |
function capture_bump() { | |
/* These are the bumps in the "jaws" of the connector which have a parallel axis to the joined peg. | |
* These bumps serve to prevent the peg from sliding out of the jaws laterally. | |
*/ | |
return CSG.cylinder({ | |
start: [ height_to_groove_focus, 0, 0 ], | |
end: [ shaft_hole_to_peg_seat_radius + peg_insert_depth, 0, 0 ], | |
radius: capture_bump_radius | |
}); | |
} | |
function distance_to_capture_focus(offset) { | |
// calculate how far away from the origin the center of the capture bumps should be. | |
// Positive offset goes into the region between the jaws | |
return shaft_radius + capture_bump_radius - offset; | |
} | |
var capture_bump_radius = 0.120; | |
var capture_bump_offset_from_center = shaft_radius/2 + 0.015; | |
var radius_to_capture_focus = 0.202; | |
var capture_bump_protrusion = 0.013; | |
var groove_bump_radius = 0.076; | |
var radius_to_groove_focus = 0.166; | |
var height_to_groove_focus = 0.126 + shaft_hole_to_peg_seat_radius; | |
// add up all the parts! | |
return union( | |
frame(), | |
groove_bump().translate([ height_to_groove_focus, radius_to_groove_focus, 0]), | |
groove_bump().translate([ height_to_groove_focus, -radius_to_groove_focus, 0]), | |
capture_bump().translate([ | |
0, | |
-distance_to_capture_focus(capture_bump_protrusion), | |
capture_bump_offset_from_center, | |
]), | |
capture_bump().translate([ | |
0, | |
-distance_to_capture_focus(capture_bump_protrusion), | |
-capture_bump_offset_from_center, | |
]), | |
capture_bump().translate([ | |
0, | |
distance_to_capture_focus(capture_bump_protrusion), | |
capture_bump_offset_from_center, | |
]), | |
capture_bump().translate([ | |
0, | |
distance_to_capture_focus(capture_bump_protrusion), | |
-capture_bump_offset_from_center, | |
]) | |
).intersect(frame_bounds()); // trim to original frame dimensions | |
} | |
function main() { | |
return difference( | |
union( //positives | |
knex_female_coupler(), | |
knex_female_coupler().rotateZ(45), | |
knex_female_coupler().rotateZ(90) | |
), | |
union( //negatives | |
CSG.cylinder({ // perpendicular shaft_hole | |
start: [0, 0, shaft_radius], | |
end: [0, 0, -shaft_radius], | |
radius: shaft_hole_radius | |
}), | |
peg_cutter(), | |
peg_cutter().rotateZ(45), | |
peg_cutter().rotateZ(90) | |
) | |
).scale(25.4); // inches to mm | |
} | |
function peg_cutter() { | |
return difference( frame_bounds(), knex_female_coupler() ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment