From 86e4e3d89265c232a337362fd6dac147437a6dc8 Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Sat, 23 May 2020 17:57:48 -0700 Subject: [PATCH 01/12] Fixed stale ref to rounded_prismoid() --- examples/attachments.scad | 3 ++- version.scad | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/attachments.scad b/examples/attachments.scad index a0e8ed1..238b3c1 100644 --- a/examples/attachments.scad +++ b/examples/attachments.scad @@ -1,9 +1,10 @@ include +include $fn=32; cuboid([60,40,40], rounding=5, edges=edges("Z"), anchor=BOTTOM) { - attach(TOP, BOTTOM) rounded_prismoid([60,40],[20,20], h=50, r1=5, r2=10) { + attach(TOP, BOTTOM) prismoid([60,40],[20,20], h=50, rounding1=5, rounding2=10) { attach(TOP) cylinder(d=20, h=30, center=false) { attach(TOP) cylinder(d1=50, d2=30, h=12, center=false); } diff --git a/version.scad b/version.scad index 25c816a..cfb828e 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,319]; +BOSL_VERSION = [2,0,320]; // Section: BOSL Library Version Functions From 719a80c5d01dc5d4ae0ade0ac3f4857c5af71653 Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Sat, 23 May 2020 19:17:32 -0700 Subject: [PATCH 02/12] Tweak docs gen to allow a lone period on a line to break a paragraph. --- WRITING_DOCS.md | 38 ++++++++++++++++++++++++-------------- scripts/docs_gen.py | 6 +++++- version.scad | 2 +- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/WRITING_DOCS.md b/WRITING_DOCS.md index 3e23451..19ee8e1 100644 --- a/WRITING_DOCS.md +++ b/WRITING_DOCS.md @@ -19,8 +19,8 @@ LibFile blocks can be followed by multiple lines that can be added as markdown t // You just need to make sure that each line is indented, with // at least three spaces after the comment marker. You can // denote a paragraph break with a comment line with three -// trailing spaces. -// +// trailing spaces, or just a period. +// . // The end of the block is denoted by a line without a comment. ``` @@ -33,12 +33,12 @@ Sections can also include Figures; images generated from code that is not shown ``` // Section: Foobar // You can have several lines of markdown formatted text here. -// You just need to make sure that each line is indented with +// You just need to make sure that each line is indented, with // at least three spaces after the comment marker. You can // denote a paragraph break with a comment line with three -// trailing spaces. -// -// The end of the block is denoted by a line without a comment, +// trailing spaces, or just a period. +// . +// The end of the block is denoted by a line without a comment. // or a line that is unindented after the comment. // Figure: Figure description // cylinder(h=100, d1=75, d2=50); @@ -70,25 +70,28 @@ Valid sub-blocks are: - `Status: DEPRECATED, use blah instead.` - Optional, used to denote deprecation. - `Usage: Optional Usage Title` - Optional. Multiple allowed. Followed by an indented block of usage patterns. Optional arguments should be in braces like `[opt]`. Alternate args should be separated by a vertical bar like `r|d`. - `Description:` - Can be single-line or a multi-line block of the description. +- `Figure: Optional Figure Title` - Optional. Multiple allowed. Followed by a multi-line code block used to create a figure image. The code will not be shown. All figures will follow the Description block. - `Arguments:` - Denotes start of an indented block of argument descriptions. Each line has the argument name, a space, an equals, another space, then the description for the argument all on one line. Like `arg = The argument description`. If you really need to explain an argument in longer form, explain it in the Description. - `Side Effects:` - Denotes the start of a block describing the side effects, such as `$special_var`s that are set. - `Extra Anchors:` - Denotes the start of an indented block of available non-standard named anchors for a part. - `Example:` - Denotes the beginning of a multi-line example code block. - `Examples:` - Denotes the beginning of a block of examples, where each line will be shows as a separate example with a separate image if needed. -Modules blocks will generate images for each example block. Function and Constant blocks will only generate images for example blocks if they have `2D` or `3D` tags. Example blocks can have tags added by putting then inside parentheses before the colon. Ie: `Examples(BigFlatSpin):`. +Modules blocks will generate images for each example or figure block. Function and Constant blocks will only generate images for example blocks if they have `2D` or `3D` tags. Example and figure blocks can have tags added by putting then inside parentheses before the colon. Ie: `Examples(BigFlatSpin):` or `Figure(2D):`. The full set of optional example tags are: - `2D`: Orient camera in a top-down view for showing 2D objects. - `3D`: Orient camera in an oblique view for showing 3D objects. Used to force an Example sub-block to generate an image in Function and Constant blocks. -- `Spin`: Animate camera orbit around the `[0,1,1]` axis to display all sides of an object. -- `FlatSpin`: Animate camera orbit around the Z axis, above the XY plane. -- `Edges`: Highlight face edges. -- `FR`: Force full rendering from OpenSCAD, instead of the normal preview. +- `NORENDER`: Don't generate an image for this example. - `Small`: Make the image small sized. (The default) - `Med`: Make the image medium sized. - `Big`: Make the image big sized. +- `Huge`: Make the image huge sized. +- `Spin`: Animate camera orbit around the `[0,1,1]` axis to display all sides of an object. +- `FlatSpin`: Animate camera orbit around the Z axis, above the XY plane. +- `FR`: Force full rendering from OpenSCAD, instead of the normal preview. +- `Edges`: Highlight face edges. Indentation is important, as it denotes the end of sub-block. @@ -105,12 +108,19 @@ Indentation is important, as it denotes the end of sub-block. // A longer, multi-line description. // All description blocks are added together. // You _can_ use *markdown* notation as well. -// You can have paragraph breaks by having a blank line with -// only enough trailing spaces to match indentation like this: -// +// You can have paragraph breaks by having a +// line with just a period, like this: +// . // You can end multi-line blocks by un-indenting the next // line, or by using a comment with no spaces like this: // +// Figure: Figure description +// cylinder(h=100, d1=75, d2=50); +// up(100) cylinder(h=100, d1=50, d2=75); +// Figure(Spin): Animated figure that spins to show all faces. +// cube([10,100,50], center=true); +// cube([100,10,30], center=true); +// // Arguments: // foo = This is the description of the foo argument. All on one line. // bar = This is the description of the bar argument. All on one line. diff --git a/scripts/docs_gen.py b/scripts/docs_gen.py index b0c8ace..cd0ee4b 100755 --- a/scripts/docs_gen.py +++ b/scripts/docs_gen.py @@ -82,6 +82,8 @@ def get_comment_block(lines, prefix, blanks=1): break else: blankcnt = 0 + if line == ".": + line == "" out.append(line.rstrip()) return (lines, out) @@ -233,7 +235,9 @@ class ImageProcessing(object): with open(scriptfile, "w") as f: f.write(script) - if "Big" in extype: + if "Huge" in extype: + imgsize = (800, 600) + elif "Big" in extype: imgsize = (640, 480) elif "Med" in extype or "distribute" in script or "show_anchors" in script: imgsize = (480, 360) diff --git a/version.scad b/version.scad index cfb828e..86be24b 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,320]; +BOSL_VERSION = [2,0,321]; // Section: BOSL Library Version Functions From 9c2cf53b2db2e647b7d38621fcccc56831b90b8b Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Sat, 23 May 2020 19:22:44 -0700 Subject: [PATCH 03/12] Renamed find_circle_tangents() to circle_point_tangents() --- geometry.scad | 8 ++++---- tests/test_geometry.scad | 6 +++--- version.scad | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/geometry.scad b/geometry.scad index fb96fb1..87c3865 100644 --- a/geometry.scad +++ b/geometry.scad @@ -1070,9 +1070,9 @@ function find_circle_3points(pt1, pt2, pt3) = -// Function: find_circle_tangents() +// Function: circle_point_tangents() // Usage: -// tangents = find_circle_tangents(r|d, cp, pt); +// tangents = circle_point_tangents(r|d, cp, pt); // Description: // Given a circle and a point outside that circle, finds the tangent point(s) on the circle for a // line passing through the point. Returns list of zero or more sublists of [ANG, TANGPT] @@ -1083,12 +1083,12 @@ function find_circle_3points(pt1, pt2, pt3) = // pt = The coordinates of the external point. // Example(2D): // cp = [-10,-10]; r = 30; pt = [30,10]; -// tanpts = subindex(find_circle_tangents(r=r, cp=cp, pt=pt),1); +// tanpts = subindex(circle_point_tangents(r=r, cp=cp, pt=pt),1); // color("yellow") translate(cp) circle(r=r); // color("cyan") for(tp=tanpts) {stroke([tp,pt]); stroke([tp,cp]);} // color("red") move_copies(tanpts) circle(d=3,$fn=12); // color("blue") move_copies([cp,pt]) circle(d=3,$fn=12); -function find_circle_tangents(r, d, cp, pt) = +function circle_point_tangents(r, d, cp, pt) = assert(is_num(r) || is_num(d)) assert(is_vector(cp)) assert(is_vector(pt)) diff --git a/tests/test_geometry.scad b/tests/test_geometry.scad index 47f28f3..ce69361 100644 --- a/tests/test_geometry.scad +++ b/tests/test_geometry.scad @@ -294,8 +294,8 @@ module test_find_circle_3points() { test_find_circle_3points(); -module test_find_circle_tangents() { - tangs = find_circle_tangents(r=50,cp=[0,0],pt=[50*sqrt(2),0]); +module test_circle_point_tangents() { + tangs = circle_point_tangents(r=50,cp=[0,0],pt=[50*sqrt(2),0]); assert(approx(subindex(tangs,0), [45,-45])); expected = [for (ang=subindex(tangs,0)) polar_to_xy(50,ang)]; got = subindex(tangs,1); @@ -304,7 +304,7 @@ module test_find_circle_tangents() { assert(approx(flatten(got), flatten(expected))); } } -test_find_circle_tangents(); +test_circle_point_tangents(); module test_tri_calc() { diff --git a/version.scad b/version.scad index 86be24b..bdfa4b3 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,321]; +BOSL_VERSION = [2,0,322]; // Section: BOSL Library Version Functions From f3127d96a2a5b20c573bc6f30775a0abce106240 Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Sun, 24 May 2020 01:03:37 -0700 Subject: [PATCH 04/12] Formatting tweaks. --- geometry.scad | 52 ++++++++++++++++++++++++++++++--------------------- version.scad | 2 +- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/geometry.scad b/geometry.scad index 87c3865..09882a7 100644 --- a/geometry.scad +++ b/geometry.scad @@ -1124,8 +1124,8 @@ function circle_point_tangents(r, d, cp, pt) = // c1 = [3,4]; r1 = 2; // c2 = [7,10]; r2 = 3; // pts = circle_circle_tangents(c1,r1,c2,r2); -// stroke(move(c1,p=circle(r=r1)),width=.1,closed=true); -// stroke(move(c2,p=circle(r=r2)),width=.1,closed=true); +// move(c1) stroke(circle(r=r1), width=.1, closed=true); +// move(c2) stroke(circle(r=r2), width=.1, closed=true); // colors = ["green","black","blue","red"]; // for(i=[0:len(pts)-1]) color(colors[i]) stroke(pts[i],width=.1); // Example(2D): Circles overlap so only exterior tangents exist. @@ -1133,8 +1133,8 @@ function circle_point_tangents(r, d, cp, pt) = // c1 = [4,4]; r1 = 3; // c2 = [7,7]; r2 = 2; // pts = circle_circle_tangents(c1,r1,c2,r2); -// stroke(move(c1,p=circle(r=r1)),width=.1,closed=true); -// stroke(move(c2,p=circle(r=r2)),width=.1,closed=true); +// move(c1) stroke(circle(r=r1), width=.1, closed=true); +// move(c2) stroke(circle(r=r2), width=.1, closed=true); // colors = ["green","black","blue","red"]; // for(i=[0:len(pts)-1]) color(colors[i]) stroke(pts[i],width=.1); // Example(2D): Circles are tangent. Only exterior tangents are returned. The degenerate internal tangent is not returned. @@ -1142,8 +1142,8 @@ function circle_point_tangents(r, d, cp, pt) = // c1 = [4,4]; r1 = 4; // c2 = [4,10]; r2 = 2; // pts = circle_circle_tangents(c1,r1,c2,r2); -// stroke(move(c1,p=circle(r=r1)),width=.1,closed=true); -// stroke(move(c2,p=circle(r=r2)),width=.1,closed=true); +// move(c1) stroke(circle(r=r1), width=.1, closed=true); +// move(c2) stroke(circle(r=r2), width=.1, closed=true); // colors = ["green","black","blue","red"]; // for(i=[0:1:len(pts)-1]) color(colors[i]) stroke(pts[i],width=.1); // Example(2D): One circle is inside the other: no tangents exist. If the interior circle is tangent the single degenerate tangent will not be returned. @@ -1151,22 +1151,32 @@ function circle_point_tangents(r, d, cp, pt) = // c1 = [4,4]; r1 = 4; // c2 = [5,5]; r2 = 2; // pts = circle_circle_tangents(c1,r1,c2,r2); -// stroke(move(c1,p=circle(r=r1)),width=.1,closed=true); -// stroke(move(c2,p=circle(r=r2)),width=.1,closed=true); -// echo(pts); // Returns [] +// move(c1) stroke(circle(r=r1), width=.1, closed=true); +// move(c2) stroke(circle(r=r2), width=.1, closed=true); +// echo(pts); // Returns [] function circle_circle_tangents(c1,r1,c2,r2,d1,d2) = - let( - r1 = get_radius(r1=r1,d1=d1), - r2 = get_radius(r1=r2,d1=d2), - Rvals = [r2-r1, r2-r1, -r2-r1, -r2-r1]/norm(c1-c2), - kvals = [-1,1,-1,1], - ext = [1,1,-1,-1], - N = 1-sqr(Rvals[2])>=0 ? 4 : - 1-sqr(Rvals[0])>=0 ? 2 : 0, - coef= [for(i=[0:1:N-1]) [[Rvals[i], -kvals[i]*sqrt(1-sqr(Rvals[i]))], - [kvals[i]*sqrt(1-sqr(Rvals[i])), Rvals[i]]]*unit(c2-c1)] - ) - [for(i=[0:1:N-1]) let(pt=[c1-r1*coef[i], c2-ext[i]*r2*coef[i]]) if (pt[0]!=pt[1]) pt]; + let( + r1 = get_radius(r1=r1,d1=d1), + r2 = get_radius(r1=r2,d1=d2), + Rvals = [r2-r1, r2-r1, -r2-r1, -r2-r1]/norm(c1-c2), + kvals = [-1,1,-1,1], + ext = [1,1,-1,-1], + N = 1-sqr(Rvals[2])>=0 ? 4 : + 1-sqr(Rvals[0])>=0 ? 2 : 0, + coef= [ + for(i=[0:1:N-1]) [ + [Rvals[i], -kvals[i]*sqrt(1-sqr(Rvals[i]))], + [kvals[i]*sqrt(1-sqr(Rvals[i])), Rvals[i]] + ] * unit(c2-c1) + ] + ) [ + for(i=[0:1:N-1]) let( + pt = [ + c1-r1*coef[i], + c2-ext[i]*r2*coef[i] + ] + ) if (pt[0]!=pt[1]) pt + ]; diff --git a/version.scad b/version.scad index bdfa4b3..0b6a0e3 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,322]; +BOSL_VERSION = [2,0,323]; // Section: BOSL Library Version Functions From fe2d59a875b25792516ffcffe37c56633b9f9fa3 Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Sun, 24 May 2020 22:31:36 -0700 Subject: [PATCH 05/12] Getting screws.scad in docs. --- screws.scad | 97 +++++++++++++++++++++++----------------- scripts/make_all_docs.sh | 2 +- version.scad | 2 +- 3 files changed, 57 insertions(+), 44 deletions(-) diff --git a/screws.scad b/screws.scad index e406e46..d461e4f 100644 --- a/screws.scad +++ b/screws.scad @@ -1,8 +1,17 @@ -include -include -include -include -include +////////////////////////////////////////////////////////////////////// +// LibFile: screws.scad +// Functions and modules for creating metric and UTS standard screws and nuts. +// To use, add the following lines to the beginning of your file: +// ``` +// include +// include +// ``` +////////////////////////////////////////////////////////////////////// + +include +include +include +include /* 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,","), length = str_num(commasplit[1]), xdash = str_split(commasplit[0], "-x"), @@ -35,7 +44,7 @@ function parse_screw_name(name) = // drive can be "hex", "phillips", "slot", "torx", or "none" // 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] : let(drive = downcase(drive)) in_list(drive,["hex","phillips", "slot", "torx", "phillips", "none"]) ? [drive, drive_size] : @@ -43,21 +52,22 @@ function parse_drive(drive=undef, drive_size=undef) = substr(drive,0,2)=="ph" ? ["phillips", str_int(substr(drive,2))] : assert(str("Unknown screw drive type ",drive)); + // Function: screw_info() // Usage: // info = screw_info(name, [head], [thread], [drive], [drive_size], [oversize]) // Description: // Look up screw characteristics for the specified screw type. -// +// . // For metric (ISO) `name` is Mx,, 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 -,, 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 // 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 `''` 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 // using a thread count, the number of threads per inch. The length is in inches. -// +// . // If you omit the pitch then a standard screw pitch will be supplied from lookup tables for the screw diameter you have chosen. // For each screw diameter, multiple standard pitches are possible. // For the UTS system these the availble thread types are: @@ -76,7 +86,7 @@ function parse_drive(drive=undef, drive_size=undef) = // produce threads with a pitch of 2mm. The final option is to specify `thread="none"` to produce an unthreaded // screw either to simplify the model or to use for cutting out screw holes. Setting the pitch to zero also produces // an unthreaded screw. If you specify a numeric thread value it will override any value given in `name`. -// +// . // The `head` parameter specifies the type of head the screw will have. Options for the head are // - "flat" // - "flat small" @@ -94,7 +104,7 @@ function parse_drive(drive=undef, drive_size=undef) = // - "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". -// +// . // The `drive` parameter specifies the recess type. Options for the drive are // - "none" // - "phillips" @@ -104,9 +114,9 @@ function parse_drive(drive=undef, drive_size=undef) = // - "ph0", up to "ph4" for phillips of the specified size // - "t" for torx at a specified size, e.g. "t20" // The default drive is "none" -// +// . // Only some combinations of head and drive type are supported. Supported UTS (English) head and drive combinations: -// +// . // Head| Drive // ---|--- // none | hex, torx @@ -119,26 +129,26 @@ function parse_drive(drive=undef, drive_size=undef) = // flat small | phillips, slot // flat large | hex, torx // flat undercut| slot, phillips -// +// . // Supported metric head and drive combinations: -// -// Head| Drive -// ---|--- -// none |hex, torx +// . +// Head | Drive +// ------|----------------- +// none | hex, torx // hex | // socket| hex, torx // pan | slot, phillips // button| hex, torx // cheese| slot, phillips // flat | phillips, slot, hex, torx -// +// . // 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 size is determined automatically from the screw size, but by passing the `drive_size` parameter // you can override the default, or in cases where no default exists you can specify it. -// +// . // 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 @@ -161,8 +171,8 @@ function parse_drive(drive=undef, drive_size=undef) = // drive_size = size of drive recess to override computed value // oversize = amount to increase screw diameter for clearance holes. Default: 0 function screw_info(name, head, thread="coarse", drive, drive_size=undef, oversize=0) = - let(type=parse_screw_name(name), - drive_info = parse_drive(drive, drive_size), + let(type=_parse_screw_name(name), + drive_info = _parse_drive(drive, drive_size), drive=drive_info[0], screwdata = type[0] == "english" ? _screw_info_english(type[1],type[2], head, thread, drive) : @@ -751,6 +761,7 @@ function _screw_info_metric(diam, pitch, head, thread, drive) = head_data ); + // Module: screw_head() // Usage: // screw_head(screw_info, [details]) @@ -799,14 +810,15 @@ module screw_head(screw_info,details=false) { } } + // Module: screw() // Usage: // screw([name],[head],[thread],[drive],[drive_size], [length], [shank], [oversize], [tolerance], [spec], [details], [anchor], [anchor_head], [orient], [spin]) // Description: // Create a screw. -// +// . // Most of these parameters are described in the entry for `screw_info()`. -// +// . // The tolerance determines the actual thread sizing based on the // nominal size. For UTS threads it is either "1A", "2A" or "3A", in // order of increasing tightness. The default tolerance is "2A", which @@ -1016,20 +1028,20 @@ module screw(name, head, thread="coarse", drive, drive_size, oversize=0, spec, l if (threaded>0) intersection(){ 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) 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(); } } -module driver(spec) +module _driver(spec) { drive = struct_val(spec,"drive"); echo(drive=drive); @@ -1055,7 +1067,7 @@ module driver(spec) } -function ISO_thread_tolerance(diameter, pitch, internal=false, tolerance=undef) = +function _ISO_thread_tolerance(diameter, pitch, internal=false, tolerance=undef) = let( P = pitch, H = P*sqrt(3)/2, @@ -1164,7 +1176,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]]]; -function UTS_thread_tolerance(diam, pitch, internal=false, tolerance=undef) = +function _UTS_thread_tolerance(diam, pitch, internal=false, tolerance=undef) = let( inch = 25.4, d = diam/inch, // diameter in inches @@ -1230,7 +1242,7 @@ function _exact_thread_tolerance(d,P) = // Description: // 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. -// +// . // The return value is a structure with the following fields: // - pitch: the thread pitch // - d_major: major diameter range @@ -1242,14 +1254,14 @@ function thread_specification(screw_spec, internal=false, tolerance=undef) = pitch = struct_val(screw_spec, "pitch") ,k= 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") == "UTS" ? UTS_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) : assert(false,"Unknown screw system ",struct_val(screw_spec,"system")), fff=echo(k)) k; -function thread_profile(thread) = +function _thread_profile(thread) = let( pitch = struct_val(thread,"pitch"), basicrad = struct_val(thread,"basic")/2, @@ -1267,7 +1279,7 @@ function thread_profile(thread) = [crestwidth + 2*depth/sqrt(3)-1/2,-depth] ]; -function thread_profile_e(thread) = +function _thread_profile_e(thread) = let( pitch = struct_val(thread,"pitch"), basicrad = struct_val(thread,"basic")/2, @@ -1286,25 +1298,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); 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")), l=length, 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); } // Module: nut() -// Usage: nut([name],[thread],[oversize],[spec], [diameter],[thickness], [tolerance], [details]) +// Usage: +// nut([name],[thread],[oversize],[spec],[diameter],[thickness],[tolerance],[details]) // Description: // The name, thread and oversize parameters are described under `screw_info()` -// +// . // The tolerance determines the actual thread sizing based on the // nominal size. For UTS threads it is either "1B", "2B" or "3B", in // order of increasing tightness. The default tolerance is "2B", which @@ -1331,7 +1344,7 @@ module nut(name, thread="coarse", oversize=0, spec, diameter, thickness, toleran trapezoidal_threaded_nut( od=diameter, id=mean(struct_val(threadspec, "d_major")), h=thickness, pitch=struct_val(threadspec, "pitch"), - profile=thread_profile(threadspec), + profile=_thread_profile(threadspec), bevel=false,anchor=anchor,spin=spin,orient=orient); } diff --git a/scripts/make_all_docs.sh b/scripts/make_all_docs.sh index c69924c..177604a 100755 --- a/scripts/make_all_docs.sh +++ b/scripts/make_all_docs.sh @@ -17,7 +17,7 @@ done if [[ "$FILES" != "" ]]; then PREVIEW_LIBS="$FILES" else - PREVIEW_LIBS="affine arrays attachments beziers bottlecaps common constants coords cubetruss debug distributors edges errors geometry hingesnaps hull involute_gears joiners knurling linear_bearings masks math metric_screws mutators nema_steppers partitions paths phillips_drive polyhedra primitives quaternions queues regions rounding shapes shapes2d skin sliders stacks strings structs threading torx_drive transforms triangulation vectors version vnf walls wiring" + PREVIEW_LIBS="affine arrays attachments beziers bottlecaps common constants coords cubetruss debug distributors edges errors geometry hingesnaps hull involute_gears joiners knurling linear_bearings masks math metric_screws mutators nema_steppers partitions paths phillips_drive polyhedra primitives quaternions queues regions rounding screws shapes shapes2d skin sliders stacks strings structs threading torx_drive transforms triangulation vectors version vnf walls wiring" fi dir="$(basename $PWD)" diff --git a/version.scad b/version.scad index 0b6a0e3..723ce4c 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,323]; +BOSL_VERSION = [2,0,324]; // Section: BOSL Library Version Functions From 6168c8bb6b2980ac1973be498e8b7f3a70499dc3 Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Mon, 25 May 2020 15:13:31 -0700 Subject: [PATCH 06/12] Fix table formatting in screws.scad --- screws.scad | 42 +++++++++++++++++++++--------------------- version.scad | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/screws.scad b/screws.scad index d461e4f..fbebedc 100644 --- a/screws.scad +++ b/screws.scad @@ -117,30 +117,30 @@ function _parse_drive(drive=undef, drive_size=undef) = // . // Only some combinations of head and drive type are supported. Supported UTS (English) head and drive combinations: // . -// Head| Drive -// ---|--- -// none | hex, torx -// hex | -// socket | hex, torx -// button | hex, torx -// round | slot, phillips -// fillister | slot, phillips -// flat | slot, phillips, hex, torx -// flat small | phillips, slot -// flat large | hex, torx -// flat undercut| slot, phillips +// Head | Drive +// ------------- | ---------------------------- +// none | hex, torx +// hex | +// socket | hex, torx +// button | hex, torx +// round | slot, phillips +// fillister | slot, phillips +// flat | slot, phillips, hex, torx +// flat small | phillips, slot +// flat large | hex, torx +// flat undercut | slot, phillips // . // Supported metric head and drive combinations: // . -// Head | Drive -// ------|----------------- -// none | hex, torx -// hex | -// socket| hex, torx -// pan | slot, phillips -// button| hex, torx -// cheese| slot, phillips -// flat | phillips, slot, hex, torx +// Head | Drive +// ------ | ---------------------------- +// none | hex, torx +// hex | +// socket | hex, torx +// pan | slot, phillips +// button | hex, torx +// cheese | slot, phillips +// flat | phillips, slot, hex, torx // . // 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 size is determined automatically from the screw size, but by passing the `drive_size` parameter diff --git a/version.scad b/version.scad index 723ce4c..9c923ae 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,324]; +BOSL_VERSION = [2,0,325]; // Section: BOSL Library Version Functions From 02789c91d99a9f487ce40c638d23a4c18ce1fc98 Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Mon, 25 May 2020 15:34:15 -0700 Subject: [PATCH 07/12] Fix lone period bug in docs parser. --- scripts/docs_gen.py | 4 ++-- version.scad | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/docs_gen.py b/scripts/docs_gen.py index cd0ee4b..6b32f7c 100755 --- a/scripts/docs_gen.py +++ b/scripts/docs_gen.py @@ -82,8 +82,8 @@ def get_comment_block(lines, prefix, blanks=1): break else: blankcnt = 0 - if line == ".": - line == "" + if line.rstrip() == '.': + line = "\n" out.append(line.rstrip()) return (lines, out) diff --git a/version.scad b/version.scad index 9c923ae..a0dfeaf 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,325]; +BOSL_VERSION = [2,0,326]; // Section: BOSL Library Version Functions From 88699c12af3b007f37f16f811fcee83afebed93e Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Mon, 25 May 2020 16:41:41 -0700 Subject: [PATCH 08/12] More screws.scad docs formatting. --- screws.scad | 327 ++++++++++++++++++++++++--------------------------- version.scad | 2 +- 2 files changed, 157 insertions(+), 172 deletions(-) diff --git a/screws.scad b/screws.scad index fbebedc..dd65b01 100644 --- a/screws.scad +++ b/screws.scad @@ -25,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,","), length = str_num(commasplit[1]), xdash = str_split(commasplit[0], "-x"), @@ -39,7 +39,7 @@ function _parse_screw_name(name) = let(val=str_num(type)) 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" @@ -56,113 +56,98 @@ function _parse_drive(drive=undef, drive_size=undef) = // Function: screw_info() // Usage: // info = screw_info(name, [head], [thread], [drive], [drive_size], [oversize]) +// // Description: // Look up screw characteristics for the specified screw type. // . -// For metric (ISO) `name` is Mx,, 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 metric (ISO) the `name=` argument is formatted in a string like: "Mx,". +// 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 -,, 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 -// 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 `''` 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 -// using a thread count, the number of threads per inch. The length is in inches. +// For English (UTS) `name=` is a string like "-,". +// 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 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 +// single-quotes) 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 using a thread count, the number of threads per inch. +// The length is in inches. // . -// If you omit the pitch then a standard screw pitch will be supplied from lookup tables for the screw diameter you have chosen. -// For each screw diameter, multiple standard pitches are possible. -// For the UTS system these the availble thread types are: -// - "coarse" or "UNC" -// - "fine" or "UNF" -// - "extra fine", "extrafine" or "UNEF". -// The ISO system defines a coarse threading and three different fine threadings but does not give different names to the fine threadings. -// The thread options for ISO are: -// - "coarse" -// - "fine" -// - "extra fine" or "extrafine" -// - "super fine" or "superfine" -// The default pitch selection is "coarse". Note that this selection is case independent. Set -// `thread` to one of these values to choose a different pitch. Note that not every pitch 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 specify `thread="none"` to produce an unthreaded -// screw either to simplify the model or to use for cutting out screw holes. Setting the pitch to zero also produces -// an unthreaded screw. If you specify a numeric thread value it will override any value given in `name`. +// If you omit the pitch then a standard screw pitch will be supplied from lookup tables for the +// screw diameter you have chosen. For each screw diameter, multiple standard pitches are possible. +// The available thread pitch types are: +// - `"coarse"` +// - `"fine"` +// - `"extrafine"` or `"extra fine"` +// - `"superfine"` or `"super fine"` (Metric/ISO only.) +// - `"UNC"` (English/UTS only. Same as `"coarse"`.) +// - `"UNF"` (English/UTS only. Same as `"fine"`.) +// - `"UNEF"` (English/UTS only. Same as `"extrafine"`.) // . -// The `head` parameter specifies the type of head the screw will have. Options for the head are -// - "flat" -// - "flat small" -// - "flat large" -// - "flat undercut" -// - "round" -// - "pan" -// - "pan flat" -// - "pan round" -// - "socket" -// - "hex" -// - "button" -// - "cheese" -// - "fillister" -// - "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". +// The default pitch selection is `"coarse"`. Note that this selection is case insensitive. Set the +// `thread=` argument to one of these values to choose a different pitch. Note that not every pitch +// 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 +// specify `thread="none"` to produce an unthreaded screw either to simplify the model or to use for +// cutting out screw holes. Setting the pitch to `0` (zero) also produces an unthreaded screw. +// If you specify a numeric thread value it will override any value given in the `name=` argument. // . -// The `drive` parameter specifies the recess type. Options for the drive are -// - "none" -// - "phillips" -// - "slot" -// - "torx" -// - "hex" -// - "ph0", up to "ph4" for phillips of the specified size -// - "t" for torx at a specified size, e.g. "t20" -// The default drive is "none" +// The `head=` parameter specifies the type of head the screw will have. Options for the head are +// `"flat"`, `"flat small"`, `"flat large"`, `"flat undercut"`, `"round"`, `"pan"`, `"pan flat"`, +// `"pan round"`, `"socket"`, `"hex"`, `"button"`, `"cheese"`, `"fillister"`, or `"none"` // . -// Only some combinations of head and drive type are supported. Supported UTS (English) head and drive combinations: +// 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"`. // . -// Head | Drive -// ------------- | ---------------------------- -// none | hex, torx -// hex | -// socket | hex, torx -// button | hex, torx -// round | slot, phillips -// fillister | slot, phillips -// flat | slot, phillips, hex, torx -// flat small | phillips, slot -// flat large | hex, torx -// flat undercut | slot, phillips +// The `drive=` argument specifies the recess type. Options for the drive are `"none"`, `"hex"`, +// `"slot"`, `"phillips"`, `"ph0"` to `"ph4"` (for phillips of the specified size), `"torx"` or +// `"t"` (for Torx at a specified size, e.g. `"t20"`). The default drive is `"none"` // . -// Supported metric head and drive combinations: +// Only some combinations of head and drive type are supported: // . -// Head | Drive -// ------ | ---------------------------- -// none | hex, torx -// hex | -// socket | hex, torx -// pan | slot, phillips -// button | hex, torx -// cheese | slot, phillips -// flat | phillips, slot, hex, torx +// Head | Drive +// ----------------- | ---------------------------- +// `"none"` | hex, torx +// `"hex"` | *none* +// `"socket"` | hex, torx +// `"button"` | hex, torx +// `"flat"` | slot, phillips, hex, torx +// `"round"` | slot, phillips (UTS/English only.) +// `"fillister"` | slot, phillips (UTS/English only.) +// `"flat small"` | phillips, slot (UTS/English only.) +// `"flat large"` | hex, torx (UTS/English only.) +// `"flat undercut"` | slot, phillips (UTS/English only.) +// `"pan"` | slot, phillips (ISO/Metric only.) +// `"cheese"` | slot, phillips (ISO/Metric only.) // . -// 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 size is determined automatically from the screw size, but by passing the `drive_size` parameter -// you can override the default, or in cases where no default exists you can specify it. +// 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 size is determined automatically +// from the screw size, but by passing the `drive_size=` argument you can override the default, or +// in cases where no default exists you can specify it. // . -// 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 `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. +// The output is a [[struct|structs.scad]] with the following fields: +// . +// Field | What it is +// ------------------ | --------------- +// `"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: // name = screw specification, e.g. "M5x1" or "#8-32" // head = head type (see list above). Default: none @@ -174,7 +159,7 @@ function screw_info(name, head, thread="coarse", drive, drive_size=undef, oversi let(type=_parse_screw_name(name), drive_info = _parse_drive(drive, drive_size), drive=drive_info[0], - screwdata = + screwdata = 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) : [], @@ -186,7 +171,7 @@ function screw_info(name, head, thread="coarse", drive, drive_size=undef, oversi ) ) struct_set(screwdata, over_ride); - + function _screw_info_english(diam, threadcount, head, thread, drive) = let( @@ -233,7 +218,7 @@ function _screw_info_english(diam, threadcount, head, thread, drive) = ] ) inch / struct_val(UTS_thread, diam)[tind], - head_data = + head_data = head=="none" || is_undef(head) ? let ( UTS_setscrew = [ // hex width, hex depth ["#0", [0.028, 0.050]], @@ -288,7 +273,7 @@ function _screw_info_english(diam, threadcount, head, thread, drive) = [1.25, [ 1+7/8, 27/32]], [1.5, [ 2.25, 15/16]], [1.75, [ 2+5/8, 1+3/32]], - [2, [ 3, 1+7/32]], + [2, [ 3, 1+7/32]], ], entry = struct_val(UTS_hex, diam) ) @@ -299,7 +284,7 @@ function _screw_info_english(diam, threadcount, head, thread, drive) = ["#0", [ 0.096, 0.05, 6, 0.025, 0.027]], ["#1", [ 0.118, 1/16, 7, 0.031, 0.036]], ["#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 ["#5", [ 0.205, 3/32, 10, 0.057, 0.049]], ["#6", [ 0.226, 7/64, 15, 0.064, 0.058]], @@ -328,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=="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 ( 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 @@ -350,7 +335,7 @@ function _screw_info_english(diam, threadcount, head, thread, drive) = 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_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( UTS_button = [ // button, hex or torx drive // head diam, height, phillips, hex, torx, hex depth @@ -368,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]], [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 - [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]], [3/4, [1.1, 0.375, undef, 7/16, undef, 0.241]], // hex depth extrapolated ], @@ -434,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]], ["#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]], - ["#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]], ["#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]], @@ -502,7 +487,7 @@ function _screw_info_english(diam, threadcount, head, thread, drive) = function _screw_info_metric(diam, pitch, head, thread, drive) = let( a=echo(metricsi=diam,pitch,head,thread,drive), - pitch = is_num(thread) ? thread : + pitch = is_num(thread) ? thread : is_def(pitch) ? pitch : let( tind=struct_val([["coarse",0], @@ -606,7 +591,7 @@ function _screw_info_metric(diam, pitch, head, thread, drive) = metric_socket = [ // height = screw diameter //diam, hex [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.5, [4.5, 2, 8, 1.05]], [2.6, [5, 2, 8, 1.05]], @@ -630,14 +615,14 @@ function _screw_info_metric(diam, pitch, head, thread, drive) = [33, [50, 24]], [36, [54, 27]], [42, [63, 32]], - [48, [72, 36]], + [48, [72, 36]], ], entry = struct_val(metric_socket, diam), drive_size = drive=="hex" ? [["drive_size",entry[1]],["drive_depth",diam/2]] : 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 ( metric_pan = [ // pan head for phillips or slotted // diam, slotted diam, phillips diam, phillips depth, ph width, slot width,slot depth @@ -658,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=="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( metric_button = [ // button, hex drive // 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.2, [3.8, 0.9, 1.3, undef, 0.76]], // [2.5, [4.6, 1.5, 1.5, undef, 0.87]], // @@ -696,19 +681,19 @@ function _screw_info_metric(diam, pitch, head, thread, drive) = drive_index = drive=="phillips" ? 3 : drive=="hex" ? 2 : undef, 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=="phillips" ? [["drive_diameter", entry[6]], ["drive_depth", entry[7]], ["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]]] : [] ) - 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( small = head == "flat small" || (head=="flat" && (drive!="hex" && drive!="torx")), metric_flat_large = [ // for hex drive [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]], [4, [8, 2.5, 1.5, 20, 1.34]], [5, [10, 3 , 1.9, 25, 1.54]], @@ -769,7 +754,7 @@ function _screw_info_metric(diam, pitch, head, thread, drive) = // Draws the screw head described by the data structure `screw_info`, which // 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) -// 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. module screw_head(screw_info,details=false) { head = struct_val(screw_info, "head"); @@ -787,12 +772,12 @@ module screw_head(screw_info,details=false) { if (in_list(head,["round","pan round","button","fillister","cheese"])) { base = head=="fillister" ? 0.75*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 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) - rotate_extrude($fn=32) + rotate_extrude($fn=32) intersection(){ 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]); @@ -808,7 +793,7 @@ module screw_head(screw_info,details=false) { 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); } -} +} // Module: screw() @@ -829,8 +814,8 @@ module screw_head(screw_info,details=false) { // 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 // 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". -// Smaller numbers give a tighter tolerance. The default ISO tolerance is "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". // Arguments: // name = screw specification, e.g. "M5x1" or "#8-32" // head = head type (see list above). Default: none @@ -838,18 +823,18 @@ module screw_head(screw_info,details=false) { // drive = drive type. Default: none // drive_size = size of drive recess to override computed value // 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) // shank = length of unthreaded portion of screw (in mm). Default: 0 // 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_head = anchor relative to the screw head // Example: Selected UTS (English) screws // $fn=32; // xdistribute(spacing=8){ // 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", thread="fine", head="fillister",length=12, drive="phillips"); // screw("#6", head="flat small",length=12,drive="slot"); @@ -880,35 +865,35 @@ module screw_head(screw_info,details=false) { // screw("1/4", thread=0, length=8, anchor=TOP, head="hex"); // 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="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"); // } // 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="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"); // } // 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="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"); // } // 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="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"); // } // 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="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="torx"); +// 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 large"); // screw("1/4", thread=0,length=8, anchor=TOP, head="flat small"); // } // 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="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"); // } // } @@ -932,23 +917,23 @@ module screw_head(screw_info,details=false) { // screw("M6x0", length=8, anchor=TOP, head="pan flat"); // } // ydistribute(spacing=15){ -// 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="hex"); +// screw("M6x0", length=8, anchor=TOP, head="button", drive="torx"); // screw("M6x0", length=8, anchor=TOP, head="button"); // } // ydistribute(spacing=15){ // 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"); // } // ydistribute(spacing=15){ // 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="hex"); -// screw("M6x0", length=8, anchor=TOP, head="flat", drive="torx"); +// 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 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 // module label(val) @@ -956,8 +941,8 @@ module screw_head(screw_info,details=false) { // difference(){ // children(); // yflip()linear_extrude(height=.35) text(val,valign="center",halign="center",size=8); -// } -// } +// } +// } // $fn=64; // xdistribute(spacing=15){ // label("1") screw("1/4-20,5/8", head="hex",orient=DOWN,anchor_head=TOP,tolerance="1A"); // Loose @@ -972,14 +957,14 @@ module screw_head(screw_info,details=false) { // children(); // ycopies(n=number, spacing=1.5)right(.25*inch-2)up(8-.35)cyl(d=1, h=1); // } -// } +// } // $fn=64; // xdistribute(spacing=17){ // 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(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: 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. // $fn=32; // inch=25.4; // color("red") render() back_half() screw("1/4-20,1/4", head="hex",orient=UP,anchor=BOTTOM,tolerance="1A"); @@ -1010,7 +995,7 @@ module screw(name, head, thread="coarse", drive, drive_size, oversize=0, spec, l head_anchor = is_def(anchor_head); attachable( 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, anchor = first_defined([anchor, anchor_head, BOTTOM]), //offset = head_anchor ? [0,0,head_height/2] : [0,0,-length/2], @@ -1027,7 +1012,7 @@ module screw(name, head, thread="coarse", drive, drive_size, oversize=0, spec, l } if (threaded>0) intersection(){ - down(unthreaded) + down(unthreaded) _rod(spec, length=threaded+eps, tolerance=tolerance, $fn=sides, anchor=TOP ); if (details) up(.01)cyl(d=diameter, l=length+.02+eps, chamfer1 = pitch/2, chamfer2 = headless ? pitch/2 : -pitch/2, anchor=TOP, $fn=sides); @@ -1061,7 +1046,7 @@ module _driver(spec) 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=="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); } } } @@ -1097,13 +1082,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) : 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], - [5, 0.8*T_D1_6], + [5, 0.8*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] - ], + ], 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))))), @@ -1117,7 +1102,7 @@ function _ISO_thread_tolerance(diameter, pitch, internal=false, tolerance=undef) [6, T_d2_6], [7, 1.25*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 @@ -1131,7 +1116,7 @@ function _ISO_thread_tolerance(diameter, pitch, internal=false, tolerance=undef) internal = is_def(internal) ? internal : tolerance[1] != downcase(tolerance[1]), internalok = !internal || ( 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 || ( (len(tolerance)==2 || len(tolerance)==4) && str_find("efgh", tol_str[1])!=undef @@ -1141,16 +1126,16 @@ function _ISO_thread_tolerance(diameter, pitch, internal=false, tolerance=undef) ) assert(internalok,str("Invalid internal thread tolerance, ",tolerance,". Must have form ")) assert(externalok,str("invalid external thread tolerance, ",tolerance,". Must have form or ")) - let( + let( tol_num_pitch = str_num(tol_str[0]), tol_num_crest = str_num(tol_str[2]), tol_letter = tol_str[1] ) assert(tol_letter==tol_str[3],str("Invalid tolerance, ",tolerance,". Cannot mix different letters")) - internal ? + internal ? let( // Nut case //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, df= echo(T_D1=T_D1), Td2val = struct_val(T_D2, tol_num_pitch)/1000, @@ -1163,7 +1148,7 @@ function _ISO_thread_tolerance(diameter, pitch, internal=false, tolerance=undef) : let( // Bolt case //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, Td2val = struct_val(T_d2, tol_num_pitch)/1000, mintrunc = P/8, @@ -1188,7 +1173,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")) 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_table = [ ["1A", 1.500*pitchtol_2A], @@ -1205,7 +1190,7 @@ function _UTS_thread_tolerance(diam, pitch, internal=false, tolerance=undef) = pitchtol+pitch/4/sqrt(3), // Internal case 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) ) : 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) @@ -1214,11 +1199,11 @@ function _UTS_thread_tolerance(diam, pitch, internal=false, tolerance=undef) = //g=echo(pta2 = pitchtol_2A), // ff=echo(minortol=minortol, pitchtol=pitchtol, majortol=majortol), 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 [d-allowance-majortol, d-allowance], //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], 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 @@ -1245,12 +1230,12 @@ function _exact_thread_tolerance(d,P) = // . // The return value is a structure with the following fields: // - pitch: the thread pitch -// - d_major: major diameter range -// - d_pitch: pitch diameter range +// - d_major: major diameter range +// - d_pitch: pitch diameter range // - d_minor: minor diameter range // - basic: vector `[minor, pitch, major]` of the nominal or "basic" diameters for the threads 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") ,k= tolerance == 0 || tolerance=="none" ? _exact_thread_tolerance(diam, pitch) : @@ -1270,7 +1255,7 @@ function _thread_profile(thread) = meanmajorrad = mean(struct_val(thread,"d_major"))/2, depth = (meanmajorrad-meanminorrad)/pitch, crestwidth = (pitch/2 - 2*(meanmajorrad-meanpitchrad)/sqrt(3))/pitch - + ) [ [-1/2,-depth], @@ -1288,7 +1273,7 @@ function _thread_profile_e(thread) = meanmajorrad = mean(struct_val(thread,"d_major"))/2, depth = (meanmajorrad-meanminorrad)/pitch, crestwidth = (pitch/2 - 2*(meanmajorrad-meanpitchrad)/sqrt(3))/pitch - + ) [ [-1/2,-1], // -1 instead of -depth? @@ -1303,7 +1288,7 @@ module _rod(spec, length, tolerance, orient=UP, spin=0, anchor=CENTER) threadspec = thread_specification(spec, internal=false, tolerance=tolerance); echo(d_major_mean = mean(struct_val(threadspec, "d_major"))); echo(bolt_profile=_thread_profile(threadspec)); - + trapezoidal_threaded_rod( d=mean(struct_val(threadspec, "d_major")), l=length, pitch = struct_val(threadspec, "pitch"), @@ -1326,15 +1311,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 // 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 -// 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: // name = screw specification, e.g. "M5x1" or "#8-32" // thread = thread type or specification. Default: "coarse" // 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) // 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) { spec = is_def(spec) ? spec : screw_info(name, thread=thread, oversize=oversize); @@ -1343,14 +1328,14 @@ module nut(name, thread="coarse", oversize=0, spec, diameter, thickness, toleran echo(nut_minor_diam = mean(struct_val(threadspec,"d_minor"))); trapezoidal_threaded_nut( 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), bevel=false,anchor=anchor,spin=spin,orient=orient); } function _is_positive(x) = is_num(x) && x>0; - + function _validate_screw_spec(spec) = let( f=struct_echo(spec), systemOK = in_list(struct_val(spec,"system"), ["UTS","ISO"]), @@ -1365,8 +1350,8 @@ function _validate_screw_spec(spec) = let( driveOK = is_undef(drive) || drive=="none" || ( _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")) && _is_positive(struct_val(spec, "drive_width")) && _is_positive(struct_val(spec, "drive_width"))) diff --git a/version.scad b/version.scad index a0dfeaf..cf389c0 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,326]; +BOSL_VERSION = [2,0,327]; // Section: BOSL Library Version Functions From 0fd909d4577fa9d6e2bce22ad94e4180bec83490 Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Mon, 25 May 2020 16:52:40 -0700 Subject: [PATCH 09/12] Github Wiki does not like angle brackets. --- screws.scad | 4 ++-- version.scad | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/screws.scad b/screws.scad index dd65b01..c0a2b88 100644 --- a/screws.scad +++ b/screws.scad @@ -60,11 +60,11 @@ function _parse_drive(drive=undef, drive_size=undef) = // Description: // Look up screw characteristics for the specified screw type. // . -// For metric (ISO) the `name=` argument is formatted in a string like: "Mx,". +// For metric (ISO) the `name=` argument is formatted in a string like: "M*\*x*\*,*\*". // 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 a string like "-,". +// For English (UTS) `name=` is a string like "*\*-*\*,*\*". // 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 a diameter in inches, either as a float or a fraction, so `"0.5-13"` and diff --git a/version.scad b/version.scad index cf389c0..3d951c3 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,327]; +BOSL_VERSION = [2,0,328]; // Section: BOSL Library Version Functions From 5c485018f396ffd578bcbc2eb85a6830cb79ae54 Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Mon, 25 May 2020 17:14:00 -0700 Subject: [PATCH 10/12] GitHub's markdown processor has bugs. --- screws.scad | 6 +++--- version.scad | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/screws.scad b/screws.scad index c0a2b88..131d350 100644 --- a/screws.scad +++ b/screws.scad @@ -60,13 +60,13 @@ function _parse_drive(drive=undef, drive_size=undef) = // Description: // Look up screw characteristics for the specified screw type. // . -// For metric (ISO) the `name=` argument is formatted in a string like: "M*\*x*\*,*\*". +// For metric (ISO) the `name=` argument is formatted in a string like: `"Mx,"`. // 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 a string like "*\*-*\*,*\*". +// For English (UTS) `name=` is a string like `"-,"`. // 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 +// number from 0 to 12 with or without a leading `#` to specify a screw gauge size, or any other // 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 // single-quotes) to the end, e.g. `"1''-4"` is a one inch screw and `"1-80"` is a very small diff --git a/version.scad b/version.scad index 3d951c3..54ecbee 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,328]; +BOSL_VERSION = [2,0,329]; // Section: BOSL Library Version Functions From a53e1f391594a45eca45677d7fea59e17b590cc5 Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Mon, 25 May 2020 17:31:29 -0700 Subject: [PATCH 11/12] Made screw() example 7 clearer. --- screws.scad | 8 +++++--- version.scad | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/screws.scad b/screws.scad index 131d350..3a0d066 100644 --- a/screws.scad +++ b/screws.scad @@ -964,11 +964,13 @@ module screw_head(screw_info,details=false) { // 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"); // } -// 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. // $fn=32; // inch=25.4; -// color("red") render() back_half() screw("1/4-20,1/4", head="hex",orient=UP,anchor=BOTTOM,tolerance="1A"); -// render() back_half() down(inch*1/20*.325+inch/20*3) nut("1/4-20", thickness=8, diameter=0.5*inch,tolerance="1B"); +// projection(cut=true) xrot(-90) { +// color("red") render() back_half() zrot(-90) screw("1/4-20,1/4", head="button",orient=UP,anchor=BOTTOM,tolerance="1A"); +// render() back_half() down(inch*1/20*.325+inch/20*3) 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) { diff --git a/version.scad b/version.scad index 54ecbee..6a25763 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,329]; +BOSL_VERSION = [2,0,330]; // Section: BOSL Library Version Functions From 3388cff335e8942b6a496e0aa5bb9a6859142939 Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Mon, 25 May 2020 19:07:51 -0700 Subject: [PATCH 12/12] More tweaks to screw() example 7. --- screws.scad | 7 ++++--- version.scad | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/screws.scad b/screws.scad index 3a0d066..58d799d 100644 --- a/screws.scad +++ b/screws.scad @@ -965,11 +965,12 @@ module screw_head(screw_info,details=false) { // mark(3) nut("1/4-20", thickness=8, diameter=0.5*inch,tolerance="3B"); // } // 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; // inch=25.4; -// projection(cut=true) xrot(-90) { -// color("red") render() back_half() zrot(-90) screw("1/4-20,1/4", head="button",orient=UP,anchor=BOTTOM,tolerance="1A"); -// render() back_half() down(inch*1/20*.325+inch/20*3) nut("1/4-20", thickness=8, diameter=0.5*inch,tolerance="1B"); +// projection(cut=true)xrot(-90){ +// 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) diff --git a/version.scad b/version.scad index 6a25763..7847591 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,330]; +BOSL_VERSION = [2,0,331]; // Section: BOSL Library Version Functions