|
|
@ -1,8 +1,17 @@
|
|
|
|
include<std.scad>
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
include<structs.scad>
|
|
|
|
// LibFile: screws.scad
|
|
|
|
include<threading.scad>
|
|
|
|
// Functions and modules for creating metric and UTS standard screws and nuts.
|
|
|
|
include<phillips_drive.scad>
|
|
|
|
// To use, add the following lines to the beginning of your file:
|
|
|
|
include<torx_drive.scad>
|
|
|
|
// ```
|
|
|
|
|
|
|
|
// include <BOSL2/std.scad>
|
|
|
|
|
|
|
|
// include <BOSL2/screws.scad>
|
|
|
|
|
|
|
|
// ```
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
include <structs.scad>
|
|
|
|
|
|
|
|
include <threading.scad>
|
|
|
|
|
|
|
|
include <phillips_drive.scad>
|
|
|
|
|
|
|
|
include <torx_drive.scad>
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
http://mdmetric.com/thddata.htm#idx
|
|
|
|
http://mdmetric.com/thddata.htm#idx
|
|
|
@ -16,7 +25,7 @@ Torx values: https://www.stanleyengineeredfastening.com/-/media/web/sef/resourc
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
function parse_screw_name(name) =
|
|
|
|
function _parse_screw_name(name) =
|
|
|
|
let( commasplit = str_split(name,","),
|
|
|
|
let( commasplit = str_split(name,","),
|
|
|
|
length = str_num(commasplit[1]),
|
|
|
|
length = str_num(commasplit[1]),
|
|
|
|
xdash = str_split(commasplit[0], "-x"),
|
|
|
|
xdash = str_split(commasplit[0], "-x"),
|
|
|
@ -30,12 +39,12 @@ function parse_screw_name(name) =
|
|
|
|
let(val=str_num(type))
|
|
|
|
let(val=str_num(type))
|
|
|
|
val == floor(val) && val>=0 && val<=12 ? str("#",type) : val
|
|
|
|
val == floor(val) && val>=0 && val<=12 ? str("#",type) : val
|
|
|
|
)
|
|
|
|
)
|
|
|
|
["english", diam, thread, 25.4*length];
|
|
|
|
["english", diam, thread, 25.4*length];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// drive can be "hex", "phillips", "slot", "torx", or "none"
|
|
|
|
// drive can be "hex", "phillips", "slot", "torx", or "none"
|
|
|
|
// or you can specify "ph0" up to "ph4" for phillips and "t20" for torx 20
|
|
|
|
// or you can specify "ph0" up to "ph4" for phillips and "t20" for torx 20
|
|
|
|
function parse_drive(drive=undef, drive_size=undef) =
|
|
|
|
function _parse_drive(drive=undef, drive_size=undef) =
|
|
|
|
is_undef(drive) ? ["none",undef] :
|
|
|
|
is_undef(drive) ? ["none",undef] :
|
|
|
|
let(drive = downcase(drive))
|
|
|
|
let(drive = downcase(drive))
|
|
|
|
in_list(drive,["hex","phillips", "slot", "torx", "phillips", "none"]) ? [drive, drive_size] :
|
|
|
|
in_list(drive,["hex","phillips", "slot", "torx", "phillips", "none"]) ? [drive, drive_size] :
|
|
|
@ -43,116 +52,102 @@ function parse_drive(drive=undef, drive_size=undef) =
|
|
|
|
substr(drive,0,2)=="ph" ? ["phillips", str_int(substr(drive,2))] :
|
|
|
|
substr(drive,0,2)=="ph" ? ["phillips", str_int(substr(drive,2))] :
|
|
|
|
assert(str("Unknown screw drive type ",drive));
|
|
|
|
assert(str("Unknown screw drive type ",drive));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Function: screw_info()
|
|
|
|
// Function: screw_info()
|
|
|
|
// Usage:
|
|
|
|
// Usage:
|
|
|
|
// info = screw_info(name, [head], [thread], [drive], [drive_size], [oversize])
|
|
|
|
// info = screw_info(name, [head], [thread], [drive], [drive_size], [oversize])
|
|
|
|
|
|
|
|
//
|
|
|
|
// Description:
|
|
|
|
// Description:
|
|
|
|
// Look up screw characteristics for the specified screw type.
|
|
|
|
// Look up screw characteristics for the specified screw type.
|
|
|
|
//
|
|
|
|
// .
|
|
|
|
// For metric (ISO) `name` is M<size>x<pitch>,<length>, e.g. `"M6x1,10"` specifies a 6mm diameter screw with a thread pitch of 1mm and length of 10mm.
|
|
|
|
// For metric (ISO) the `name=` argument is formatted in a string like: `"M<size>x<pitch>,<length>"`.
|
|
|
|
// You can omit the pitch or length, e.g. `"M6x1"`, or `"M6,10"`, or just `"M6"`.
|
|
|
|
// e.g. `"M6x1,10"` specifies a 6mm diameter screw with a thread pitch of 1mm and length of 10mm.
|
|
|
|
//
|
|
|
|
// You can omit the pitch or length, e.g. `"M6x1"`, or `"M6,10"`, or just `"M6"`.
|
|
|
|
// For English (UTS) name is <size>-<threadcount>,<length>, e.g. `"#8-32,1/2"`, or `"1/4-20,1"`. Units are in inches, including the length.
|
|
|
|
// .
|
|
|
|
// Size can be a number from 0 to 12 with or without a leading '#' to specify a screw gauge size, or any other value to specify
|
|
|
|
// For English (UTS) `name=` is a string like `"<size>-<threadcount>,<length>"`.
|
|
|
|
// a diameter in inches, either as a float or a fraction, so `"0.5-13"` and `"1/2-13"` are equivalent. To force interpretation of the value
|
|
|
|
// e.g. `"#8-32,1/2"`, or `"1/4-20,1"`. Units are in inches, including the length. Size can be a
|
|
|
|
// as inches add `''` to the end, e.g. `"1''-4"` is a one inch screw and `"1-80"` is a very small 1-gauge screw. The pitch is specified
|
|
|
|
// number from 0 to 12 with or without a leading `#` to specify a screw gauge size, or any other
|
|
|
|
// using a thread count, the number of threads per inch. The length is in inches.
|
|
|
|
// value to specify a diameter in inches, either as a float or a fraction, so `"0.5-13"` and
|
|
|
|
//
|
|
|
|
// `"1/2-13"` are equivalent. To force interpretation of the value as inches add `''` (two
|
|
|
|
// If you omit the pitch then a standard screw pitch will be supplied from lookup tables for the screw diameter you have chosen.
|
|
|
|
// single-quotes) to the end, e.g. `"1''-4"` is a one inch screw and `"1-80"` is a very small
|
|
|
|
// For each screw diameter, multiple standard pitches are possible.
|
|
|
|
// 1-gauge screw. The pitch is specified using a thread count, the number of threads per inch.
|
|
|
|
// For the UTS system these the availble thread types are:
|
|
|
|
// The length is in inches.
|
|
|
|
// - "coarse" or "UNC"
|
|
|
|
// .
|
|
|
|
// - "fine" or "UNF"
|
|
|
|
// If you omit the pitch then a standard screw pitch will be supplied from lookup tables for the
|
|
|
|
// - "extra fine", "extrafine" or "UNEF".
|
|
|
|
// screw diameter you have chosen. For each screw diameter, multiple standard pitches are possible.
|
|
|
|
// The ISO system defines a coarse threading and three different fine threadings but does not give different names to the fine threadings.
|
|
|
|
// The available thread pitch types are:
|
|
|
|
// The thread options for ISO are:
|
|
|
|
// - `"coarse"`
|
|
|
|
// - "coarse"
|
|
|
|
// - `"fine"`
|
|
|
|
// - "fine"
|
|
|
|
// - `"extrafine"` or `"extra fine"`
|
|
|
|
// - "extra fine" or "extrafine"
|
|
|
|
// - `"superfine"` or `"super fine"` (Metric/ISO only.)
|
|
|
|
// - "super fine" or "superfine"
|
|
|
|
// - `"UNC"` (English/UTS only. Same as `"coarse"`.)
|
|
|
|
// The default pitch selection is "coarse". Note that this selection is case independent. Set
|
|
|
|
// - `"UNF"` (English/UTS only. Same as `"fine"`.)
|
|
|
|
// `thread` to one of these values to choose a different pitch. Note that not every pitch category is defined at every
|
|
|
|
// - `"UNEF"` (English/UTS only. Same as `"extrafine"`.)
|
|
|
|
// diameter. You can also specify the thread pitch directly, for example you could set `thread=2` which would
|
|
|
|
// .
|
|
|
|
// produce threads with a pitch of 2mm. The final option is to specify `thread="none"` to produce an unthreaded
|
|
|
|
// The default pitch selection is `"coarse"`. Note that this selection is case insensitive. Set the
|
|
|
|
// screw either to simplify the model or to use for cutting out screw holes. Setting the pitch to zero also produces
|
|
|
|
// `thread=` argument to one of these values to choose a different pitch. Note that not every pitch
|
|
|
|
// an unthreaded screw. If you specify a numeric thread value it will override any value given in `name`.
|
|
|
|
// category is defined at every diameter. You can also specify the thread pitch directly, for example
|
|
|
|
//
|
|
|
|
// you could set `thread=2` which would produce threads with a pitch of 2mm. The final option is to
|
|
|
|
// The `head` parameter specifies the type of head the screw will have. Options for the head are
|
|
|
|
// specify `thread="none"` to produce an unthreaded screw either to simplify the model or to use for
|
|
|
|
// - "flat"
|
|
|
|
// cutting out screw holes. Setting the pitch to `0` (zero) also produces an unthreaded screw.
|
|
|
|
// - "flat small"
|
|
|
|
// If you specify a numeric thread value it will override any value given in the `name=` argument.
|
|
|
|
// - "flat large"
|
|
|
|
// .
|
|
|
|
// - "flat undercut"
|
|
|
|
// The `head=` parameter specifies the type of head the screw will have. Options for the head are
|
|
|
|
// - "round"
|
|
|
|
// `"flat"`, `"flat small"`, `"flat large"`, `"flat undercut"`, `"round"`, `"pan"`, `"pan flat"`,
|
|
|
|
// - "pan"
|
|
|
|
// `"pan round"`, `"socket"`, `"hex"`, `"button"`, `"cheese"`, `"fillister"`, or `"none"`
|
|
|
|
// - "pan flat"
|
|
|
|
// .
|
|
|
|
// - "pan round"
|
|
|
|
// Note that different sized flat heads exist for the same screw type. Sometimes this depends on
|
|
|
|
// - "socket"
|
|
|
|
// the type of recess. If you specify `"flat"` then the size will be chosen appropriately for the
|
|
|
|
// - "hex"
|
|
|
|
// recess you specify. The default is `"none"`.
|
|
|
|
// - "button"
|
|
|
|
// .
|
|
|
|
// - "cheese"
|
|
|
|
// The `drive=` argument specifies the recess type. Options for the drive are `"none"`, `"hex"`,
|
|
|
|
// - "fillister"
|
|
|
|
// `"slot"`, `"phillips"`, `"ph0"` to `"ph4"` (for phillips of the specified size), `"torx"` or
|
|
|
|
// - "none"
|
|
|
|
// `"t<size>"` (for Torx at a specified size, e.g. `"t20"`). The default drive is `"none"`
|
|
|
|
// Note that different sized flat heads exist for the same screw type. Sometimes this depends on the type of recess. If you specify "flat" then
|
|
|
|
// .
|
|
|
|
// the size will be chosen appropriately for the recess you specify. The default is "none".
|
|
|
|
// Only some combinations of head and drive type are supported:
|
|
|
|
//
|
|
|
|
// .
|
|
|
|
// The `drive` parameter specifies the recess type. Options for the drive are
|
|
|
|
// Head | Drive
|
|
|
|
// - "none"
|
|
|
|
// ----------------- | ----------------------------
|
|
|
|
// - "phillips"
|
|
|
|
// `"none"` | hex, torx
|
|
|
|
// - "slot"
|
|
|
|
// `"hex"` | *none*
|
|
|
|
// - "torx"
|
|
|
|
// `"socket"` | hex, torx
|
|
|
|
// - "hex"
|
|
|
|
// `"button"` | hex, torx
|
|
|
|
// - "ph0", up to "ph4" for phillips of the specified size
|
|
|
|
// `"flat"` | slot, phillips, hex, torx
|
|
|
|
// - "t<size>" for torx at a specified size, e.g. "t20"
|
|
|
|
// `"round"` | slot, phillips (UTS/English only.)
|
|
|
|
// The default drive is "none"
|
|
|
|
// `"fillister"` | slot, phillips (UTS/English only.)
|
|
|
|
//
|
|
|
|
// `"flat small"` | phillips, slot (UTS/English only.)
|
|
|
|
// Only some combinations of head and drive type are supported. Supported UTS (English) head and drive combinations:
|
|
|
|
// `"flat large"` | hex, torx (UTS/English only.)
|
|
|
|
//
|
|
|
|
// `"flat undercut"` | slot, phillips (UTS/English only.)
|
|
|
|
// Head| Drive
|
|
|
|
// `"pan"` | slot, phillips (ISO/Metric only.)
|
|
|
|
// ---|---
|
|
|
|
// `"cheese"` | slot, phillips (ISO/Metric only.)
|
|
|
|
// none | hex, torx
|
|
|
|
// .
|
|
|
|
// hex |
|
|
|
|
// The drive size is specified appropriately to the drive type: drive number for phillips or torx,
|
|
|
|
// socket | hex, torx
|
|
|
|
// and allen width in mm or inches (as appropriate) for hex. Drive size is determined automatically
|
|
|
|
// button | hex, torx
|
|
|
|
// from the screw size, but by passing the `drive_size=` argument you can override the default, or
|
|
|
|
// round | slot, phillips
|
|
|
|
// in cases where no default exists you can specify it.
|
|
|
|
// fillister | slot, phillips
|
|
|
|
// .
|
|
|
|
// flat | slot, phillips, hex, torx
|
|
|
|
// The `oversize=` parameter adds the specified amount to the screw and head diameter to make an
|
|
|
|
// flat small | phillips, slot
|
|
|
|
// oversized screw. This is intended for generating clearance holes, not for dealing with printer
|
|
|
|
// flat large | hex, torx
|
|
|
|
// inaccuracy. Does not affect length, thread pitch or head height.
|
|
|
|
// flat undercut| slot, phillips
|
|
|
|
// .
|
|
|
|
//
|
|
|
|
// The output is a [[struct|structs.scad]] with the following fields:
|
|
|
|
// Supported metric head and drive combinations:
|
|
|
|
// .
|
|
|
|
//
|
|
|
|
// Field | What it is
|
|
|
|
// Head| Drive
|
|
|
|
// ------------------ | ---------------
|
|
|
|
// ---|---
|
|
|
|
// `"system"` | Either `"UTS"` or `"ISO"` (used for correct tolerance computation).
|
|
|
|
// none |hex, torx
|
|
|
|
// `"diameter"` | The nominal diameter of the screw shaft in mm.
|
|
|
|
// hex |
|
|
|
|
// `"pitch"` | The thread pitch in mm.
|
|
|
|
// socket| hex, torx
|
|
|
|
// `"head"` | The type of head (a string from the list above).
|
|
|
|
// pan | slot, phillips
|
|
|
|
// `"head_size"` | Size of the head in mm.
|
|
|
|
// button| hex, torx
|
|
|
|
// `"head_angle"` | Countersink angle for flat heads.
|
|
|
|
// cheese| slot, phillips
|
|
|
|
// `"head_height"` | Height of the head (when needed to specify the head).
|
|
|
|
// flat | phillips, slot, hex, torx
|
|
|
|
// `"drive"` | The drive type (`"phillips"`, `"torx"`, `"slot"`, `"hex"`, `"none"`)
|
|
|
|
//
|
|
|
|
// `"drive_size"` | The drive size, either a drive number (phillips or torx) or a dimension in mm (hex). Not defined for slot drive.
|
|
|
|
// The drive size is specified appropriately to the drive type: drive number for phillips or torx, and allen width in mm or inches (as appropriate) for hex.
|
|
|
|
// `"drive_diameter"` | Diameter of a phillips drive.
|
|
|
|
// Drive size is determined automatically from the screw size, but by passing the `drive_size` parameter
|
|
|
|
// `"drive_width"` | Width of the arms of the cross in a phillips drive or the slot for a slot drive.
|
|
|
|
// you can override the default, or in cases where no default exists you can specify it.
|
|
|
|
// `"drive_depth"` | Depth of the drive recess.
|
|
|
|
//
|
|
|
|
// `"length"` | Length of the screw in mm measured in the customary fashion. For flat head screws the total length and for other screws, the length from the bottom of the head to the screw tip.
|
|
|
|
// The `oversize` parameter adds the specified amount to the screw and head diameter to make an oversized screw.
|
|
|
|
//
|
|
|
|
// This is intended for generating clearance holes, not for dealing with printer inaccuracy. Does not affect length, thread pitch or head height.
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// The output is a structure with the following fields:
|
|
|
|
|
|
|
|
// - system: either "UTS" or "ISO" (used for correct tolerance computation)
|
|
|
|
|
|
|
|
// - diameter: the nominal diameter of the screw shaft in mm
|
|
|
|
|
|
|
|
// - pitch: the thread pitch in mm
|
|
|
|
|
|
|
|
// - head: the type of head (a string from the list above)
|
|
|
|
|
|
|
|
// - head_size: size of the head in mm
|
|
|
|
|
|
|
|
// - head_angle: countersink angle for flat heads
|
|
|
|
|
|
|
|
// - head_height: height of the head (when needed to specify the head)
|
|
|
|
|
|
|
|
// - drive: the drive type ("phillips", "torx", "slot", "hex", "none")
|
|
|
|
|
|
|
|
// - drive_size: the drive size, either a drive number (phillips or torx) or a dimension in mm (hex). Not defined for slot drive
|
|
|
|
|
|
|
|
// - drive_diameter: diameter of a phillips drive
|
|
|
|
|
|
|
|
// - drive_width: width of the arms of the cross in a phillips drive or the slot for a slot drive
|
|
|
|
|
|
|
|
// - drive_depth: depth of the drive recess
|
|
|
|
|
|
|
|
// - length: length of the screw in mm measured in the customary fashion: for flat head screws the total length and for other screws, the length from the bottom of the head to the screw tip.
|
|
|
|
|
|
|
|
// Arguments:
|
|
|
|
// Arguments:
|
|
|
|
// name = screw specification, e.g. "M5x1" or "#8-32"
|
|
|
|
// name = screw specification, e.g. "M5x1" or "#8-32"
|
|
|
|
// head = head type (see list above). Default: none
|
|
|
|
// head = head type (see list above). Default: none
|
|
|
@ -161,10 +156,10 @@ function parse_drive(drive=undef, drive_size=undef) =
|
|
|
|
// drive_size = size of drive recess to override computed value
|
|
|
|
// drive_size = size of drive recess to override computed value
|
|
|
|
// oversize = amount to increase screw diameter for clearance holes. Default: 0
|
|
|
|
// oversize = amount to increase screw diameter for clearance holes. Default: 0
|
|
|
|
function screw_info(name, head, thread="coarse", drive, drive_size=undef, oversize=0) =
|
|
|
|
function screw_info(name, head, thread="coarse", drive, drive_size=undef, oversize=0) =
|
|
|
|
let(type=parse_screw_name(name),
|
|
|
|
let(type=_parse_screw_name(name),
|
|
|
|
drive_info = parse_drive(drive, drive_size),
|
|
|
|
drive_info = _parse_drive(drive, drive_size),
|
|
|
|
drive=drive_info[0],
|
|
|
|
drive=drive_info[0],
|
|
|
|
screwdata =
|
|
|
|
screwdata =
|
|
|
|
type[0] == "english" ? _screw_info_english(type[1],type[2], head, thread, drive) :
|
|
|
|
type[0] == "english" ? _screw_info_english(type[1],type[2], head, thread, drive) :
|
|
|
|
type[0] == "metric" ? _screw_info_metric(type[1], type[2], head, thread, drive) :
|
|
|
|
type[0] == "metric" ? _screw_info_metric(type[1], type[2], head, thread, drive) :
|
|
|
|
[],
|
|
|
|
[],
|
|
|
@ -176,7 +171,7 @@ function screw_info(name, head, thread="coarse", drive, drive_size=undef, oversi
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
struct_set(screwdata, over_ride);
|
|
|
|
struct_set(screwdata, over_ride);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _screw_info_english(diam, threadcount, head, thread, drive) =
|
|
|
|
function _screw_info_english(diam, threadcount, head, thread, drive) =
|
|
|
|
let(
|
|
|
|
let(
|
|
|
@ -223,7 +218,7 @@ function _screw_info_english(diam, threadcount, head, thread, drive) =
|
|
|
|
]
|
|
|
|
]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
inch / struct_val(UTS_thread, diam)[tind],
|
|
|
|
inch / struct_val(UTS_thread, diam)[tind],
|
|
|
|
head_data =
|
|
|
|
head_data =
|
|
|
|
head=="none" || is_undef(head) ? let (
|
|
|
|
head=="none" || is_undef(head) ? let (
|
|
|
|
UTS_setscrew = [ // hex width, hex depth
|
|
|
|
UTS_setscrew = [ // hex width, hex depth
|
|
|
|
["#0", [0.028, 0.050]],
|
|
|
|
["#0", [0.028, 0.050]],
|
|
|
@ -278,7 +273,7 @@ function _screw_info_english(diam, threadcount, head, thread, drive) =
|
|
|
|
[1.25, [ 1+7/8, 27/32]],
|
|
|
|
[1.25, [ 1+7/8, 27/32]],
|
|
|
|
[1.5, [ 2.25, 15/16]],
|
|
|
|
[1.5, [ 2.25, 15/16]],
|
|
|
|
[1.75, [ 2+5/8, 1+3/32]],
|
|
|
|
[1.75, [ 2+5/8, 1+3/32]],
|
|
|
|
[2, [ 3, 1+7/32]],
|
|
|
|
[2, [ 3, 1+7/32]],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
entry = struct_val(UTS_hex, diam)
|
|
|
|
entry = struct_val(UTS_hex, diam)
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -289,7 +284,7 @@ function _screw_info_english(diam, threadcount, head, thread, drive) =
|
|
|
|
["#0", [ 0.096, 0.05, 6, 0.025, 0.027]],
|
|
|
|
["#0", [ 0.096, 0.05, 6, 0.025, 0.027]],
|
|
|
|
["#1", [ 0.118, 1/16, 7, 0.031, 0.036]],
|
|
|
|
["#1", [ 0.118, 1/16, 7, 0.031, 0.036]],
|
|
|
|
["#2", [ 9/64, 5/64, 8, 0.038, 0.037]],
|
|
|
|
["#2", [ 9/64, 5/64, 8, 0.038, 0.037]],
|
|
|
|
["#3", [ 0.161, 5/64, 8, 0.044, 0.041]], // For larger sizes, recess depth is
|
|
|
|
["#3", [ 0.161, 5/64, 8, 0.044, 0.041]], // For larger sizes, recess depth is
|
|
|
|
["#4", [ 0.183, 3/32, 10, 0.051, 0.049]], // half the diameter
|
|
|
|
["#4", [ 0.183, 3/32, 10, 0.051, 0.049]], // half the diameter
|
|
|
|
["#5", [ 0.205, 3/32, 10, 0.057, 0.049]],
|
|
|
|
["#5", [ 0.205, 3/32, 10, 0.057, 0.049]],
|
|
|
|
["#6", [ 0.226, 7/64, 15, 0.064, 0.058]],
|
|
|
|
["#6", [ 0.226, 7/64, 15, 0.064, 0.058]],
|
|
|
@ -318,7 +313,7 @@ function _screw_info_english(diam, threadcount, head, thread, drive) =
|
|
|
|
drive_size = drive=="hex" ? [["drive_size",inch*entry[1]], ["drive_depth",inch*hexdepth]] :
|
|
|
|
drive_size = drive=="hex" ? [["drive_size",inch*entry[1]], ["drive_depth",inch*hexdepth]] :
|
|
|
|
drive=="torx" ? [["drive_size",entry[2]],["drive_depth",inch*entry[4]]] : []
|
|
|
|
drive=="torx" ? [["drive_size",entry[2]],["drive_depth",inch*entry[4]]] : []
|
|
|
|
)
|
|
|
|
)
|
|
|
|
concat([["head","socket"],["head_size",inch*entry[0]], ["head_height", inch*diameter]],drive_size) :
|
|
|
|
concat([["head","socket"],["head_size",inch*entry[0]], ["head_height", inch*diameter]],drive_size) :
|
|
|
|
head=="pan" ? let (
|
|
|
|
head=="pan" ? let (
|
|
|
|
UTS_pan = [ // pan head for phillips or slotted
|
|
|
|
UTS_pan = [ // pan head for phillips or slotted
|
|
|
|
// diam, head ht slotted, head height phillips, phillips drive, phillips diam, phillips width, phillips depth, slot width, slot depth
|
|
|
|
// diam, head ht slotted, head height phillips, phillips drive, phillips diam, phillips width, phillips depth, slot width, slot depth
|
|
|
@ -340,7 +335,7 @@ function _screw_info_english(diam, threadcount, head, thread, drive) =
|
|
|
|
entry = struct_val(UTS_pan, diam),
|
|
|
|
entry = struct_val(UTS_pan, diam),
|
|
|
|
drive_size = drive=="phillips" ? [["drive_size", entry[3]], ["drive_diameter",inch*entry[4]],["drive_width",inch*entry[5]],["drive_depth",inch*entry[6]]] :
|
|
|
|
drive_size = drive=="phillips" ? [["drive_size", entry[3]], ["drive_diameter",inch*entry[4]],["drive_width",inch*entry[5]],["drive_depth",inch*entry[6]]] :
|
|
|
|
[["drive_width", inch*entry[7]], ["drive_depth",inch*entry[8]]])
|
|
|
|
[["drive_width", inch*entry[7]], ["drive_depth",inch*entry[8]]])
|
|
|
|
concat([["head","pan"], ["head_size", inch*entry[0]], ["head_height", inch*entry[htind]]], drive_size) :
|
|
|
|
concat([["head","pan"], ["head_size", inch*entry[0]], ["head_height", inch*entry[htind]]], drive_size) :
|
|
|
|
head=="button" || head=="round" ? let(
|
|
|
|
head=="button" || head=="round" ? let(
|
|
|
|
UTS_button = [ // button, hex or torx drive
|
|
|
|
UTS_button = [ // button, hex or torx drive
|
|
|
|
// head diam, height, phillips, hex, torx, hex depth
|
|
|
|
// head diam, height, phillips, hex, torx, hex depth
|
|
|
@ -358,7 +353,7 @@ function _screw_info_english(diam, threadcount, head, thread, drive) =
|
|
|
|
[5/16, [0.547, 0.166, undef, 3/16, 40 , 0.105, 0.090]],
|
|
|
|
[5/16, [0.547, 0.166, undef, 3/16, 40 , 0.105, 0.090]],
|
|
|
|
[3/8, [0.656, 0.199, undef, 7/32, 45 , 0.122, 0.106]],
|
|
|
|
[3/8, [0.656, 0.199, undef, 7/32, 45 , 0.122, 0.106]],
|
|
|
|
[7/16, [0.750, 0.220, undef, 1/4, undef, 0.193, undef]], // hex depth interpolated
|
|
|
|
[7/16, [0.750, 0.220, undef, 1/4, undef, 0.193, undef]], // hex depth interpolated
|
|
|
|
[1/2, [0.875, 0.265, undef, 5/16, 55 , 0.175, 0.158]],
|
|
|
|
[1/2, [0.875, 0.265, undef, 5/16, 55 , 0.175, 0.158]],
|
|
|
|
[5/8, [1.000, 0.331, undef, 3/8, 60, , 0.210, 0.192]],
|
|
|
|
[5/8, [1.000, 0.331, undef, 3/8, 60, , 0.210, 0.192]],
|
|
|
|
[3/4, [1.1, 0.375, undef, 7/16, undef, 0.241]], // hex depth extrapolated
|
|
|
|
[3/4, [1.1, 0.375, undef, 7/16, undef, 0.241]], // hex depth extrapolated
|
|
|
|
],
|
|
|
|
],
|
|
|
@ -424,7 +419,7 @@ function _screw_info_english(diam, threadcount, head, thread, drive) =
|
|
|
|
["#2", [ .162, 1, 6 , 0.036, 0.096, 0.055, 0.017, 0.031, 0.023, 0.088, 0.048, 0.017, 0.016]],
|
|
|
|
["#2", [ .162, 1, 6 , 0.036, 0.096, 0.055, 0.017, 0.031, 0.023, 0.088, 0.048, 0.017, 0.016]],
|
|
|
|
["#3", [ .187, 1, undef, 0.042, 0.100, 0.060, 0.018, 0.035, 0.027, 0.099, 0.059, 0.018, 0.019]],
|
|
|
|
["#3", [ .187, 1, undef, 0.042, 0.100, 0.060, 0.018, 0.035, 0.027, 0.099, 0.059, 0.018, 0.019]],
|
|
|
|
["#4", [ .212, 1, 8 , 0.047, 0.122, 0.081, 0.018, 0.039, 0.030, 0.110, 0.070, 0.018, 0.022]],
|
|
|
|
["#4", [ .212, 1, 8 , 0.047, 0.122, 0.081, 0.018, 0.039, 0.030, 0.110, 0.070, 0.018, 0.022]],
|
|
|
|
["#5", [ .237, 2, undef, 0.053, 0.148, 0.074, 0.027, 0.043, 0.034, 0.122, 0.081, 0.018, 0.024]], // ph#1 for undercut
|
|
|
|
["#5", [ .237, 2, undef, 0.053, 0.148, 0.074, 0.027, 0.043, 0.034, 0.122, 0.081, 0.018, 0.024]], // ph#1 for undercut
|
|
|
|
["#6", [ .262, 2, 10 , 0.059, 0.168, 0.094, 0.029, 0.048, 0.038, 0.140, 0.066, 0.025, 0.027]],
|
|
|
|
["#6", [ .262, 2, 10 , 0.059, 0.168, 0.094, 0.029, 0.048, 0.038, 0.140, 0.066, 0.025, 0.027]],
|
|
|
|
["#8", [ .312, 2, 15 , 0.070, 0.182, 0.110, 0.030, 0.054, 0.045, 0.168, 0.094, 0.029, 0.032]],
|
|
|
|
["#8", [ .312, 2, 15 , 0.070, 0.182, 0.110, 0.030, 0.054, 0.045, 0.168, 0.094, 0.029, 0.032]],
|
|
|
|
["#10",[ .362, 2, 20 , 0.081, 0.198, 0.124, 0.032, 0.060, 0.053, 0.182, 0.110, 0.030, 0.037]],
|
|
|
|
["#10",[ .362, 2, 20 , 0.081, 0.198, 0.124, 0.032, 0.060, 0.053, 0.182, 0.110, 0.030, 0.037]],
|
|
|
@ -492,7 +487,7 @@ function _screw_info_english(diam, threadcount, head, thread, drive) =
|
|
|
|
function _screw_info_metric(diam, pitch, head, thread, drive) =
|
|
|
|
function _screw_info_metric(diam, pitch, head, thread, drive) =
|
|
|
|
let(
|
|
|
|
let(
|
|
|
|
a=echo(metricsi=diam,pitch,head,thread,drive),
|
|
|
|
a=echo(metricsi=diam,pitch,head,thread,drive),
|
|
|
|
pitch = is_num(thread) ? thread :
|
|
|
|
pitch = is_num(thread) ? thread :
|
|
|
|
is_def(pitch) ? pitch :
|
|
|
|
is_def(pitch) ? pitch :
|
|
|
|
let(
|
|
|
|
let(
|
|
|
|
tind=struct_val([["coarse",0],
|
|
|
|
tind=struct_val([["coarse",0],
|
|
|
@ -596,7 +591,7 @@ function _screw_info_metric(diam, pitch, head, thread, drive) =
|
|
|
|
metric_socket = [ // height = screw diameter
|
|
|
|
metric_socket = [ // height = screw diameter
|
|
|
|
//diam, hex
|
|
|
|
//diam, hex
|
|
|
|
[1.4, [2.5, 1.3]],
|
|
|
|
[1.4, [2.5, 1.3]],
|
|
|
|
[1.6, [3, 1.5]],
|
|
|
|
[1.6, [3, 1.5]],
|
|
|
|
[2, [3.8, 1.5, 6, 0.77]],
|
|
|
|
[2, [3.8, 1.5, 6, 0.77]],
|
|
|
|
[2.5, [4.5, 2, 8, 1.05]],
|
|
|
|
[2.5, [4.5, 2, 8, 1.05]],
|
|
|
|
[2.6, [5, 2, 8, 1.05]],
|
|
|
|
[2.6, [5, 2, 8, 1.05]],
|
|
|
@ -620,14 +615,14 @@ function _screw_info_metric(diam, pitch, head, thread, drive) =
|
|
|
|
[33, [50, 24]],
|
|
|
|
[33, [50, 24]],
|
|
|
|
[36, [54, 27]],
|
|
|
|
[36, [54, 27]],
|
|
|
|
[42, [63, 32]],
|
|
|
|
[42, [63, 32]],
|
|
|
|
[48, [72, 36]],
|
|
|
|
[48, [72, 36]],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
entry = struct_val(metric_socket, diam),
|
|
|
|
entry = struct_val(metric_socket, diam),
|
|
|
|
drive_size = drive=="hex" ? [["drive_size",entry[1]],["drive_depth",diam/2]] :
|
|
|
|
drive_size = drive=="hex" ? [["drive_size",entry[1]],["drive_depth",diam/2]] :
|
|
|
|
drive=="torx" ? [["drive_size", entry[2]], ["drive_depth", entry[3]]] :
|
|
|
|
drive=="torx" ? [["drive_size", entry[2]], ["drive_depth", entry[3]]] :
|
|
|
|
[]
|
|
|
|
[]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
concat([["head","socket"],["head_size",entry[0]], ["head_height", diam]],drive_size) :
|
|
|
|
concat([["head","socket"],["head_size",entry[0]], ["head_height", diam]],drive_size) :
|
|
|
|
starts_with(head,"pan") ? let (
|
|
|
|
starts_with(head,"pan") ? let (
|
|
|
|
metric_pan = [ // pan head for phillips or slotted
|
|
|
|
metric_pan = [ // pan head for phillips or slotted
|
|
|
|
// diam, slotted diam, phillips diam, phillips depth, ph width, slot width,slot depth
|
|
|
|
// diam, slotted diam, phillips diam, phillips depth, ph width, slot width,slot depth
|
|
|
@ -648,11 +643,11 @@ function _screw_info_metric(diam, pitch, head, thread, drive) =
|
|
|
|
drive_size = drive=="phillips" ? [["drive_size", entry[3]], ["drive_diameter", entry[4]], ["drive_depth",entry[5]], ["drive_width",entry[6]]] :
|
|
|
|
drive_size = drive=="phillips" ? [["drive_size", entry[3]], ["drive_diameter", entry[4]], ["drive_depth",entry[5]], ["drive_width",entry[6]]] :
|
|
|
|
drive=="slot" ? [["drive_width", entry[7]], ["drive_depth", entry[8]]] : []
|
|
|
|
drive=="slot" ? [["drive_width", entry[7]], ["drive_depth", entry[8]]] : []
|
|
|
|
)
|
|
|
|
)
|
|
|
|
concat([["head",type], ["head_size", entry[0]], ["head_height", entry[htind]]], drive_size) :
|
|
|
|
concat([["head",type], ["head_size", entry[0]], ["head_height", entry[htind]]], drive_size) :
|
|
|
|
head=="button" || head=="cheese" ? let(
|
|
|
|
head=="button" || head=="cheese" ? let(
|
|
|
|
metric_button = [ // button, hex drive
|
|
|
|
metric_button = [ // button, hex drive
|
|
|
|
// head diam, height, hex, phillips, hex drive depth
|
|
|
|
// head diam, height, hex, phillips, hex drive depth
|
|
|
|
[1.6, [2.9, 0.8, 0.9, undef, 0.55]], // These four cases,
|
|
|
|
[1.6, [2.9, 0.8, 0.9, undef, 0.55]], // These four cases,
|
|
|
|
[2, [3.5, 1.3, 1.3, undef, 0.69]], // extrapolated hex depth
|
|
|
|
[2, [3.5, 1.3, 1.3, undef, 0.69]], // extrapolated hex depth
|
|
|
|
[2.2, [3.8, 0.9, 1.3, undef, 0.76]], //
|
|
|
|
[2.2, [3.8, 0.9, 1.3, undef, 0.76]], //
|
|
|
|
[2.5, [4.6, 1.5, 1.5, undef, 0.87]], //
|
|
|
|
[2.5, [4.6, 1.5, 1.5, undef, 0.87]], //
|
|
|
@ -686,19 +681,19 @@ function _screw_info_metric(diam, pitch, head, thread, drive) =
|
|
|
|
drive_index = drive=="phillips" ? 3 :
|
|
|
|
drive_index = drive=="phillips" ? 3 :
|
|
|
|
drive=="hex" ? 2 : undef,
|
|
|
|
drive=="hex" ? 2 : undef,
|
|
|
|
drive_dim = head=="button" && drive=="hex" ? [["drive_depth", entry[4]]] :
|
|
|
|
drive_dim = head=="button" && drive=="hex" ? [["drive_depth", entry[4]]] :
|
|
|
|
head=="button" && drive=="torx" ? [["drive_size", entry[5]],["drive_depth", entry[6]]] :
|
|
|
|
head=="button" && drive=="torx" ? [["drive_size", entry[5]],["drive_depth", entry[6]]] :
|
|
|
|
head=="cheese" && drive=="slot" ? [["drive_width", entry[4]], ["drive_depth", entry[5]]] :
|
|
|
|
head=="cheese" && drive=="slot" ? [["drive_width", entry[4]], ["drive_depth", entry[5]]] :
|
|
|
|
head=="cheese" && drive=="phillips" ? [["drive_diameter", entry[6]], ["drive_depth", entry[7]],
|
|
|
|
head=="cheese" && drive=="phillips" ? [["drive_diameter", entry[6]], ["drive_depth", entry[7]],
|
|
|
|
["drive_width", entry[6]/4]]: // Fabricated this width value to fill in missing field
|
|
|
|
["drive_width", entry[6]/4]]: // Fabricated this width value to fill in missing field
|
|
|
|
[],
|
|
|
|
[],
|
|
|
|
drive_size = is_def(drive_index) ? [["drive_size", entry[drive_index]]] : []
|
|
|
|
drive_size = is_def(drive_index) ? [["drive_size", entry[drive_index]]] : []
|
|
|
|
)
|
|
|
|
)
|
|
|
|
concat([["head",head],["head_size",entry[0]], ["head_height", entry[1]]],drive_size, drive_dim) :
|
|
|
|
concat([["head",head],["head_size",entry[0]], ["head_height", entry[1]]],drive_size, drive_dim) :
|
|
|
|
starts_with(head,"flat") ? let(
|
|
|
|
starts_with(head,"flat") ? let(
|
|
|
|
small = head == "flat small" || (head=="flat" && (drive!="hex" && drive!="torx")),
|
|
|
|
small = head == "flat small" || (head=="flat" && (drive!="hex" && drive!="torx")),
|
|
|
|
metric_flat_large = [ // for hex drive
|
|
|
|
metric_flat_large = [ // for hex drive
|
|
|
|
[2, [4, 1.3,undef]],
|
|
|
|
[2, [4, 1.3,undef]],
|
|
|
|
[2.5,[5, 1.5, undef]],
|
|
|
|
[2.5,[5, 1.5, undef]],
|
|
|
|
[3, [6, 2 , 1.1, 10, 0.96]],
|
|
|
|
[3, [6, 2 , 1.1, 10, 0.96]],
|
|
|
|
[4, [8, 2.5, 1.5, 20, 1.34]],
|
|
|
|
[4, [8, 2.5, 1.5, 20, 1.34]],
|
|
|
|
[5, [10, 3 , 1.9, 25, 1.54]],
|
|
|
|
[5, [10, 3 , 1.9, 25, 1.54]],
|
|
|
@ -751,6 +746,7 @@ function _screw_info_metric(diam, pitch, head, thread, drive) =
|
|
|
|
head_data
|
|
|
|
head_data
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Module: screw_head()
|
|
|
|
// Module: screw_head()
|
|
|
|
// Usage:
|
|
|
|
// Usage:
|
|
|
|
// screw_head(screw_info, [details])
|
|
|
|
// screw_head(screw_info, [details])
|
|
|
@ -758,7 +754,7 @@ function _screw_info_metric(diam, pitch, head, thread, drive) =
|
|
|
|
// Draws the screw head described by the data structure `screw_info`, which
|
|
|
|
// Draws the screw head described by the data structure `screw_info`, which
|
|
|
|
// should have the fields produced by `screw_info()`. See that function for
|
|
|
|
// should have the fields produced by `screw_info()`. See that function for
|
|
|
|
// details on the fields. Standard orientation is with the head centered at (0,0)
|
|
|
|
// details on the fields. Standard orientation is with the head centered at (0,0)
|
|
|
|
// and oriented in the +z direction. Flat heads appear below the xy plane.
|
|
|
|
// and oriented in the +z direction. Flat heads appear below the xy plane.
|
|
|
|
// Other heads appear sitting on the xy plane.
|
|
|
|
// Other heads appear sitting on the xy plane.
|
|
|
|
module screw_head(screw_info,details=false) {
|
|
|
|
module screw_head(screw_info,details=false) {
|
|
|
|
head = struct_val(screw_info, "head");
|
|
|
|
head = struct_val(screw_info, "head");
|
|
|
@ -776,12 +772,12 @@ module screw_head(screw_info,details=false) {
|
|
|
|
if (in_list(head,["round","pan round","button","fillister","cheese"])) {
|
|
|
|
if (in_list(head,["round","pan round","button","fillister","cheese"])) {
|
|
|
|
base = head=="fillister" ? 0.75*head_height :
|
|
|
|
base = head=="fillister" ? 0.75*head_height :
|
|
|
|
head=="pan round" ? .6 * head_height :
|
|
|
|
head=="pan round" ? .6 * head_height :
|
|
|
|
head=="cheese" ? .7 * head_height :
|
|
|
|
head=="cheese" ? .7 * head_height :
|
|
|
|
0.1 * head_height; // round and button
|
|
|
|
0.1 * head_height; // round and button
|
|
|
|
head_size2 = head=="cheese" ? head_size-2*tan(5)*head_height : head_size; // 5 deg slope on cheese head
|
|
|
|
head_size2 = head=="cheese" ? head_size-2*tan(5)*head_height : head_size; // 5 deg slope on cheese head
|
|
|
|
cyl(l=base, d1=head_size, d2=head_size2,anchor=BOTTOM, $fn=32)
|
|
|
|
cyl(l=base, d1=head_size, d2=head_size2,anchor=BOTTOM, $fn=32)
|
|
|
|
attach(TOP)
|
|
|
|
attach(TOP)
|
|
|
|
rotate_extrude($fn=32)
|
|
|
|
rotate_extrude($fn=32)
|
|
|
|
intersection(){
|
|
|
|
intersection(){
|
|
|
|
arc(points=[[-head_size2/2,0], [0,-base+head_height * (head=="button"?4/3:1)], [head_size2/2,0]]);
|
|
|
|
arc(points=[[-head_size2/2,0], [0,-base+head_height * (head=="button"?4/3:1)], [head_size2/2,0]]);
|
|
|
|
square([head_size2, head_height-base]);
|
|
|
|
square([head_size2, head_height-base]);
|
|
|
@ -797,16 +793,17 @@ module screw_head(screw_info,details=false) {
|
|
|
|
if (details)
|
|
|
|
if (details)
|
|
|
|
down(.01)cyl(l=head_height+.02,d=2*head_size/sqrt(3), chamfer=head_size*(1/sqrt(3)-1/2), anchor=BOTTOM);
|
|
|
|
down(.01)cyl(l=head_height+.02,d=2*head_size/sqrt(3), chamfer=head_size*(1/sqrt(3)-1/2), anchor=BOTTOM);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Module: screw()
|
|
|
|
// Module: screw()
|
|
|
|
// Usage:
|
|
|
|
// Usage:
|
|
|
|
// screw([name],[head],[thread],[drive],[drive_size], [length], [shank], [oversize], [tolerance], [spec], [details], [anchor], [anchor_head], [orient], [spin])
|
|
|
|
// screw([name],[head],[thread],[drive],[drive_size], [length], [shank], [oversize], [tolerance], [spec], [details], [anchor], [anchor_head], [orient], [spin])
|
|
|
|
// Description:
|
|
|
|
// Description:
|
|
|
|
// Create a screw.
|
|
|
|
// Create a screw.
|
|
|
|
//
|
|
|
|
// .
|
|
|
|
// Most of these parameters are described in the entry for `screw_info()`.
|
|
|
|
// Most of these parameters are described in the entry for `screw_info()`.
|
|
|
|
//
|
|
|
|
// .
|
|
|
|
// The tolerance determines the actual thread sizing based on the
|
|
|
|
// The tolerance determines the actual thread sizing based on the
|
|
|
|
// nominal size. For UTS threads it is either "1A", "2A" or "3A", in
|
|
|
|
// nominal size. For UTS threads it is either "1A", "2A" or "3A", in
|
|
|
|
// order of increasing tightness. The default tolerance is "2A", which
|
|
|
|
// order of increasing tightness. The default tolerance is "2A", which
|
|
|
@ -817,8 +814,8 @@ module screw_head(screw_info,details=false) {
|
|
|
|
// range (variability) of the thread heights. It must be a value from
|
|
|
|
// range (variability) of the thread heights. It must be a value from
|
|
|
|
// 3-9 for crest diameter and one of 4, 6, or 8 for pitch diameter. A
|
|
|
|
// 3-9 for crest diameter and one of 4, 6, or 8 for pitch diameter. A
|
|
|
|
// tolerance "6g" specifies both pitch and crest diameter to be the same,
|
|
|
|
// tolerance "6g" specifies both pitch and crest diameter to be the same,
|
|
|
|
// but they can be different, with a tolerance like "5g6g" specifies a pitch diameter tolerance of "5g" and a crest diameter tolerance of "6g".
|
|
|
|
// but they can be different, with a tolerance like "5g6g" specifies a pitch diameter tolerance of "5g" and a crest diameter tolerance of "6g".
|
|
|
|
// Smaller numbers give a tighter tolerance. The default ISO tolerance is "6g".
|
|
|
|
// Smaller numbers give a tighter tolerance. The default ISO tolerance is "6g".
|
|
|
|
// Arguments:
|
|
|
|
// Arguments:
|
|
|
|
// name = screw specification, e.g. "M5x1" or "#8-32"
|
|
|
|
// name = screw specification, e.g. "M5x1" or "#8-32"
|
|
|
|
// head = head type (see list above). Default: none
|
|
|
|
// head = head type (see list above). Default: none
|
|
|
@ -826,18 +823,18 @@ module screw_head(screw_info,details=false) {
|
|
|
|
// drive = drive type. Default: none
|
|
|
|
// drive = drive type. Default: none
|
|
|
|
// drive_size = size of drive recess to override computed value
|
|
|
|
// drive_size = size of drive recess to override computed value
|
|
|
|
// oversize = amount to increase screw diameter for clearance holes. Default: 0
|
|
|
|
// oversize = amount to increase screw diameter for clearance holes. Default: 0
|
|
|
|
// spec = screw specification from `screw_info()`. If you specify this you can omit all the preceeding parameters.
|
|
|
|
// spec = screw specification from `screw_info()`. If you specify this you can omit all the preceeding parameters.
|
|
|
|
// length = length of screw (in mm)
|
|
|
|
// length = length of screw (in mm)
|
|
|
|
// shank = length of unthreaded portion of screw (in mm). Default: 0
|
|
|
|
// shank = length of unthreaded portion of screw (in mm). Default: 0
|
|
|
|
// details = toggle some details in rendering. Default: false
|
|
|
|
// details = toggle some details in rendering. Default: false
|
|
|
|
// tolerance = screw tolerance. Determines actual screw thread geometry based on nominal sizing. Default is "2A" for UTS and "6g" for ISO.
|
|
|
|
// tolerance = screw tolerance. Determines actual screw thread geometry based on nominal sizing. Default is "2A" for UTS and "6g" for ISO.
|
|
|
|
// anchor = anchor relative to the shaft of the screw
|
|
|
|
// anchor = anchor relative to the shaft of the screw
|
|
|
|
// anchor_head = anchor relative to the screw head
|
|
|
|
// anchor_head = anchor relative to the screw head
|
|
|
|
// Example: Selected UTS (English) screws
|
|
|
|
// Example: Selected UTS (English) screws
|
|
|
|
// $fn=32;
|
|
|
|
// $fn=32;
|
|
|
|
// xdistribute(spacing=8){
|
|
|
|
// xdistribute(spacing=8){
|
|
|
|
// screw("#6", length=12);
|
|
|
|
// screw("#6", length=12);
|
|
|
|
// screw("#6-32", head="button", drive="torx",length=12);
|
|
|
|
// screw("#6-32", head="button", drive="torx",length=12);
|
|
|
|
// screw("#6-32,3/4", head="hex");
|
|
|
|
// screw("#6-32,3/4", head="hex");
|
|
|
|
// screw("#6", thread="fine", head="fillister",length=12, drive="phillips");
|
|
|
|
// screw("#6", thread="fine", head="fillister",length=12, drive="phillips");
|
|
|
|
// screw("#6", head="flat small",length=12,drive="slot");
|
|
|
|
// screw("#6", head="flat small",length=12,drive="slot");
|
|
|
@ -868,35 +865,35 @@ module screw_head(screw_info,details=false) {
|
|
|
|
// screw("1/4", thread=0, length=8, anchor=TOP, head="hex");
|
|
|
|
// screw("1/4", thread=0, length=8, anchor=TOP, head="hex");
|
|
|
|
// ydistribute(spacing=15){
|
|
|
|
// ydistribute(spacing=15){
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="socket", drive="hex");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="socket", drive="hex");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="socket", drive="torx");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="socket", drive="torx");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="socket");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="socket");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// ydistribute(spacing=15){
|
|
|
|
// ydistribute(spacing=15){
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="button", drive="hex");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="button", drive="hex");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="button", drive="torx");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="button", drive="torx");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="button");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="button");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// ydistribute(spacing=15){
|
|
|
|
// ydistribute(spacing=15){
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="round", drive="slot");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="round", drive="slot");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="round", drive="phillips");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="round", drive="phillips");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="round");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="round");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// ydistribute(spacing=15){
|
|
|
|
// ydistribute(spacing=15){
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="fillister", drive="slot");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="fillister", drive="slot");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="fillister", drive="phillips");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="fillister", drive="phillips");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="fillister");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="fillister");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// ydistribute(spacing=15){
|
|
|
|
// ydistribute(spacing=15){
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="flat", drive="slot");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="flat", drive="slot");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="flat", drive="phillips");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="flat", drive="phillips");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="flat", drive="hex");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="flat", drive="hex");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="flat", drive="torx");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="flat", drive="torx");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="flat large");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="flat large");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="flat small");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="flat small");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// ydistribute(spacing=15){
|
|
|
|
// ydistribute(spacing=15){
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="flat undercut", drive="slot");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="flat undercut", drive="slot");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="flat undercut", drive="phillips");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="flat undercut", drive="phillips");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="flat undercut");
|
|
|
|
// screw("1/4", thread=0,length=8, anchor=TOP, head="flat undercut");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
@ -920,23 +917,23 @@ module screw_head(screw_info,details=false) {
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="pan flat");
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="pan flat");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// ydistribute(spacing=15){
|
|
|
|
// ydistribute(spacing=15){
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="button", drive="hex");
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="button", drive="hex");
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="button", drive="torx");
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="button", drive="torx");
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="button");
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="button");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// ydistribute(spacing=15){
|
|
|
|
// ydistribute(spacing=15){
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="cheese", drive="slot");
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="cheese", drive="slot");
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="cheese", drive="phillips");
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="cheese", drive="phillips");
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="cheese");
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="cheese");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// ydistribute(spacing=15){
|
|
|
|
// ydistribute(spacing=15){
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="flat", drive="phillips");
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="flat", drive="phillips");
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="flat", drive="slot");
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="flat", drive="slot");
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="flat", drive="hex");
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="flat", drive="hex");
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="flat", drive="torx");
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="flat", drive="torx");
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="flat small");
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="flat small");
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="flat large");
|
|
|
|
// screw("M6x0", length=8, anchor=TOP, head="flat large");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// Example: The three different English (UTS) screw tolerances
|
|
|
|
// Example: The three different English (UTS) screw tolerances
|
|
|
|
// module label(val)
|
|
|
|
// module label(val)
|
|
|
@ -944,8 +941,8 @@ module screw_head(screw_info,details=false) {
|
|
|
|
// difference(){
|
|
|
|
// difference(){
|
|
|
|
// children();
|
|
|
|
// children();
|
|
|
|
// yflip()linear_extrude(height=.35) text(val,valign="center",halign="center",size=8);
|
|
|
|
// yflip()linear_extrude(height=.35) text(val,valign="center",halign="center",size=8);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// $fn=64;
|
|
|
|
// $fn=64;
|
|
|
|
// xdistribute(spacing=15){
|
|
|
|
// xdistribute(spacing=15){
|
|
|
|
// label("1") screw("1/4-20,5/8", head="hex",orient=DOWN,anchor_head=TOP,tolerance="1A"); // Loose
|
|
|
|
// label("1") screw("1/4-20,5/8", head="hex",orient=DOWN,anchor_head=TOP,tolerance="1A"); // Loose
|
|
|
@ -960,18 +957,21 @@ module screw_head(screw_info,details=false) {
|
|
|
|
// children();
|
|
|
|
// children();
|
|
|
|
// ycopies(n=number, spacing=1.5)right(.25*inch-2)up(8-.35)cyl(d=1, h=1);
|
|
|
|
// ycopies(n=number, spacing=1.5)right(.25*inch-2)up(8-.35)cyl(d=1, h=1);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// $fn=64;
|
|
|
|
// $fn=64;
|
|
|
|
// xdistribute(spacing=17){
|
|
|
|
// xdistribute(spacing=17){
|
|
|
|
// mark(1) nut("1/4-20", thickness=8, diameter=0.5*inch,tolerance="1B");
|
|
|
|
// mark(1) nut("1/4-20", thickness=8, diameter=0.5*inch,tolerance="1B");
|
|
|
|
// mark(2) nut("1/4-20", thickness=8, diameter=0.5*inch,tolerance="2B");
|
|
|
|
// mark(2) nut("1/4-20", thickness=8, diameter=0.5*inch,tolerance="2B");
|
|
|
|
// mark(3) nut("1/4-20", thickness=8, diameter=0.5*inch,tolerance="3B");
|
|
|
|
// mark(3) nut("1/4-20", thickness=8, diameter=0.5*inch,tolerance="3B");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// Example: This example shows the gap between nut and bolt at the loosest tolerance for UTS. This gap is what enables the parts to mesh without binding and is part of the definition for standard metal hardware.
|
|
|
|
// Example(2D): This example shows the gap between nut and bolt at the loosest tolerance for UTS. This gap is what enables the parts to mesh without binding and is part of the definition for standard metal hardware.
|
|
|
|
|
|
|
|
// $slop=0;
|
|
|
|
// $fn=32;
|
|
|
|
// $fn=32;
|
|
|
|
// inch=25.4;
|
|
|
|
// inch=25.4;
|
|
|
|
// color("red") render() back_half() screw("1/4-20,1/4", head="hex",orient=UP,anchor=BOTTOM,tolerance="1A");
|
|
|
|
// projection(cut=true)xrot(-90){
|
|
|
|
// render() back_half() down(inch*1/20*.325+inch/20*3) nut("1/4-20", thickness=8, diameter=0.5*inch,tolerance="1B");
|
|
|
|
// screw("1/4-20,1/4", head="hex",orient=UP,anchor=BOTTOM,tolerance="1A");
|
|
|
|
|
|
|
|
// down(inch*1/20*2.58) nut("1/4-20", thickness=8, diameter=0.5*inch,tolerance="1B");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
module screw(name, head, thread="coarse", drive, drive_size, oversize=0, spec, length, shank=0, tolerance=undef, details=true, anchor=undef,anchor_head=undef,spin=0, orient=UP)
|
|
|
|
module screw(name, head, thread="coarse", drive, drive_size, oversize=0, spec, length, shank=0, tolerance=undef, details=true, anchor=undef,anchor_head=undef,spin=0, orient=UP)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -998,7 +998,7 @@ module screw(name, head, thread="coarse", drive, drive_size, oversize=0, spec, l
|
|
|
|
head_anchor = is_def(anchor_head);
|
|
|
|
head_anchor = is_def(anchor_head);
|
|
|
|
attachable(
|
|
|
|
attachable(
|
|
|
|
d = head_anchor ? head_size[0] : diameter, // This code should be tweaked to pass diameter and length more cleanly
|
|
|
|
d = head_anchor ? head_size[0] : diameter, // This code should be tweaked to pass diameter and length more cleanly
|
|
|
|
l = head_anchor ? head_size[2] : length,
|
|
|
|
l = head_anchor ? head_size[2] : length,
|
|
|
|
orient = orient,
|
|
|
|
orient = orient,
|
|
|
|
anchor = first_defined([anchor, anchor_head, BOTTOM]),
|
|
|
|
anchor = first_defined([anchor, anchor_head, BOTTOM]),
|
|
|
|
//offset = head_anchor ? [0,0,head_height/2] : [0,0,-length/2],
|
|
|
|
//offset = head_anchor ? [0,0,head_height/2] : [0,0,-length/2],
|
|
|
@ -1015,21 +1015,21 @@ module screw(name, head, thread="coarse", drive, drive_size, oversize=0, spec, l
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (threaded>0)
|
|
|
|
if (threaded>0)
|
|
|
|
intersection(){
|
|
|
|
intersection(){
|
|
|
|
down(unthreaded)
|
|
|
|
down(unthreaded)
|
|
|
|
rod(spec, length=threaded+eps, tolerance=tolerance, $fn=sides, anchor=TOP );
|
|
|
|
_rod(spec, length=threaded+eps, tolerance=tolerance, $fn=sides, anchor=TOP );
|
|
|
|
if (details)
|
|
|
|
if (details)
|
|
|
|
up(.01)cyl(d=diameter, l=length+.02+eps, chamfer1 = pitch/2, chamfer2 = headless ? pitch/2 : -pitch/2, anchor=TOP, $fn=sides);
|
|
|
|
up(.01)cyl(d=diameter, l=length+.02+eps, chamfer1 = pitch/2, chamfer2 = headless ? pitch/2 : -pitch/2, anchor=TOP, $fn=sides);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
driver(spec);
|
|
|
|
_driver(spec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
children();
|
|
|
|
children();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module driver(spec)
|
|
|
|
module _driver(spec)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
drive = struct_val(spec,"drive");
|
|
|
|
drive = struct_val(spec,"drive");
|
|
|
|
echo(drive=drive);
|
|
|
|
echo(drive=drive);
|
|
|
@ -1049,13 +1049,13 @@ module driver(spec)
|
|
|
|
if (drive=="phillips") phillips_drive(size=str("#",drive_size), shaft=diameter,anchor=BOTTOM);
|
|
|
|
if (drive=="phillips") phillips_drive(size=str("#",drive_size), shaft=diameter,anchor=BOTTOM);
|
|
|
|
if (drive=="torx") torx_drive(size=drive_size, l=drive_depth+1, center=false);
|
|
|
|
if (drive=="torx") torx_drive(size=drive_size, l=drive_depth+1, center=false);
|
|
|
|
if (drive=="hex") linear_extrude(height=drive_depth+1) hexagon(id=drive_size);
|
|
|
|
if (drive=="hex") linear_extrude(height=drive_depth+1) hexagon(id=drive_size);
|
|
|
|
if (drive=="slot") cuboid([2*struct_val(spec,"head_size"), drive_width, drive_depth+1],anchor=BOTTOM);
|
|
|
|
if (drive=="slot") cuboid([2*struct_val(spec,"head_size"), drive_width, drive_depth+1],anchor=BOTTOM);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function ISO_thread_tolerance(diameter, pitch, internal=false, tolerance=undef) =
|
|
|
|
function _ISO_thread_tolerance(diameter, pitch, internal=false, tolerance=undef) =
|
|
|
|
let(
|
|
|
|
let(
|
|
|
|
P = pitch,
|
|
|
|
P = pitch,
|
|
|
|
H = P*sqrt(3)/2,
|
|
|
|
H = P*sqrt(3)/2,
|
|
|
@ -1085,13 +1085,13 @@ function ISO_thread_tolerance(diameter, pitch, internal=false, tolerance=undef)
|
|
|
|
|
|
|
|
|
|
|
|
T_D1_6 = 0.2 <= P && P <= 0.8 ? 433*P - 190*pow(P,1.22) :
|
|
|
|
T_D1_6 = 0.2 <= P && P <= 0.8 ? 433*P - 190*pow(P,1.22) :
|
|
|
|
P > .8 ? 230 * pow(P,0.7) : undef,
|
|
|
|
P > .8 ? 230 * pow(P,0.7) : undef,
|
|
|
|
T_D1 = [ // Crest diameter tolerance for minor diameter of nut thread
|
|
|
|
T_D1 = [ // Crest diameter tolerance for minor diameter of nut thread
|
|
|
|
[4, 0.63*T_D1_6],
|
|
|
|
[4, 0.63*T_D1_6],
|
|
|
|
[5, 0.8*T_D1_6],
|
|
|
|
[5, 0.8*T_D1_6],
|
|
|
|
[6, T_D1_6],
|
|
|
|
[6, T_D1_6],
|
|
|
|
[7, 1.25*T_D1_6],
|
|
|
|
[7, 1.25*T_D1_6],
|
|
|
|
[8, 1.6*T_D1_6]
|
|
|
|
[8, 1.6*T_D1_6]
|
|
|
|
],
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
|
|
rangepts = [0.99, 1.4, 2.8, 5.6, 11.2, 22.4, 45, 90, 180, 300],
|
|
|
|
rangepts = [0.99, 1.4, 2.8, 5.6, 11.2, 22.4, 45, 90, 180, 300],
|
|
|
|
d_ind = floor(lookup(diameter,zip(rangepts,list_range(len(rangepts))))),
|
|
|
|
d_ind = floor(lookup(diameter,zip(rangepts,list_range(len(rangepts))))),
|
|
|
@ -1105,7 +1105,7 @@ function ISO_thread_tolerance(diameter, pitch, internal=false, tolerance=undef)
|
|
|
|
[6, T_d2_6],
|
|
|
|
[6, T_d2_6],
|
|
|
|
[7, 1.25*T_d2_6],
|
|
|
|
[7, 1.25*T_d2_6],
|
|
|
|
[8, 1.6*T_d2_6],
|
|
|
|
[8, 1.6*T_d2_6],
|
|
|
|
[9, 2*T_d2_6],
|
|
|
|
[9, 2*T_d2_6],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
|
|
T_D2 = [ // Tolerance for pitch diameter of nut thread
|
|
|
|
T_D2 = [ // Tolerance for pitch diameter of nut thread
|
|
|
@ -1119,7 +1119,7 @@ function ISO_thread_tolerance(diameter, pitch, internal=false, tolerance=undef)
|
|
|
|
internal = is_def(internal) ? internal : tolerance[1] != downcase(tolerance[1]),
|
|
|
|
internal = is_def(internal) ? internal : tolerance[1] != downcase(tolerance[1]),
|
|
|
|
internalok = !internal || (
|
|
|
|
internalok = !internal || (
|
|
|
|
len(tolerance)==2 && str_find("GH",tolerance[1])!=undef && str_find("45678",tolerance[0])!=undef),
|
|
|
|
len(tolerance)==2 && str_find("GH",tolerance[1])!=undef && str_find("45678",tolerance[0])!=undef),
|
|
|
|
tol_str = str(tolerance,tolerance),
|
|
|
|
tol_str = str(tolerance,tolerance),
|
|
|
|
externalok = internal || (
|
|
|
|
externalok = internal || (
|
|
|
|
(len(tolerance)==2 || len(tolerance)==4)
|
|
|
|
(len(tolerance)==2 || len(tolerance)==4)
|
|
|
|
&& str_find("efgh", tol_str[1])!=undef
|
|
|
|
&& str_find("efgh", tol_str[1])!=undef
|
|
|
@ -1129,16 +1129,16 @@ function ISO_thread_tolerance(diameter, pitch, internal=false, tolerance=undef)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assert(internalok,str("Invalid internal thread tolerance, ",tolerance,". Must have form <digit><letter>"))
|
|
|
|
assert(internalok,str("Invalid internal thread tolerance, ",tolerance,". Must have form <digit><letter>"))
|
|
|
|
assert(externalok,str("invalid external thread tolerance, ",tolerance,". Must have form <digit><letter> or <digit><letter><digit><letter>"))
|
|
|
|
assert(externalok,str("invalid external thread tolerance, ",tolerance,". Must have form <digit><letter> or <digit><letter><digit><letter>"))
|
|
|
|
let(
|
|
|
|
let(
|
|
|
|
tol_num_pitch = str_num(tol_str[0]),
|
|
|
|
tol_num_pitch = str_num(tol_str[0]),
|
|
|
|
tol_num_crest = str_num(tol_str[2]),
|
|
|
|
tol_num_crest = str_num(tol_str[2]),
|
|
|
|
tol_letter = tol_str[1]
|
|
|
|
tol_letter = tol_str[1]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assert(tol_letter==tol_str[3],str("Invalid tolerance, ",tolerance,". Cannot mix different letters"))
|
|
|
|
assert(tol_letter==tol_str[3],str("Invalid tolerance, ",tolerance,". Cannot mix different letters"))
|
|
|
|
internal ?
|
|
|
|
internal ?
|
|
|
|
let( // Nut case
|
|
|
|
let( // Nut case
|
|
|
|
//a=echo("nut", tol_letter, tol_num_pitch, tol_num_crest),
|
|
|
|
//a=echo("nut", tol_letter, tol_num_pitch, tol_num_crest),
|
|
|
|
fdev = struct_val(EI,tol_letter)/1000,
|
|
|
|
fdev = struct_val(EI,tol_letter)/1000,
|
|
|
|
Tdval = struct_val(T_D1, tol_num_crest)/1000,
|
|
|
|
Tdval = struct_val(T_D1, tol_num_crest)/1000,
|
|
|
|
df= echo(T_D1=T_D1),
|
|
|
|
df= echo(T_D1=T_D1),
|
|
|
|
Td2val = struct_val(T_D2, tol_num_pitch)/1000,
|
|
|
|
Td2val = struct_val(T_D2, tol_num_pitch)/1000,
|
|
|
@ -1151,7 +1151,7 @@ function ISO_thread_tolerance(diameter, pitch, internal=false, tolerance=undef)
|
|
|
|
:
|
|
|
|
:
|
|
|
|
let( // Bolt case
|
|
|
|
let( // Bolt case
|
|
|
|
//a=echo("bolt"),
|
|
|
|
//a=echo("bolt"),
|
|
|
|
fdev = struct_val(es,tol_letter)/1000,
|
|
|
|
fdev = struct_val(es,tol_letter)/1000,
|
|
|
|
Tdval = struct_val(T_d, tol_num_crest)/1000,
|
|
|
|
Tdval = struct_val(T_d, tol_num_crest)/1000,
|
|
|
|
Td2val = struct_val(T_d2, tol_num_pitch)/1000,
|
|
|
|
Td2val = struct_val(T_d2, tol_num_pitch)/1000,
|
|
|
|
mintrunc = P/8,
|
|
|
|
mintrunc = P/8,
|
|
|
@ -1164,7 +1164,7 @@ function ISO_thread_tolerance(diameter, pitch, internal=false, tolerance=undef)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
[["pitch",P],["d_major",xdiam], ["d_pitch",pitchdiam], ["d_minor",bot],["basic",[mindiam,pdiam,diameter]]];
|
|
|
|
[["pitch",P],["d_major",xdiam], ["d_pitch",pitchdiam], ["d_minor",bot],["basic",[mindiam,pdiam,diameter]]];
|
|
|
|
|
|
|
|
|
|
|
|
function UTS_thread_tolerance(diam, pitch, internal=false, tolerance=undef) =
|
|
|
|
function _UTS_thread_tolerance(diam, pitch, internal=false, tolerance=undef) =
|
|
|
|
let(
|
|
|
|
let(
|
|
|
|
inch = 25.4,
|
|
|
|
inch = 25.4,
|
|
|
|
d = diam/inch, // diameter in inches
|
|
|
|
d = diam/inch, // diameter in inches
|
|
|
@ -1176,7 +1176,7 @@ function UTS_thread_tolerance(diam, pitch, internal=false, tolerance=undef) =
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assert(tolOK,str("Tolerance was ",tolerance,". Must be one of 1A, 2A, 3A, 1B, 2B, 3B"))
|
|
|
|
assert(tolOK,str("Tolerance was ",tolerance,". Must be one of 1A, 2A, 3A, 1B, 2B, 3B"))
|
|
|
|
let(
|
|
|
|
let(
|
|
|
|
LE = 9*P, // length of engagement. Is this right?
|
|
|
|
LE = 9*P, // length of engagement. Is this right?
|
|
|
|
pitchtol_2A = 0.0015*pow(d,1/3) + 0.0015*sqrt(LE) + 0.015*pow(P,2/3),
|
|
|
|
pitchtol_2A = 0.0015*pow(d,1/3) + 0.0015*sqrt(LE) + 0.015*pow(P,2/3),
|
|
|
|
pitchtol_table = [
|
|
|
|
pitchtol_table = [
|
|
|
|
["1A", 1.500*pitchtol_2A],
|
|
|
|
["1A", 1.500*pitchtol_2A],
|
|
|
@ -1193,7 +1193,7 @@ function UTS_thread_tolerance(diam, pitch, internal=false, tolerance=undef) =
|
|
|
|
pitchtol+pitch/4/sqrt(3), // Internal case
|
|
|
|
pitchtol+pitch/4/sqrt(3), // Internal case
|
|
|
|
minortol = tolerance=="1B" || tolerance=="2B" ?
|
|
|
|
minortol = tolerance=="1B" || tolerance=="2B" ?
|
|
|
|
(
|
|
|
|
(
|
|
|
|
d < 0.25 ? constrain(0.05*pow(P,2/3)+0.03*P/d - 0.002, 0.25*P-0.4*P*P, 0.394*P)
|
|
|
|
d < 0.25 ? constrain(0.05*pow(P,2/3)+0.03*P/d - 0.002, 0.25*P-0.4*P*P, 0.394*P)
|
|
|
|
: (P > 0.25 ? 0.15*P : 0.25*P-0.4*P*P)
|
|
|
|
: (P > 0.25 ? 0.15*P : 0.25*P-0.4*P*P)
|
|
|
|
) :
|
|
|
|
) :
|
|
|
|
tolerance=="3B" ? constrain(0.05*pow(P,2/3)+0.03*P/d - 0.002, P<1/13 ? 0.12*P : 0.23*P-1.5*P*P, 0.394*P)
|
|
|
|
tolerance=="3B" ? constrain(0.05*pow(P,2/3)+0.03*P/d - 0.002, P<1/13 ? 0.12*P : 0.23*P-1.5*P*P, 0.394*P)
|
|
|
@ -1202,11 +1202,11 @@ function UTS_thread_tolerance(diam, pitch, internal=false, tolerance=undef) =
|
|
|
|
//g=echo(pta2 = pitchtol_2A),
|
|
|
|
//g=echo(pta2 = pitchtol_2A),
|
|
|
|
// ff=echo(minortol=minortol, pitchtol=pitchtol, majortol=majortol),
|
|
|
|
// ff=echo(minortol=minortol, pitchtol=pitchtol, majortol=majortol),
|
|
|
|
basic_minordiam = d - 5/4*H,
|
|
|
|
basic_minordiam = d - 5/4*H,
|
|
|
|
basic_pitchdiam = d - 3/4*H,
|
|
|
|
basic_pitchdiam = d - 3/4*H,
|
|
|
|
majordiam = internal ? [d,d] : // A little confused here, paragraph 8.3.2
|
|
|
|
majordiam = internal ? [d,d] : // A little confused here, paragraph 8.3.2
|
|
|
|
[d-allowance-majortol, d-allowance],
|
|
|
|
[d-allowance-majortol, d-allowance],
|
|
|
|
//ffda=echo(allowance=allowance, majortol=majortol, "*****************************"),
|
|
|
|
//ffda=echo(allowance=allowance, majortol=majortol, "*****************************"),
|
|
|
|
pitchdiam = internal ? [basic_pitchdiam, basic_pitchdiam + pitchtol]
|
|
|
|
pitchdiam = internal ? [basic_pitchdiam, basic_pitchdiam + pitchtol]
|
|
|
|
: [majordiam[1] - 3/4*H-pitchtol, majordiam[1]-3/4*H],
|
|
|
|
: [majordiam[1] - 3/4*H-pitchtol, majordiam[1]-3/4*H],
|
|
|
|
minordiam = internal ? [basic_minordiam, basic_minordiam + minortol]
|
|
|
|
minordiam = internal ? [basic_minordiam, basic_minordiam + minortol]
|
|
|
|
: [pitchdiam[0] - 3/4*H, basic_minordiam - allowance - H/8] // the -H/8 is for the UNR case, 0 for UN case
|
|
|
|
: [pitchdiam[0] - 3/4*H, basic_minordiam - allowance - H/8] // the -H/8 is for the UNR case, 0 for UN case
|
|
|
@ -1230,26 +1230,26 @@ function _exact_thread_tolerance(d,P) =
|
|
|
|
// Description:
|
|
|
|
// Description:
|
|
|
|
// Determines actual thread geometry for a given screw with specified tolerance. If tolerance is omitted the default is used. If tolerance
|
|
|
|
// Determines actual thread geometry for a given screw with specified tolerance. If tolerance is omitted the default is used. If tolerance
|
|
|
|
// is "none" or 0 then return the nominal thread geometry.
|
|
|
|
// is "none" or 0 then return the nominal thread geometry.
|
|
|
|
//
|
|
|
|
// .
|
|
|
|
// The return value is a structure with the following fields:
|
|
|
|
// The return value is a structure with the following fields:
|
|
|
|
// - pitch: the thread pitch
|
|
|
|
// - pitch: the thread pitch
|
|
|
|
// - d_major: major diameter range
|
|
|
|
// - d_major: major diameter range
|
|
|
|
// - d_pitch: pitch diameter range
|
|
|
|
// - d_pitch: pitch diameter range
|
|
|
|
// - d_minor: minor diameter range
|
|
|
|
// - d_minor: minor diameter range
|
|
|
|
// - basic: vector `[minor, pitch, major]` of the nominal or "basic" diameters for the threads
|
|
|
|
// - basic: vector `[minor, pitch, major]` of the nominal or "basic" diameters for the threads
|
|
|
|
function thread_specification(screw_spec, internal=false, tolerance=undef) =
|
|
|
|
function thread_specification(screw_spec, internal=false, tolerance=undef) =
|
|
|
|
let( diam = struct_val(screw_spec, "diameter"),
|
|
|
|
let( diam = struct_val(screw_spec, "diameter"),
|
|
|
|
pitch = struct_val(screw_spec, "pitch")
|
|
|
|
pitch = struct_val(screw_spec, "pitch")
|
|
|
|
,k=
|
|
|
|
,k=
|
|
|
|
tolerance == 0 || tolerance=="none" ? _exact_thread_tolerance(diam, pitch) :
|
|
|
|
tolerance == 0 || tolerance=="none" ? _exact_thread_tolerance(diam, pitch) :
|
|
|
|
struct_val(screw_spec,"system") == "ISO" ? ISO_thread_tolerance(diam, pitch, internal, tolerance) :
|
|
|
|
struct_val(screw_spec,"system") == "ISO" ? _ISO_thread_tolerance(diam, pitch, internal, tolerance) :
|
|
|
|
struct_val(screw_spec,"system") == "UTS" ? UTS_thread_tolerance(diam, pitch, internal, tolerance) :
|
|
|
|
struct_val(screw_spec,"system") == "UTS" ? _UTS_thread_tolerance(diam, pitch, internal, tolerance) :
|
|
|
|
assert(false,"Unknown screw system ",struct_val(screw_spec,"system")),
|
|
|
|
assert(false,"Unknown screw system ",struct_val(screw_spec,"system")),
|
|
|
|
fff=echo(k))
|
|
|
|
fff=echo(k))
|
|
|
|
k;
|
|
|
|
k;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function thread_profile(thread) =
|
|
|
|
function _thread_profile(thread) =
|
|
|
|
let(
|
|
|
|
let(
|
|
|
|
pitch = struct_val(thread,"pitch"),
|
|
|
|
pitch = struct_val(thread,"pitch"),
|
|
|
|
basicrad = struct_val(thread,"basic")/2,
|
|
|
|
basicrad = struct_val(thread,"basic")/2,
|
|
|
@ -1258,7 +1258,7 @@ function thread_profile(thread) =
|
|
|
|
meanmajorrad = mean(struct_val(thread,"d_major"))/2,
|
|
|
|
meanmajorrad = mean(struct_val(thread,"d_major"))/2,
|
|
|
|
depth = (meanmajorrad-meanminorrad)/pitch,
|
|
|
|
depth = (meanmajorrad-meanminorrad)/pitch,
|
|
|
|
crestwidth = (pitch/2 - 2*(meanmajorrad-meanpitchrad)/sqrt(3))/pitch
|
|
|
|
crestwidth = (pitch/2 - 2*(meanmajorrad-meanpitchrad)/sqrt(3))/pitch
|
|
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
[
|
|
|
|
[
|
|
|
|
[-1/2,-depth],
|
|
|
|
[-1/2,-depth],
|
|
|
@ -1267,7 +1267,7 @@ function thread_profile(thread) =
|
|
|
|
[crestwidth + 2*depth/sqrt(3)-1/2,-depth]
|
|
|
|
[crestwidth + 2*depth/sqrt(3)-1/2,-depth]
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
function thread_profile_e(thread) =
|
|
|
|
function _thread_profile_e(thread) =
|
|
|
|
let(
|
|
|
|
let(
|
|
|
|
pitch = struct_val(thread,"pitch"),
|
|
|
|
pitch = struct_val(thread,"pitch"),
|
|
|
|
basicrad = struct_val(thread,"basic")/2,
|
|
|
|
basicrad = struct_val(thread,"basic")/2,
|
|
|
@ -1276,7 +1276,7 @@ function thread_profile_e(thread) =
|
|
|
|
meanmajorrad = mean(struct_val(thread,"d_major"))/2,
|
|
|
|
meanmajorrad = mean(struct_val(thread,"d_major"))/2,
|
|
|
|
depth = (meanmajorrad-meanminorrad)/pitch,
|
|
|
|
depth = (meanmajorrad-meanminorrad)/pitch,
|
|
|
|
crestwidth = (pitch/2 - 2*(meanmajorrad-meanpitchrad)/sqrt(3))/pitch
|
|
|
|
crestwidth = (pitch/2 - 2*(meanmajorrad-meanpitchrad)/sqrt(3))/pitch
|
|
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
[
|
|
|
|
[
|
|
|
|
[-1/2,-1], // -1 instead of -depth?
|
|
|
|
[-1/2,-1], // -1 instead of -depth?
|
|
|
@ -1286,25 +1286,26 @@ function thread_profile_e(thread) =
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module rod(spec, length, tolerance, orient=UP, spin=0, anchor=CENTER)
|
|
|
|
module _rod(spec, length, tolerance, orient=UP, spin=0, anchor=CENTER)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
threadspec = thread_specification(spec, internal=false, tolerance=tolerance);
|
|
|
|
threadspec = thread_specification(spec, internal=false, tolerance=tolerance);
|
|
|
|
echo(d_major_mean = mean(struct_val(threadspec, "d_major")));
|
|
|
|
echo(d_major_mean = mean(struct_val(threadspec, "d_major")));
|
|
|
|
echo(bolt_profile=thread_profile(threadspec));
|
|
|
|
echo(bolt_profile=_thread_profile(threadspec));
|
|
|
|
|
|
|
|
|
|
|
|
trapezoidal_threaded_rod( d=mean(struct_val(threadspec, "d_major")),
|
|
|
|
trapezoidal_threaded_rod( d=mean(struct_val(threadspec, "d_major")),
|
|
|
|
l=length,
|
|
|
|
l=length,
|
|
|
|
pitch = struct_val(threadspec, "pitch"),
|
|
|
|
pitch = struct_val(threadspec, "pitch"),
|
|
|
|
profile = thread_profile(threadspec),left_handed=false,
|
|
|
|
profile = _thread_profile(threadspec),left_handed=false,
|
|
|
|
bevel=false, orient=orient, anchor=anchor, spin=spin);
|
|
|
|
bevel=false, orient=orient, anchor=anchor, spin=spin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Module: nut()
|
|
|
|
// Module: nut()
|
|
|
|
// Usage: nut([name],[thread],[oversize],[spec], [diameter],[thickness], [tolerance], [details])
|
|
|
|
// Usage:
|
|
|
|
|
|
|
|
// nut([name],[thread],[oversize],[spec],[diameter],[thickness],[tolerance],[details])
|
|
|
|
// Description:
|
|
|
|
// Description:
|
|
|
|
// The name, thread and oversize parameters are described under `screw_info()`
|
|
|
|
// The name, thread and oversize parameters are described under `screw_info()`
|
|
|
|
//
|
|
|
|
// .
|
|
|
|
// The tolerance determines the actual thread sizing based on the
|
|
|
|
// The tolerance determines the actual thread sizing based on the
|
|
|
|
// nominal size. For UTS threads it is either "1B", "2B" or "3B", in
|
|
|
|
// nominal size. For UTS threads it is either "1B", "2B" or "3B", in
|
|
|
|
// order of increasing tightness. The default tolerance is "2B", which
|
|
|
|
// order of increasing tightness. The default tolerance is "2B", which
|
|
|
@ -1313,15 +1314,15 @@ module rod(spec, length, tolerance, orient=UP, spin=0, anchor=CENTER)
|
|
|
|
// from the nominal size, and must be "G", or "H", where "G" is looser
|
|
|
|
// from the nominal size, and must be "G", or "H", where "G" is looser
|
|
|
|
// he loosest and "H" means no gap. The number specifies the allowed
|
|
|
|
// he loosest and "H" means no gap. The number specifies the allowed
|
|
|
|
// range (variability) of the thread heights. Smaller numbers give tigher tolerances. It must be a value from
|
|
|
|
// range (variability) of the thread heights. Smaller numbers give tigher tolerances. It must be a value from
|
|
|
|
// 4-8, so an allowed (loose) tolerance is "7G". The default ISO tolerance is "6H".
|
|
|
|
// 4-8, so an allowed (loose) tolerance is "7G". The default ISO tolerance is "6H".
|
|
|
|
// Arguments:
|
|
|
|
// Arguments:
|
|
|
|
// name = screw specification, e.g. "M5x1" or "#8-32"
|
|
|
|
// name = screw specification, e.g. "M5x1" or "#8-32"
|
|
|
|
// thread = thread type or specification. Default: "coarse"
|
|
|
|
// thread = thread type or specification. Default: "coarse"
|
|
|
|
// oversize = amount to increase screw diameter for clearance holes. Default: 0
|
|
|
|
// oversize = amount to increase screw diameter for clearance holes. Default: 0
|
|
|
|
// spec = screw specification from `screw_info()`. If you specify this you can omit all the preceeding parameters.
|
|
|
|
// spec = screw specification from `screw_info()`. If you specify this you can omit all the preceeding parameters.
|
|
|
|
// thickness = thickness of bolt (in mm)
|
|
|
|
// thickness = thickness of bolt (in mm)
|
|
|
|
// details = toggle some details in rendering. Default: false
|
|
|
|
// details = toggle some details in rendering. Default: false
|
|
|
|
// tolerance = nut tolerance. Determines actual nut thread geometry based on nominal sizing. Default is "2B" for UTS and "6H" for ISO.
|
|
|
|
// tolerance = nut tolerance. Determines actual nut thread geometry based on nominal sizing. Default is "2B" for UTS and "6H" for ISO.
|
|
|
|
module nut(name, thread="coarse", oversize=0, spec, diameter, thickness, tolerance=undef, details=true, anchor=BOTTOM,spin=0, orient=UP)
|
|
|
|
module nut(name, thread="coarse", oversize=0, spec, diameter, thickness, tolerance=undef, details=true, anchor=BOTTOM,spin=0, orient=UP)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
spec = is_def(spec) ? spec : screw_info(name, thread=thread, oversize=oversize);
|
|
|
|
spec = is_def(spec) ? spec : screw_info(name, thread=thread, oversize=oversize);
|
|
|
@ -1330,14 +1331,14 @@ module nut(name, thread="coarse", oversize=0, spec, diameter, thickness, toleran
|
|
|
|
echo(nut_minor_diam = mean(struct_val(threadspec,"d_minor")));
|
|
|
|
echo(nut_minor_diam = mean(struct_val(threadspec,"d_minor")));
|
|
|
|
trapezoidal_threaded_nut(
|
|
|
|
trapezoidal_threaded_nut(
|
|
|
|
od=diameter, id=mean(struct_val(threadspec, "d_major")), h=thickness,
|
|
|
|
od=diameter, id=mean(struct_val(threadspec, "d_major")), h=thickness,
|
|
|
|
pitch=struct_val(threadspec, "pitch"),
|
|
|
|
pitch=struct_val(threadspec, "pitch"),
|
|
|
|
profile=thread_profile(threadspec),
|
|
|
|
profile=_thread_profile(threadspec),
|
|
|
|
bevel=false,anchor=anchor,spin=spin,orient=orient);
|
|
|
|
bevel=false,anchor=anchor,spin=spin,orient=orient);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _is_positive(x) = is_num(x) && x>0;
|
|
|
|
function _is_positive(x) = is_num(x) && x>0;
|
|
|
|
|
|
|
|
|
|
|
|
function _validate_screw_spec(spec) = let(
|
|
|
|
function _validate_screw_spec(spec) = let(
|
|
|
|
f=struct_echo(spec),
|
|
|
|
f=struct_echo(spec),
|
|
|
|
systemOK = in_list(struct_val(spec,"system"), ["UTS","ISO"]),
|
|
|
|
systemOK = in_list(struct_val(spec,"system"), ["UTS","ISO"]),
|
|
|
@ -1352,8 +1353,8 @@ function _validate_screw_spec(spec) = let(
|
|
|
|
driveOK = is_undef(drive) || drive=="none"
|
|
|
|
driveOK = is_undef(drive) || drive=="none"
|
|
|
|
|| (
|
|
|
|
|| (
|
|
|
|
_is_positive(struct_val(spec, "drive_depth")) &&
|
|
|
|
_is_positive(struct_val(spec, "drive_depth")) &&
|
|
|
|
(
|
|
|
|
(
|
|
|
|
in_list(drive, ["torx","hex"])
|
|
|
|
in_list(drive, ["torx","hex"])
|
|
|
|
|| (drive=="phillips" && _is_positive(struct_val(spec, "drive_diameter")) &&
|
|
|
|
|| (drive=="phillips" && _is_positive(struct_val(spec, "drive_diameter")) &&
|
|
|
|
_is_positive(struct_val(spec, "drive_width")) &&
|
|
|
|
_is_positive(struct_val(spec, "drive_width")) &&
|
|
|
|
_is_positive(struct_val(spec, "drive_width")))
|
|
|
|
_is_positive(struct_val(spec, "drive_width")))
|
|
|
|