2017-08-30 00:00:16 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
2019-03-23 04:13:18 +00:00
|
|
|
// LibFile: metric_screws.scad
|
|
|
|
// Screws, Bolts, and Nuts.
|
|
|
|
// To use, include the following lines at the top of your file:
|
|
|
|
// ```
|
2019-04-19 07:25:10 +00:00
|
|
|
// include <BOSL2/std.scad>
|
|
|
|
// include <BOSL2/metric_screws.scad>
|
2019-03-23 04:13:18 +00:00
|
|
|
// ```
|
2017-08-30 00:00:16 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
2019-05-03 19:19:51 +00:00
|
|
|
include <BOSL2/threading.scad>
|
|
|
|
include <BOSL2/phillips_drive.scad>
|
|
|
|
include <BOSL2/torx_drive.scad>
|
|
|
|
|
2018-11-19 23:24:44 +00:00
|
|
|
|
2019-03-23 04:13:18 +00:00
|
|
|
// Section: Functions
|
|
|
|
|
|
|
|
|
|
|
|
// Function: get_metric_bolt_head_size()
|
|
|
|
// Description: Returns the diameter of a typical metric bolt's head, based on the bolt `size`.
|
2017-08-30 00:00:16 +00:00
|
|
|
function get_metric_bolt_head_size(size) = lookup(size, [
|
2018-11-19 23:24:44 +00:00
|
|
|
[ 3.0, 5.5],
|
2017-08-30 00:00:16 +00:00
|
|
|
[ 4.0, 7.0],
|
|
|
|
[ 5.0, 8.0],
|
|
|
|
[ 6.0, 10.0],
|
|
|
|
[ 7.0, 11.0],
|
|
|
|
[ 8.0, 13.0],
|
2018-11-19 23:24:44 +00:00
|
|
|
[10.0, 17.0],
|
|
|
|
[12.0, 19.0],
|
|
|
|
[14.0, 22.0],
|
|
|
|
[16.0, 24.0],
|
|
|
|
[18.0, 27.0],
|
|
|
|
[20.0, 30.0],
|
|
|
|
[24.0, 36.0],
|
|
|
|
[30.0, 46.0],
|
|
|
|
[36.0, 55.0],
|
|
|
|
[42.0, 65.0],
|
|
|
|
[48.0, 75.0],
|
|
|
|
[56.0, 85.0],
|
|
|
|
[64.0, 95.0]
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
2019-03-23 04:13:18 +00:00
|
|
|
// Function: get_metric_bolt_head_height()
|
|
|
|
// Description: Returns the height of a typical metric bolt's head, based on the bolt `size`.
|
2018-11-19 23:24:44 +00:00
|
|
|
function get_metric_bolt_head_height(size) = lookup(size, [
|
|
|
|
[ 1.6, 1.23],
|
|
|
|
[ 2.0, 1.53],
|
|
|
|
[ 2.5, 1.83],
|
|
|
|
[ 3.0, 2.13],
|
|
|
|
[ 4.0, 2.93],
|
|
|
|
[ 5.0, 3.65],
|
|
|
|
[ 6.0, 4.15],
|
|
|
|
[ 8.0, 5.45],
|
|
|
|
[10.0, 6.58],
|
|
|
|
[12.0, 7.68],
|
|
|
|
[14.0, 8.98],
|
|
|
|
[16.0, 10.18],
|
|
|
|
[20.0, 12.72],
|
|
|
|
[24.0, 15.35],
|
|
|
|
[30.0, 19.12],
|
|
|
|
[36.0, 22.92],
|
|
|
|
[42.0, 26.42],
|
|
|
|
[48.0, 30.42],
|
|
|
|
[56.0, 35.50],
|
|
|
|
[64.0, 40.50]
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
2019-03-23 04:13:18 +00:00
|
|
|
// Function: get_metric_socket_cap_diam()
|
|
|
|
// Description: Returns the diameter of a typical metric socket cap bolt's head, based on the bolt `size`.
|
2018-11-19 23:24:44 +00:00
|
|
|
function get_metric_socket_cap_diam(size) = lookup(size, [
|
|
|
|
[ 1.6, 3.0],
|
|
|
|
[ 2.0, 3.8],
|
|
|
|
[ 2.5, 4.5],
|
|
|
|
[ 3.0, 5.5],
|
|
|
|
[ 4.0, 7.0],
|
|
|
|
[ 5.0, 8.5],
|
|
|
|
[ 6.0, 10.0],
|
|
|
|
[ 8.0, 13.0],
|
2017-08-30 00:00:16 +00:00
|
|
|
[10.0, 16.0],
|
|
|
|
[12.0, 18.0],
|
|
|
|
[14.0, 21.0],
|
|
|
|
[16.0, 24.0],
|
|
|
|
[18.0, 27.0],
|
2018-11-19 23:24:44 +00:00
|
|
|
[20.0, 30.0],
|
|
|
|
[22.0, 33.0],
|
|
|
|
[24.0, 36.0],
|
|
|
|
[27.0, 40.0],
|
|
|
|
[30.0, 45.0],
|
|
|
|
[33.0, 50.0],
|
|
|
|
[36.0, 54.0],
|
|
|
|
[42.0, 63.0],
|
|
|
|
[48.0, 72.0],
|
|
|
|
[56.0, 84.0],
|
|
|
|
[64.0, 96.0]
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
2019-03-23 04:13:18 +00:00
|
|
|
// Function: get_metric_socket_cap_height()
|
|
|
|
// Description: Returns the height of a typical metric socket cap bolt's head, based on the bolt `size`.
|
2018-11-19 23:24:44 +00:00
|
|
|
function get_metric_socket_cap_height(size) = lookup(size, [
|
|
|
|
[ 1.6, 1.7],
|
|
|
|
[ 2.0, 2.0],
|
|
|
|
[ 2.5, 2.5],
|
|
|
|
[ 3.0, 3.0],
|
|
|
|
[ 4.0, 4.0],
|
|
|
|
[ 5.0, 5.0],
|
|
|
|
[ 6.0, 6.0],
|
|
|
|
[ 8.0, 8.0],
|
|
|
|
[10.0, 10.0],
|
|
|
|
[12.0, 12.0],
|
|
|
|
[14.0, 14.0],
|
|
|
|
[16.0, 16.0],
|
|
|
|
[18.0, 18.0],
|
|
|
|
[20.0, 20.0],
|
|
|
|
[22.0, 22.0],
|
|
|
|
[24.0, 24.0],
|
|
|
|
[27.0, 27.0],
|
|
|
|
[30.0, 30.0],
|
|
|
|
[33.0, 33.0],
|
|
|
|
[36.0, 36.0],
|
|
|
|
[42.0, 42.0],
|
|
|
|
[48.0, 48.0],
|
|
|
|
[56.0, 56.0],
|
|
|
|
[64.0, 64.0]
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
2019-03-23 04:13:18 +00:00
|
|
|
// Function: get_metric_socket_cap_socket_size()
|
|
|
|
// Description: Returns the diameter of a typical metric socket cap bolt's hex drive socket, based on the bolt `size`.
|
2018-11-19 23:24:44 +00:00
|
|
|
function get_metric_socket_cap_socket_size(size) = lookup(size, [
|
|
|
|
[ 1.6, 1.5],
|
|
|
|
[ 2.0, 1.5],
|
|
|
|
[ 2.5, 2.0],
|
|
|
|
[ 3.0, 2.5],
|
|
|
|
[ 4.0, 3.0],
|
|
|
|
[ 5.0, 4.0],
|
|
|
|
[ 6.0, 5.0],
|
|
|
|
[ 8.0, 6.0],
|
|
|
|
[10.0, 8.0],
|
|
|
|
[12.0, 10.0],
|
|
|
|
[14.0, 12.0],
|
|
|
|
[16.0, 14.0],
|
|
|
|
[18.0, 14.0],
|
|
|
|
[20.0, 17.0],
|
|
|
|
[22.0, 17.0],
|
|
|
|
[24.0, 19.0],
|
|
|
|
[27.0, 19.0],
|
|
|
|
[30.0, 22.0],
|
|
|
|
[33.0, 24.0],
|
|
|
|
[36.0, 27.0],
|
|
|
|
[42.0, 32.0],
|
|
|
|
[48.0, 36.0],
|
|
|
|
[56.0, 41.0],
|
|
|
|
[64.0, 46.0]
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
2019-03-23 04:13:18 +00:00
|
|
|
// Function: get_metric_socket_cap_socket_depth()
|
|
|
|
// Description: Returns the depth of a typical metric socket cap bolt's hex drive socket, based on the bolt `size`.
|
2018-11-19 23:24:44 +00:00
|
|
|
function get_metric_socket_cap_socket_depth(size) = lookup(size, [
|
|
|
|
[ 1.6, 0.7],
|
|
|
|
[ 2.0, 1.0],
|
|
|
|
[ 2.5, 1.1],
|
|
|
|
[ 3.0, 1.3],
|
|
|
|
[ 4.0, 2.0],
|
|
|
|
[ 5.0, 2.5],
|
|
|
|
[ 6.0, 3.0],
|
|
|
|
[ 8.0, 4.0],
|
|
|
|
[10.0, 5.0],
|
|
|
|
[12.0, 6.0],
|
|
|
|
[14.0, 7.0],
|
|
|
|
[16.0, 8.0],
|
|
|
|
[18.0, 9.0],
|
|
|
|
[20.0, 10.0],
|
|
|
|
[22.0, 11.0],
|
|
|
|
[24.0, 12.0],
|
|
|
|
[27.0, 13.5],
|
|
|
|
[30.0, 15.5],
|
|
|
|
[33.0, 18.0],
|
|
|
|
[36.0, 19.0],
|
|
|
|
[42.0, 24.0],
|
|
|
|
[48.0, 28.0],
|
|
|
|
[56.0, 34.0],
|
|
|
|
[64.0, 38.0]
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
2019-03-23 04:13:18 +00:00
|
|
|
// Function: get_metric_iso_coarse_thread_pitch()
|
|
|
|
// Description: Returns the ISO metric standard coarse threading pitch for a given bolt `size`.
|
2018-11-19 23:24:44 +00:00
|
|
|
function get_metric_iso_coarse_thread_pitch(size) = lookup(size, [
|
|
|
|
[ 1.6, 0.35],
|
|
|
|
[ 2.0, 0.40],
|
|
|
|
[ 2.5, 0.45],
|
|
|
|
[ 3.0, 0.50],
|
|
|
|
[ 4.0, 0.70],
|
|
|
|
[ 5.0, 0.80],
|
|
|
|
[ 6.0, 1.00],
|
|
|
|
[ 7.0, 1.00],
|
|
|
|
[ 8.0, 1.25],
|
|
|
|
[10.0, 1.50],
|
|
|
|
[12.0, 1.75],
|
|
|
|
[14.0, 2.00],
|
|
|
|
[16.0, 2.00],
|
|
|
|
[18.0, 2.50],
|
|
|
|
[20.0, 2.50],
|
|
|
|
[22.0, 2.50],
|
|
|
|
[24.0, 3.00],
|
|
|
|
[27.0, 3.00],
|
|
|
|
[30.0, 3.50],
|
|
|
|
[33.0, 3.50],
|
|
|
|
[36.0, 4.00],
|
|
|
|
[39.0, 4.00],
|
|
|
|
[42.0, 4.50],
|
|
|
|
[45.0, 4.50],
|
|
|
|
[48.0, 5.00],
|
|
|
|
[56.0, 5.50],
|
|
|
|
[64.0, 6.00]
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
2019-03-23 04:13:18 +00:00
|
|
|
// Function: get_metric_iso_fine_thread_pitch()
|
|
|
|
// Description: Returns the ISO metric standard fine threading pitch for a given bolt `size`.
|
2018-11-19 23:24:44 +00:00
|
|
|
function get_metric_iso_fine_thread_pitch(size) = lookup(size, [
|
|
|
|
[ 1.6, 0.35],
|
|
|
|
[ 2.0, 0.40],
|
|
|
|
[ 2.5, 0.45],
|
|
|
|
[ 3.0, 0.50],
|
|
|
|
[ 4.0, 0.70],
|
|
|
|
[ 5.0, 0.80],
|
|
|
|
[ 6.0, 1.00],
|
|
|
|
[ 7.0, 1.00],
|
|
|
|
[ 8.0, 1.00],
|
|
|
|
[10.0, 1.25],
|
|
|
|
[12.0, 1.50],
|
|
|
|
[14.0, 1.50],
|
|
|
|
[16.0, 2.00],
|
|
|
|
[18.0, 2.50],
|
|
|
|
[20.0, 2.50],
|
|
|
|
[22.0, 2.50],
|
|
|
|
[24.0, 3.00],
|
|
|
|
[27.0, 3.00],
|
|
|
|
[30.0, 3.50],
|
|
|
|
[33.0, 3.50],
|
|
|
|
[36.0, 4.00],
|
|
|
|
[39.0, 4.00],
|
|
|
|
[42.0, 4.50],
|
|
|
|
[45.0, 4.50],
|
|
|
|
[48.0, 5.00],
|
|
|
|
[56.0, 5.50],
|
|
|
|
[64.0, 6.00]
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
2019-03-23 04:13:18 +00:00
|
|
|
// Function: get_metric_iso_superfine_thread_pitch()
|
|
|
|
// Description: Returns the ISO metric standard superfine threading pitch for a given bolt `size`.
|
2018-11-19 23:24:44 +00:00
|
|
|
function get_metric_iso_superfine_thread_pitch(size) = lookup(size, [
|
|
|
|
[ 1.6, 0.35],
|
|
|
|
[ 2.0, 0.40],
|
|
|
|
[ 2.5, 0.45],
|
|
|
|
[ 3.0, 0.50],
|
|
|
|
[ 4.0, 0.70],
|
|
|
|
[ 5.0, 0.80],
|
|
|
|
[ 6.0, 1.00],
|
|
|
|
[ 7.0, 1.00],
|
|
|
|
[ 8.0, 1.00],
|
|
|
|
[10.0, 1.00],
|
|
|
|
[12.0, 1.25],
|
|
|
|
[14.0, 1.50],
|
|
|
|
[16.0, 2.00],
|
|
|
|
[18.0, 2.50],
|
|
|
|
[20.0, 2.50],
|
|
|
|
[22.0, 2.50],
|
|
|
|
[24.0, 3.00],
|
|
|
|
[27.0, 3.00],
|
|
|
|
[30.0, 3.50],
|
|
|
|
[33.0, 3.50],
|
|
|
|
[36.0, 4.00],
|
|
|
|
[39.0, 4.00],
|
|
|
|
[42.0, 4.50],
|
|
|
|
[45.0, 4.50],
|
|
|
|
[48.0, 5.00],
|
|
|
|
[56.0, 5.50],
|
|
|
|
[64.0, 6.00]
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
2019-03-23 04:13:18 +00:00
|
|
|
// Function: get_metric_jis_thread_pitch()
|
|
|
|
// Description: Returns the JIS metric standard threading pitch for a given bolt `size`.
|
2018-11-19 23:24:44 +00:00
|
|
|
function get_metric_jis_thread_pitch(size) = lookup(size, [
|
|
|
|
[ 2.0, 0.40],
|
|
|
|
[ 2.5, 0.45],
|
|
|
|
[ 3.0, 0.50],
|
|
|
|
[ 4.0, 0.70],
|
|
|
|
[ 5.0, 0.80],
|
|
|
|
[ 6.0, 1.00],
|
|
|
|
[ 7.0, 1.00],
|
|
|
|
[ 8.0, 1.25],
|
|
|
|
[10.0, 1.25],
|
|
|
|
[12.0, 1.25],
|
|
|
|
[14.0, 1.50],
|
|
|
|
[16.0, 1.50],
|
|
|
|
[18.0, 1.50],
|
|
|
|
[20.0, 1.50]
|
2017-08-30 00:00:16 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
2019-03-23 04:13:18 +00:00
|
|
|
// Function: get_metric_nut_size()
|
|
|
|
// Description: Returns the typical metric nut flat-to-flat diameter for a given bolt `size`.
|
2017-08-30 00:00:16 +00:00
|
|
|
function get_metric_nut_size(size) = lookup(size, [
|
|
|
|
[ 2.0, 4.0],
|
|
|
|
[ 2.5, 5.0],
|
|
|
|
[ 3.0, 5.5],
|
|
|
|
[ 4.0, 7.0],
|
|
|
|
[ 5.0, 8.0],
|
|
|
|
[ 6.0, 10.0],
|
|
|
|
[ 7.0, 11.0],
|
|
|
|
[ 8.0, 13.0],
|
|
|
|
[10.0, 17.0],
|
|
|
|
[12.0, 19.0],
|
|
|
|
[14.0, 22.0],
|
|
|
|
[16.0, 24.0],
|
|
|
|
[18.0, 27.0],
|
2018-11-19 23:24:44 +00:00
|
|
|
[20.0, 30.0]
|
2017-08-30 00:00:16 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
2019-03-23 04:13:18 +00:00
|
|
|
// Function: get_metric_nut_thickness()
|
|
|
|
// Description: Returns the typical metric nut thickness for a given bolt `size`.
|
2017-08-30 00:00:16 +00:00
|
|
|
function get_metric_nut_thickness(size) = lookup(size, [
|
2018-11-19 23:24:44 +00:00
|
|
|
[ 1.6, 1.3],
|
2017-08-30 00:00:16 +00:00
|
|
|
[ 2.0, 1.6],
|
|
|
|
[ 2.5, 2.0],
|
|
|
|
[ 3.0, 2.4],
|
|
|
|
[ 4.0, 3.2],
|
|
|
|
[ 5.0, 4.0],
|
|
|
|
[ 6.0, 5.0],
|
|
|
|
[ 7.0, 5.5],
|
|
|
|
[ 8.0, 6.5],
|
|
|
|
[10.0, 8.0],
|
|
|
|
[12.0, 10.0],
|
|
|
|
[14.0, 11.0],
|
|
|
|
[16.0, 13.0],
|
|
|
|
[18.0, 15.0],
|
2018-11-19 23:24:44 +00:00
|
|
|
[20.0, 16.0],
|
|
|
|
[24.0, 21.5],
|
|
|
|
[30.0, 25.6],
|
|
|
|
[36.0, 31.0],
|
|
|
|
[42.0, 34.0],
|
|
|
|
[48.0, 38.0],
|
|
|
|
[56.0, 45.0],
|
|
|
|
[64.0, 51.0]
|
2017-08-30 00:00:16 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
2019-03-23 04:13:18 +00:00
|
|
|
|
|
|
|
// Section: Modules
|
|
|
|
|
|
|
|
|
|
|
|
// Module: screw()
|
|
|
|
// Description:
|
|
|
|
// Makes a very simple screw model, useful for making screwholes.
|
|
|
|
// Usage:
|
2019-05-26 20:45:22 +00:00
|
|
|
// screw(screwsize, screwlen, headsize, headlen)
|
2019-03-23 04:13:18 +00:00
|
|
|
// Arguments:
|
2017-08-30 00:00:16 +00:00
|
|
|
// screwsize = diameter of threaded part of screw.
|
|
|
|
// screwlen = length of threaded part of screw.
|
|
|
|
// headsize = diameter of the screw head.
|
|
|
|
// headlen = length of the screw head.
|
2019-05-26 19:47:50 +00:00
|
|
|
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#anchor). Default: `CENTER`
|
|
|
|
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#spin). Default: `0`
|
|
|
|
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#orient). Default: `UP`
|
2019-05-26 06:31:05 +00:00
|
|
|
// Extra Anchors:
|
|
|
|
// "base" = At the base of the head.
|
|
|
|
// "countersunk" = At the head height that would be just barely exposed when countersunk.
|
2019-03-23 04:13:18 +00:00
|
|
|
// Examples:
|
2019-05-26 06:31:05 +00:00
|
|
|
// screw(screwsize=3,screwlen=10,headsize=6,headlen=3, anchor="countersunk");
|
2019-04-23 03:55:03 +00:00
|
|
|
// screw(screwsize=3,screwlen=10,headsize=6,headlen=3, anchor="base");
|
|
|
|
// Example(FlatSpin): Standard Anchors
|
|
|
|
// screw(screwsize=3,screwlen=10,headsize=6,headlen=3)
|
|
|
|
// show_anchors(5, custom=false);
|
|
|
|
// Example(FlatSpin): Standard Anchors
|
2019-05-26 18:31:26 +00:00
|
|
|
// show_internal_anchors()
|
2019-04-23 03:55:03 +00:00
|
|
|
// screw(screwsize=3,screwlen=10,headsize=6,headlen=3)
|
|
|
|
// show_anchors(5, std=false);
|
2018-11-19 23:24:44 +00:00
|
|
|
module screw(
|
|
|
|
screwsize=3,
|
|
|
|
screwlen=10,
|
|
|
|
headsize=6,
|
|
|
|
headlen=3,
|
|
|
|
pitch=undef,
|
2019-05-26 06:31:05 +00:00
|
|
|
anchor="base",
|
|
|
|
spin=0,
|
|
|
|
orient=UP
|
2018-11-19 23:24:44 +00:00
|
|
|
) {
|
|
|
|
sides = max(12, segs(screwsize/2));
|
2019-04-23 03:55:03 +00:00
|
|
|
anchors = [
|
2019-05-26 06:31:05 +00:00
|
|
|
anchorpt("countersunk", [0,0,(headlen+screwlen)/2-0.01]),
|
|
|
|
anchorpt("base", [0,0,-headlen/2+screwlen/2])
|
2019-03-23 04:13:18 +00:00
|
|
|
];
|
2019-05-26 06:31:05 +00:00
|
|
|
orient_and_anchor([screwsize, screwsize, headlen+screwlen], orient, anchor, spin=spin, anchors=anchors, geometry="cylinder", chain=true) {
|
2019-03-23 04:13:18 +00:00
|
|
|
down(headlen/2-screwlen/2) {
|
|
|
|
down(screwlen/2) {
|
|
|
|
if (pitch == undef) {
|
|
|
|
cylinder(r=screwsize/2, h=screwlen+0.05, center=true, $fn=sides);
|
|
|
|
} else {
|
|
|
|
threaded_rod(d=screwsize, l=screwlen+0.05, pitch=pitch, $fn=sides);
|
|
|
|
}
|
2018-11-19 23:24:44 +00:00
|
|
|
}
|
2019-04-23 03:55:03 +00:00
|
|
|
cylinder(r=headsize/2, h=headlen, center=false, $fn=sides*2);
|
2018-11-19 23:24:44 +00:00
|
|
|
}
|
2019-04-20 00:02:17 +00:00
|
|
|
children();
|
2018-11-19 23:24:44 +00:00
|
|
|
}
|
2017-08-30 00:00:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-23 04:13:18 +00:00
|
|
|
// Module: metric_bolt()
|
|
|
|
// Description:
|
|
|
|
// Makes a standard metric screw model.
|
|
|
|
// Arguments:
|
|
|
|
// size = Diameter of threaded part of screw.
|
|
|
|
// headtype = One of `"hex"`, `"pan"`, `"button"`, `"round"`, `"countersunk"`, `"oval"`, `"socket`". Default: `"socket"`
|
|
|
|
// l = Length of screw, except for the head.
|
2018-11-19 23:24:44 +00:00
|
|
|
// shank = Length of unthreaded portion of the shaft.
|
2018-12-10 01:39:50 +00:00
|
|
|
// pitch = If given, render threads of the given pitch. If 0, then no threads. Overrides coarse argument.
|
2018-11-19 23:24:44 +00:00
|
|
|
// details = If true model should be rendered with extra details. (Default: false)
|
|
|
|
// coarse = If true, make coarse threads instead of fine threads. Default = true
|
2019-03-23 04:13:18 +00:00
|
|
|
// flange = Radius of flange beyond the head. Default = 0 (no flange)
|
2018-11-19 23:24:44 +00:00
|
|
|
// phillips = If given, the size of the phillips drive hole to add. (ie: "#1", "#2", or "#3")
|
2019-02-20 05:58:45 +00:00
|
|
|
// torx = If given, the size of the torx drive hole to add. (ie: 10, 20, 30, etc.)
|
2019-05-26 19:47:50 +00:00
|
|
|
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#anchor). Default: `CENTER`
|
|
|
|
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#spin). Default: `0`
|
|
|
|
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#orient). Default: `UP`
|
2019-05-26 06:31:05 +00:00
|
|
|
// Extra Anchors:
|
|
|
|
// "base" = At the base of the head.
|
|
|
|
// "countersunk" = At the head height that would be just barely exposed when countersunk.
|
|
|
|
// "shank" = At the bottom start of the unthreaded shank.
|
2019-03-23 04:13:18 +00:00
|
|
|
// Example: Bolt Head Types
|
|
|
|
// ydistribute(40) {
|
|
|
|
// xdistribute(30) {
|
|
|
|
// // Front Row, Left to Right
|
|
|
|
// metric_bolt(headtype="pan", size=10, l=15, details=true, phillips="#2");
|
|
|
|
// metric_bolt(headtype="button", size=10, l=15, details=true, phillips="#2");
|
|
|
|
// metric_bolt(headtype="round", size=10, l=15, details=true, phillips="#2");
|
|
|
|
// }
|
|
|
|
// xdistribute(30) {
|
|
|
|
// // Back Row, Left to Right
|
|
|
|
// metric_bolt(headtype="socket", size=10, l=15, details=true);
|
|
|
|
// metric_bolt(headtype="hex", size=10, l=15, details=true, phillips="#2");
|
|
|
|
// metric_bolt(headtype="countersunk", size=10, l=15, details=true, phillips="#2");
|
|
|
|
// metric_bolt(headtype="oval", size=10, l=15, details=true, phillips="#2");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// Example: Details
|
|
|
|
// metric_bolt(size=10, l=15, details=true, $fn=32);
|
|
|
|
// Example: No Details Except Threads
|
|
|
|
// metric_bolt(size=10, l=15);
|
|
|
|
// Example: No Details, No Threads
|
|
|
|
// metric_bolt(size=10, l=15, pitch=0);
|
|
|
|
// Example: Fine Threads
|
|
|
|
// metric_bolt(size=10, l=15, coarse=false);
|
|
|
|
// Example: Flange
|
|
|
|
// metric_bolt(size=10, l=15, flange=5);
|
|
|
|
// Example: Shank
|
|
|
|
// metric_bolt(size=10, l=25, shank=10);
|
|
|
|
// Example: Hex Head with Phillips
|
|
|
|
// metric_bolt(headtype="hex", size=10, l=15, phillips="#2");
|
|
|
|
// Example: Hex Head with Torx
|
|
|
|
// metric_bolt(headtype="hex", size=10, l=15, torx=50);
|
2019-04-23 03:55:03 +00:00
|
|
|
// Example(FlatSpin): Standard Anchors
|
|
|
|
// metric_bolt(headtype="oval", size=10, l=15, shank=5, details=true, phillips="#2")
|
|
|
|
// show_anchors(5, custom=false);
|
|
|
|
// Example(FlatSpin): Custom Anchors
|
2019-05-26 18:31:26 +00:00
|
|
|
// show_internal_anchors(0.125)
|
2019-04-23 03:55:03 +00:00
|
|
|
// metric_bolt(headtype="oval", size=10, l=15, shank=5, details=true, phillips="#2")
|
|
|
|
// show_anchors(5, std=false);
|
2018-11-19 23:24:44 +00:00
|
|
|
module metric_bolt(
|
|
|
|
headtype="socket",
|
|
|
|
size=3,
|
|
|
|
l=12,
|
|
|
|
shank=0,
|
|
|
|
pitch=undef,
|
|
|
|
details=false,
|
|
|
|
coarse=true,
|
|
|
|
phillips=undef,
|
2019-02-20 05:58:45 +00:00
|
|
|
torx=undef,
|
2019-03-23 04:13:18 +00:00
|
|
|
flange=0,
|
2019-05-26 06:31:05 +00:00
|
|
|
anchor="base",
|
|
|
|
spin=0,
|
|
|
|
orient=UP
|
2018-11-19 23:24:44 +00:00
|
|
|
) {
|
|
|
|
D = headtype != "hex"?
|
|
|
|
get_metric_socket_cap_diam(size) :
|
|
|
|
get_metric_bolt_head_size(size);
|
|
|
|
H = headtype == "socket"?
|
|
|
|
get_metric_socket_cap_height(size) :
|
|
|
|
get_metric_bolt_head_height(size);
|
|
|
|
P = coarse?
|
|
|
|
(pitch==undef? get_metric_iso_coarse_thread_pitch(size) : pitch) :
|
|
|
|
(pitch==undef? get_metric_iso_fine_thread_pitch(size) : pitch);
|
|
|
|
tlen = l - min(l, shank);
|
|
|
|
sides = max(12, segs(size/2));
|
|
|
|
tcirc = D/cos(30);
|
|
|
|
bevtop = (tcirc-D)/2;
|
|
|
|
bevbot = P/2;
|
|
|
|
|
2019-03-23 04:13:18 +00:00
|
|
|
headlen = (
|
|
|
|
(headtype == "pan" || headtype == "round" || headtype == "button")? H*0.75 :
|
|
|
|
(headtype == "countersunk")? (D-size)/2 :
|
|
|
|
(headtype == "oval")? ((D-size)/2 + D/2/3) :
|
|
|
|
H
|
|
|
|
);
|
|
|
|
base = l/2 - headlen/2;
|
|
|
|
sunklen = (
|
|
|
|
(headtype == "oval")? (D-size)/2 :
|
|
|
|
headlen-0.001
|
|
|
|
);
|
|
|
|
|
2019-04-23 03:55:03 +00:00
|
|
|
anchors = [
|
2019-05-26 06:31:05 +00:00
|
|
|
anchorpt("countersunk", [0,0,base+sunklen]),
|
2019-04-23 03:55:03 +00:00
|
|
|
anchorpt("base", [0,0,base]),
|
|
|
|
anchorpt("shank", [0,0,base-shank])
|
2019-03-23 04:13:18 +00:00
|
|
|
];
|
|
|
|
|
2019-04-23 03:55:03 +00:00
|
|
|
//color("silver")
|
2019-05-26 06:31:05 +00:00
|
|
|
orient_and_anchor([size, size, headlen+l], orient, anchor, spin=spin, geometry="cylinder", anchors=anchors, chain=true) {
|
2019-03-23 04:13:18 +00:00
|
|
|
up(base) {
|
|
|
|
difference() {
|
|
|
|
union() {
|
|
|
|
// Head
|
|
|
|
if (headtype == "hex") {
|
|
|
|
difference() {
|
2019-04-23 03:55:03 +00:00
|
|
|
cylinder(d=tcirc, h=H, $fn=6);
|
2019-03-23 04:13:18 +00:00
|
|
|
|
|
|
|
// Bevel hex nut top
|
|
|
|
if (details) {
|
|
|
|
up(H-bevtop) {
|
|
|
|
difference() {
|
2019-04-23 03:55:03 +00:00
|
|
|
cube([tcirc+1, tcirc+1, bevtop+0.5], anchor=BOTTOM);
|
2019-03-23 04:13:18 +00:00
|
|
|
down(0.01) cylinder(d1=tcirc, d2=tcirc-bevtop*2, h=bevtop+0.02, center=false);
|
|
|
|
}
|
2018-11-19 23:24:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-03-23 04:13:18 +00:00
|
|
|
} else if (headtype == "socket") {
|
|
|
|
sockw = get_metric_socket_cap_socket_size(size);
|
|
|
|
sockd = get_metric_socket_cap_socket_depth(size);
|
|
|
|
difference() {
|
2019-04-23 03:55:03 +00:00
|
|
|
cylinder(d=D, h=H);
|
|
|
|
up(H-sockd) cylinder(h=sockd+0.1, d=sockw/cos(30), $fn=6);
|
2019-03-23 04:13:18 +00:00
|
|
|
if (details) {
|
|
|
|
kcnt = 36;
|
2019-04-23 03:55:03 +00:00
|
|
|
zring(n=kcnt, r=D/2) up(H/3) cube([PI*D/kcnt/2, PI*D/kcnt/2, H], anchor=BOTTOM);
|
2019-03-23 04:13:18 +00:00
|
|
|
}
|
2018-11-19 23:24:44 +00:00
|
|
|
}
|
2019-03-23 04:13:18 +00:00
|
|
|
} else if (headtype == "pan") {
|
2019-04-25 02:42:38 +00:00
|
|
|
cyl(l=H*0.75, d=D, rounding2=H*0.75/2, anchor=DOWN);
|
2019-03-23 04:13:18 +00:00
|
|
|
} else if (headtype == "round") {
|
2019-04-23 03:55:03 +00:00
|
|
|
top_half(D) zscale(H*0.75/D*2) sphere(d=D);
|
2019-03-23 04:13:18 +00:00
|
|
|
} else if (headtype == "button") {
|
2019-04-23 03:55:03 +00:00
|
|
|
up(H*0.75/3) top_half(D) zscale(H*0.75*2/3/D*2) sphere(d=D);
|
2019-03-23 04:13:18 +00:00
|
|
|
cylinder(d=D, h=H*0.75/3+0.01, center=false);
|
|
|
|
} else if (headtype == "countersunk") {
|
2019-04-23 03:55:03 +00:00
|
|
|
cylinder(h=(D-size)/2, d1=size, d2=D);
|
2019-03-23 04:13:18 +00:00
|
|
|
} else if (headtype == "oval") {
|
2019-04-23 03:55:03 +00:00
|
|
|
up((D-size)/2) top_half(D) zscale(0.333) sphere(d=D);
|
|
|
|
cylinder(h=(D-size)/2, d1=size, d2=D);
|
2018-11-19 23:24:44 +00:00
|
|
|
}
|
|
|
|
|
2019-03-23 04:13:18 +00:00
|
|
|
// Flange
|
|
|
|
if (flange>0) {
|
|
|
|
up(headtype == "countersunk" || headtype == "oval"? (D-size)/2 : 0) {
|
|
|
|
cylinder(d=D+flange, h=H/8, center=false);
|
|
|
|
up(H/8) cylinder(d1=D+flange, d2=D, h=H/8, center=false);
|
|
|
|
}
|
2018-11-19 23:24:44 +00:00
|
|
|
}
|
|
|
|
|
2019-03-23 04:13:18 +00:00
|
|
|
// Unthreaded Shank
|
|
|
|
if (tlen < l) {
|
|
|
|
down(l-tlen) cylinder(d=size, h=l-tlen+0.05, center=false, $fn=sides);
|
|
|
|
}
|
2018-11-19 23:24:44 +00:00
|
|
|
|
2019-03-23 04:13:18 +00:00
|
|
|
// Threads
|
|
|
|
down(l) {
|
|
|
|
difference() {
|
|
|
|
up(tlen/2+0.05) {
|
|
|
|
if (tlen > 0) {
|
|
|
|
if (P > 0) {
|
|
|
|
threaded_rod(d=size, l=tlen+0.05, pitch=P, $fn=sides);
|
|
|
|
} else {
|
|
|
|
cylinder(d=size, h=tlen+0.05, $fn=sides, center=true);
|
|
|
|
}
|
2018-12-10 01:39:50 +00:00
|
|
|
}
|
|
|
|
}
|
2018-11-19 23:24:44 +00:00
|
|
|
|
2019-03-23 04:13:18 +00:00
|
|
|
// Bevel bottom end of threads
|
|
|
|
if (details) {
|
|
|
|
difference() {
|
2019-04-23 03:55:03 +00:00
|
|
|
down(0.5) cube([size+1, size+1, bevbot+0.5], anchor=BOTTOM);
|
2019-03-23 04:13:18 +00:00
|
|
|
cylinder(d1=size-bevbot*2, d2=size, h=bevbot+0.01, center=false);
|
|
|
|
}
|
2018-11-19 23:24:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-23 04:13:18 +00:00
|
|
|
// Phillips drive hole
|
|
|
|
if (headtype != "socket" && phillips != undef) {
|
|
|
|
down(headtype != "hex"? H/6 : 0) {
|
|
|
|
phillips_drive(size=phillips, shaft=D);
|
|
|
|
}
|
2018-11-19 23:24:44 +00:00
|
|
|
}
|
2019-02-20 05:58:45 +00:00
|
|
|
|
2019-03-23 04:13:18 +00:00
|
|
|
// Torx drive hole
|
|
|
|
if (headtype != "socket" && torx != undef) {
|
|
|
|
up(1) torx_drive(size=torx, l=H+0.1, center=false);
|
|
|
|
}
|
2019-02-20 05:58:45 +00:00
|
|
|
}
|
2018-11-19 23:24:44 +00:00
|
|
|
}
|
2019-04-20 00:02:17 +00:00
|
|
|
children();
|
2018-11-19 23:24:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-23 04:13:18 +00:00
|
|
|
// Module: metric_nut()
|
|
|
|
// Description:
|
|
|
|
// Makes a model of a standard nut for a standard metric screw.
|
|
|
|
// Arguments:
|
2017-08-30 00:00:16 +00:00
|
|
|
// size = standard metric screw size in mm. (Default: 3)
|
2018-11-19 23:24:44 +00:00
|
|
|
// hole = include the hole in the nut. (Default: true)
|
|
|
|
// pitch = pitch of threads in the hole. No threads if not given.
|
|
|
|
// flange = radius of flange beyond the head. Default = 0 (no flange)
|
|
|
|
// details = true if model should be rendered with extra details. (Default: false)
|
2019-05-26 19:47:50 +00:00
|
|
|
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#anchor). Default: `CENTER`
|
|
|
|
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#spin). Default: `0`
|
|
|
|
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#orient). Default: `UP`
|
2019-04-23 03:55:03 +00:00
|
|
|
// center = If true, centers the nut at the origin. If false, sits on top of XY plane. Overrides `anchor` if given.
|
2019-03-23 04:13:18 +00:00
|
|
|
// Example: No details, No Hole. Useful for a mask.
|
|
|
|
// metric_nut(size=10, hole=false);
|
|
|
|
// Example: Hole, with No Threads
|
|
|
|
// metric_nut(size=10, hole=true);
|
|
|
|
// Example: Threads
|
|
|
|
// metric_nut(size=10, hole=true, pitch=1.5);
|
|
|
|
// Example: Details
|
|
|
|
// metric_nut(size=10, hole=true, pitch=1.5, details=true);
|
|
|
|
// Example: Centered
|
|
|
|
// metric_nut(size=10, hole=true, pitch=1.5, details=true, center=true);
|
|
|
|
// Example: Flange
|
|
|
|
// metric_nut(size=10, hole=true, pitch=1.5, flange=3, details=true);
|
2018-11-19 23:24:44 +00:00
|
|
|
module metric_nut(
|
|
|
|
size=3,
|
|
|
|
hole=true,
|
|
|
|
pitch=undef,
|
|
|
|
details=false,
|
|
|
|
flange=0,
|
2019-03-23 04:13:18 +00:00
|
|
|
center=undef,
|
2019-05-26 06:31:05 +00:00
|
|
|
anchor=CENTER,
|
|
|
|
spin=0,
|
|
|
|
orient=UP
|
2018-11-19 23:24:44 +00:00
|
|
|
) {
|
|
|
|
H = get_metric_nut_thickness(size);
|
|
|
|
D = get_metric_nut_size(size);
|
|
|
|
boltfn = max(12, segs(size/2));
|
|
|
|
nutfn = max(12, segs(D/2));
|
|
|
|
dcirc = D/cos(30);
|
|
|
|
bevtop = (dcirc - D)/2;
|
2019-03-23 04:13:18 +00:00
|
|
|
|
2019-04-23 03:55:03 +00:00
|
|
|
//color("silver")
|
2019-05-26 06:31:05 +00:00
|
|
|
orient_and_anchor([dcirc+flange, dcirc+flange, H], orient, anchor, spin=spin, center=center, geometry="cylinder", chain=true) {
|
2018-11-19 23:24:44 +00:00
|
|
|
difference() {
|
|
|
|
union() {
|
|
|
|
difference() {
|
|
|
|
cylinder(d=dcirc, h=H, center=true, $fn=6);
|
|
|
|
if (details) {
|
|
|
|
up(H/2-bevtop) {
|
|
|
|
difference() {
|
2019-04-23 03:55:03 +00:00
|
|
|
cube([dcirc+1, dcirc+1, bevtop+0.5], anchor=BOTTOM);
|
2018-11-19 23:24:44 +00:00
|
|
|
down(0.01) cylinder(d1=dcirc, d2=dcirc-bevtop*2, h=bevtop+0.02, center=false, $fn=nutfn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (flange == 0) {
|
|
|
|
down(H/2) {
|
|
|
|
difference() {
|
2019-04-23 03:55:03 +00:00
|
|
|
down(0.5) cube([dcirc+1, dcirc+1, bevtop+0.5], anchor=BOTTOM);
|
2018-11-19 23:24:44 +00:00
|
|
|
down(0.01) cylinder(d1=dcirc-bevtop*2, d2=dcirc, h=bevtop+0.02, center=false, $fn=nutfn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (flange>0) {
|
|
|
|
down(H/2) {
|
|
|
|
cylinder(d=D+flange, h=H/8, center=false);
|
|
|
|
up(H/8) cylinder(d1=D+flange, d2=D, h=H/8, center=false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (hole == true) {
|
|
|
|
if (pitch == undef) {
|
|
|
|
cylinder(r=size/2, h=H+0.5, center=true, $fn=boltfn);
|
|
|
|
} else {
|
|
|
|
threaded_rod(d=size, l=H+0.5, pitch=pitch, $fn=boltfn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-20 00:02:17 +00:00
|
|
|
children();
|
2017-08-30 00:00:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|