From 7404c2d047d964abe6e18e7ef131567547073fd9 Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Mon, 3 Apr 2023 19:22:51 -0700 Subject: [PATCH 1/8] Added Synopses to beziers.scad --- beziers.scad | 123 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 77 insertions(+), 46 deletions(-) diff --git a/beziers.scad b/beziers.scad index 5589f2c..3a48b6f 100644 --- a/beziers.scad +++ b/beziers.scad @@ -28,11 +28,13 @@ // Section: Bezier Curves // Function: bezier_points() +// Synopsis: Computes one or more specified points along a bezier curve. +// Topics: Bezier Curves +// See Also: bezier_curve(), bezier_curvature(), bezier_tangent(), bezier_derivative(), bezier_points() // Usage: // pt = bezier_points(bezier, u); // ptlist = bezier_points(bezier, RANGE); // ptlist = bezier_points(bezier, LIST); -// Topics: Bezier Curves // Description: // Computes points on a bezier curve with control points specified by `bezier` at parameter values // specified by `u`, which can be a scalar or a list. The value `u=0` gives the first endpoint; `u=1` gives the final endpoint, @@ -176,10 +178,11 @@ function _bezier_matrix(N) = // Function: bezier_curve() +// Synopsis: Computes a number of uniformly distributed points along a bezier curve. +// Topics: Bezier Curves +// See Also: bezier_curve(), bezier_curvature(), bezier_tangent(), bezier_derivative(), bezier_points() // Usage: // path = bezier_curve(bezier, [splinesteps], [endpoint]); -// Topics: Bezier Curves -// See Also: bezier_curvature(), bezier_tangent(), bezier_derivative(), bezier_points() // Description: // Takes a list of bezier control points and generates splinesteps segments (splinesteps+1 points) // along the bezier curve they define. @@ -210,12 +213,13 @@ function bezier_curve(bezier,splinesteps=16,endpoint=true) = // Function: bezier_derivative() +// Synopsis: Evaluates the derivative of the bezier curve at the given point or points. +// Topics: Bezier Curves +// See Also: bezier_curvature(), bezier_tangent(), bezier_points() // Usage: // deriv = bezier_derivative(bezier, u, [order]); // derivs = bezier_derivative(bezier, LIST, [order]); // derivs = bezier_derivative(bezier, RANGE, [order]); -// Topics: Bezier Curves -// See Also: bezier_curvature(), bezier_tangent(), bezier_points() // Description: // Evaluates the derivative of the bezier curve at the given parameter value or values, `u`. The `order` gives the order of the derivative. // The degree of the bezier curve is one less than the number of points in `bezier`. @@ -234,12 +238,13 @@ function bezier_derivative(bezier, u, order=1) = // Function: bezier_tangent() +// Synopsis: Calculates unit tangent vectors along the bezier curve at one or more given positions. +// Topics: Bezier Curves +// See Also: bezier_curvature(), bezier_derivative(), bezier_points() // Usage: // tanvec = bezier_tangent(bezier, u); // tanvecs = bezier_tangent(bezier, LIST); // tanvecs = bezier_tangent(bezier, RANGE); -// Topics: Bezier Curves -// See Also: bezier_curvature(), bezier_derivative(), bezier_points() // Description: // Returns the unit tangent vector at the given parameter values on a bezier curve with control points `bezier`. // Arguments: @@ -254,12 +259,13 @@ function bezier_tangent(bezier, u) = // Function: bezier_curvature() +// Synopsis: Returns the curvature values at one or more given positions along a bezier curve. +// Topics: Bezier Curves +// See Also: bezier_tangent(), bezier_derivative(), bezier_points() // Usage: // crv = bezier_curvature(curve, u); // crvlist = bezier_curvature(curve, LIST); // crvlist = bezier_curvature(curve, RANGE); -// Topics: Bezier Curves -// See Also: bezier_tangent(), bezier_derivative(), bezier_points() // Description: // Returns the curvature value for the given parameters `u` on the bezier curve with control points `bezier`. // The curvature is the inverse of the radius of the tangent circle at the given point. @@ -284,10 +290,11 @@ function bezier_curvature(bezier, u) = // Function: bezier_closest_point() -// Usage: -// u = bezier_closest_point(bezier, pt, [max_err]); +// Synopsis: Finds the closest position on a bezier curve to a given point. // Topics: Bezier Curves // See Also: bezier_points() +// Usage: +// u = bezier_closest_point(bezier, pt, [max_err]); // Description: // Finds the closest part of the given bezier curve to point `pt`. // The degree of the curve, N, is one less than the number of points in `curve`. @@ -333,10 +340,11 @@ function bezier_closest_point(bezier, pt, max_err=0.01, u=0, end_u=1) = // Function: bezier_length() -// Usage: -// pathlen = bezier_length(bezier, [start_u], [end_u], [max_deflect]); +// Synopsis: Approximate the length of part of a bezier curve. // Topics: Bezier Curves // See Also: bezier_points() +// Usage: +// pathlen = bezier_length(bezier, [start_u], [end_u], [max_deflect]); // Description: // Approximates the length of the portion of the bezier curve between start_u and end_u. // Arguments: @@ -370,10 +378,11 @@ function bezier_length(bezier, start_u=0, end_u=1, max_deflect=0.01) = // Function: bezier_line_intersection() -// Usage: -// u = bezier_line_intersection(bezier, line); +// Synopsis: Calculates where a bezier curve intersects a line. // Topics: Bezier Curves, Geometry, Intersection // See Also: bezier_points(), bezier_length(), bezier_closest_point() +// Usage: +// u = bezier_line_intersection(bezier, line); // Description: // Finds the intersection points of the 2D Bezier curve with control points `bezier` and the given line, specified as a pair of points. // Returns the intersection as a list of `u` values for the Bezier. @@ -404,12 +413,13 @@ function bezier_line_intersection(bezier, line) = // Function: bezpath_points() +// Synopsis: Computes one or more specified points along a bezier path. +// Topics: Bezier Paths +// See Also: bezier_points(), bezier_curve() // Usage: // pt = bezpath_points(bezpath, curveind, u, [N]); // ptlist = bezpath_points(bezpath, curveind, LIST, [N]); // path = bezpath_points(bezpath, curveind, RANGE, [N]); -// Topics: Bezier Paths -// See Also: bezier_points(), bezier_curve() // Description: // Extracts from the Bezier path `bezpath` the control points for the Bezier curve whose index is `curveind` and // computes the point or points on the corresponding Bezier curve specified by `u`. If `curveind` is zero you @@ -424,12 +434,13 @@ function bezpath_points(bezpath, curveind, u, N=3) = // Function: bezpath_curve() +// Synopsis: Takes a bezier path and converts it into a path of points. +// Topics: Bezier Paths +// See Also: bezier_points(), bezier_curve(), bezpath_points() // Usage: // path = bezpath_curve(bezpath, [splinesteps], [N], [endpoint]) -// Topics: Bezier Paths -// See Also: bezier_points(), bezier_curve() // Description: -// Takes a bezier path and converts it into a path of points. +// Computes a number of uniformly distributed points along a bezier path. // Arguments: // bezpath = A bezier path to approximate. // splinesteps = Number of straight lines to split each bezier curve into. default=16 @@ -459,10 +470,11 @@ function bezpath_curve(bezpath, splinesteps=16, N=3, endpoint=true) = // Function: bezpath_closest_point() +// Synopsis: Finds the closest part of a bezier path to a give point. +// Topics: Bezier Paths +// See Also: bezpath_points(), bezpath_curve(), bezier_points(), bezier_curve(), bezier_closest_point() // Usage: // res = bezpath_closest_point(bezpath, pt, [N], [max_err]); -// Topics: Bezier Paths -// See Also: bezier_points(), bezier_curve(), bezier_closest_point() // Description: // Finds an approximation to the closest part of the given bezier path to point `pt`. // Returns [segnum, u] for the closest position on the bezier path to the given point `pt`. @@ -504,10 +516,11 @@ function bezpath_closest_point(bezpath, pt, N=3, max_err=0.01, seg=0, min_seg=un // Function: bezpath_length() -// Usage: -// plen = bezpath_length(path, [N], [max_deflect]); +// Synopsis: Approximate the length of a bezier path. // Topics: Bezier Paths // See Also: bezier_points(), bezier_curve(), bezier_length() +// Usage: +// plen = bezpath_length(path, [N], [max_deflect]); // Description: // Approximates the length of the bezier path. // Arguments: @@ -530,10 +543,11 @@ function bezpath_length(bezpath, N=3, max_deflect=0.001) = // Function: path_to_bezpath() -// Usage: -// bezpath = path_to_bezpath(path, [closed], [tangents], [uniform], [size=]|[relsize=]); +// Synopsis: Generates a bezier path that passes through all points in a given linear path. // Topics: Bezier Paths, Rounding // See Also: path_tangents() +// Usage: +// bezpath = path_to_bezpath(path, [closed], [tangents], [uniform], [size=]|[relsize=]); // Description: // Given a 2d or 3d input path and optional list of tangent vectors, computes a cubic (degree 3) bezier // path that passes through every point on the input path and matches the tangent vectors. If you do @@ -616,10 +630,11 @@ function path_to_bezpath(path, closed, tangents, uniform=false, size, relsize) = // Function: bezpath_close_to_axis() -// Usage: -// bezpath = bezpath_close_to_axis(bezpath, [axis], [N]); +// Synopsis: Closes a 2D bezier path to the specified axis. // Topics: Bezier Paths // See Also: bezpath_offset() +// Usage: +// bezpath = bezpath_close_to_axis(bezpath, [axis], [N]); // Description: // Takes a 2D bezier path and closes it to the specified axis. // Arguments: @@ -659,10 +674,11 @@ function bezpath_close_to_axis(bezpath, axis="X", N=3) = // Function: bezpath_offset() -// Usage: -// bezpath = bezpath_offset(offset, bezier, [N]); +// Synopsis: Forms a closed bezier path loop with a translated and reversed copy of itself. // Topics: Bezier Paths // See Also: bezpath_close_to_axis() +// Usage: +// bezpath = bezpath_offset(offset, bezier, [N]); // Description: // Takes a 2D bezier path and closes it with a matching reversed path that is offset by the given `offset` [X,Y] distance. // Arguments: @@ -697,6 +713,7 @@ function bezpath_offset(offset, bezier, N=3) = // Section: Cubic Bezier Path Construction // Function: bez_begin() +// Synopsis: Calculates starting bezier path control points. // Topics: Bezier Paths // See Also: bez_tang(), bez_joint(), bez_end() // Usage: @@ -767,6 +784,7 @@ function bez_begin(pt,a,r,p) = // Function: bez_tang() +// Synopsis: Calculates control points for a smooth bezier path joint. // Topics: Bezier Paths // See Also: bez_begin(), bez_joint(), bez_end() // Usage: @@ -802,6 +820,7 @@ function bez_tang(pt,a,r1,r2,p) = // Function: bez_joint() +// Synopsis: Calculates control points for a disjointed corner bezier path joint. // Topics: Bezier Paths // See Also: bez_begin(), bez_tang(), bez_end() // Usage: @@ -842,6 +861,7 @@ function bez_joint(pt,a1,a2,r1,r2,p1,p2) = // Function: bez_end() +// Synopsis: Calculates ending bezier path control points. // Topics: Bezier Paths // See Also: bez_tang(), bez_joint(), bez_end() // Usage: @@ -868,11 +888,12 @@ function bez_end(pt,a,r,p) = // Function: is_bezier_patch() +// Synopsis: Returns true if the given item is a bezier patch. +// Topics: Bezier Patches, Type Checking // Usage: // bool = is_bezier_patch(x); -// Topics: Bezier Patches, Type Checking // Description: -// Returns true if the given item is a bezier patch. +// Returns true if the given item is a bezier patch. (a 2D array of 3D points.) // Arguments: // x = The value to check the type of. function is_bezier_patch(x) = @@ -880,10 +901,11 @@ function is_bezier_patch(x) = // Function: bezier_patch_flat() -// Usage: -// patch = bezier_patch_flat(size, [N=], [spin=], [orient=], [trans=]); +// Synopsis: Creates a flat bezier patch. // Topics: Bezier Patches // See Also: bezier_patch_points() +// Usage: +// patch = bezier_patch_flat(size, [N=], [spin=], [orient=], [trans=]); // Description: // Returns a flat rectangular bezier patch of degree `N`, centered on the XY plane. // Arguments: @@ -913,10 +935,11 @@ function bezier_patch_flat(size, N=1, spin=0, orient=UP, trans=[0,0,0]) = // Function: bezier_patch_reverse() -// Usage: -// rpatch = bezier_patch_reverse(patch); +// Synopsis: Reverses the orientation of a bezier patch. // Topics: Bezier Patches // See Also: bezier_patch_points(), bezier_patch_flat() +// Usage: +// rpatch = bezier_patch_reverse(patch); // Description: // Reverses the patch, so that the faces generated from it are flipped back to front. // Arguments: @@ -926,12 +949,13 @@ function bezier_patch_reverse(patch) = // Function: bezier_patch_points() +// Synopsis: Computes one or more specified points across a bezier surface patch. +// Topics: Bezier Patches +// See Also: bezier_patch_normals(), bezier_points(), bezier_curve(), bezpath_curve() // Usage: // pt = bezier_patch_points(patch, u, v); // ptgrid = bezier_patch_points(patch, LIST, LIST); // ptgrid = bezier_patch_points(patch, RANGE, RANGE); -// Topics: Bezier Patches -// See Also: bezier_patch_normals(), bezier_points(), bezier_curve(), bezpath_curve() // Description: // Sample a bezier patch on a listed point set. The bezier patch must be a rectangular array of // points, and it will be sampled at all the (u,v) pairs that you specify. If you give u and v @@ -987,10 +1011,11 @@ function _bezier_rectangle(patch, splinesteps=16, style="default") = // Function: bezier_vnf() -// Usage: -// vnf = bezier_vnf(patches, [splinesteps], [style]); +// Synopsis: Generates a (probably non-manifold) VNF for one or more bezier surface patches. // Topics: Bezier Patches // See Also: bezier_patch_points(), bezier_patch_flat() +// Usage: +// vnf = bezier_vnf(patches, [splinesteps], [style]); // Description: // Convert a patch or list of patches into the corresponding Bezier surface, representing the // result as a [VNF structure](vnf.scad). The `splinesteps` argument specifies the sampling grid of @@ -1113,6 +1138,9 @@ function bezier_vnf(patches=[], splinesteps=16, style="default") = // Function: bezier_vnf_degenerate_patch() +// Synopsis: Generates a VNF for a degenerate bezier surface patch. +// Topics: Bezier Patches +// See Also: bezier_patch_points(), bezier_patch_flat(), bezier_vnf() // Usage: // vnf = bezier_vnf_degenerate_patch(patch, [splinesteps], [reverse]); // vnf_edges = bezier_vnf_degenerate_patch(patch, [splinesteps], [reverse], return_edges=true); @@ -1297,12 +1325,13 @@ function bezier_vnf_degenerate_patch(patch, splinesteps=16, reverse=false, retur // Function: bezier_patch_normals() +// Synopsis: Computes surface normals for one or more places on a bezier surface patch. +// Topics: Bezier Patches +// See Also: bezier_patch_points(), bezier_points(), bezier_curve(), bezpath_curve() // Usage: // n = bezier_patch_normals(patch, u, v); // ngrid = bezier_patch_normals(patch, LIST, LIST); // ngrid = bezier_patch_normals(patch, RANGE, RANGE); -// Topics: Bezier Patches -// See Also: bezier_patch_points(), bezier_points(), bezier_curve(), bezpath_curve() // Description: // Compute the unit normal vector to a bezier patch at the listed point set. The bezier patch must be a rectangular array of // points, and the normal will be computed at all the (u,v) pairs that you specify. If you give u and v @@ -1409,10 +1438,11 @@ function bezier_patch_normals(patch, u, v) = // Module: debug_bezier() -// Usage: -// debug_bezier(bez, [size], [N=]); +// Synopsis: Shows a bezier path and it's associated control points. // Topics: Bezier Paths, Debugging // See Also: bezpath_curve() +// Usage: +// debug_bezier(bez, [size], [N=]); // Description: // Renders 2D or 3D bezier paths and their associated control points. // Useful for debugging bezier paths. @@ -1462,10 +1492,11 @@ module debug_bezier(bezpath, width=1, N=3) { // Module: debug_bezier_patches() -// Usage: -// debug_bezier_patches(patches, [size=], [splinesteps=], [showcps=], [showdots=], [showpatch=], [convexity=], [style=]); +// Synopsis: Shows a bezier surface patch and its associated control points. // Topics: Bezier Patches, Debugging // See Also: bezier_patch_points(), bezier_patch_flat(), bezier_vnf() +// Usage: +// debug_bezier_patches(patches, [size=], [splinesteps=], [showcps=], [showdots=], [showpatch=], [convexity=], [style=]); // Description: // Shows the surface, and optionally, control points of a list of bezier patches. // Arguments: From 119de92f6e0bc65aed80a7a70dd67db8f123b8da Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Mon, 3 Apr 2023 20:11:36 -0700 Subject: [PATCH 2/8] Added Synopses, etc to hinges.scad and joiners.scad --- hinges.scad | 50 +++++++++++++++++++++++++++++++++++++------------- joiners.scad | 37 +++++++++++++++++++++++++++---------- 2 files changed, 64 insertions(+), 23 deletions(-) diff --git a/hinges.scad b/hinges.scad index 8c6420e..27fc746 100644 --- a/hinges.scad +++ b/hinges.scad @@ -14,23 +14,32 @@ include // Section: Hinges // Module: knuckle_hinge() +// Synopsis: Creates a knuckle-hinge shape. +// Topics: Hinges, Parts +// See Also: living_hinge_mask(), snap_lock(), snap_socket() // Usage: // knuckle_hinge(length, offset, segs, [inner], [arm_height=], [arm_angle=], [fill=], [clear_top=], [gap=], [round_top=], [round_bot=], [knuckle_diam=], [pin_diam=], [pin_fn=], [anchor=], [spin=], [orient=]) [ATTACHMENTS]; // Description: -// Construct standard knuckle hinge in two parts using a hinge pin that must be separately supplied. The default is configured to use a piece of 1.75 mm filament as the hinge pin, -// but you can select any dimensions you like to use a screw or other available pin material. The BOTTOM of the hinge is its mount point, which is aligned with -// the hinge pin centersurface, and the hinge pin hole is the CENTER of the hinge. -// The offset is the distance from a vertical mounting point to the center of the hinge pin. The hinge barrel is held by an angled support and -// vertical support. The length of the angled support is determined by its angle and the offset. You specify the length of the vertical support with the -// arm_height parameter. -// +// Construct standard knuckle hinge in two parts using a hinge pin that must be separately supplied. +// The default is configured to use a piece of 1.75 mm filament as the hinge pin, but you can select +// any dimensions you like to use a screw or other available pin material. The BOTTOM of the hinge +// is its mount point, which is aligned with the hinge pin centersurface, and the hinge pin hole is +// the CENTER of the hinge. The offset is the distance from a vertical mounting point to the center +// of the hinge pin. The hinge barrel is held by an angled support and vertical support. The +// length of the angled support is determined by its angle and the offset. You specify the length +// of the vertical support with the arm_height parameter. // . -// A hinge requires clearance so its parts don't interfere. If the hinge pin is exactly centered on the top of your part, then the hinge may not close all the way -// due to interference at the edge. A small clearance, specified with `clearance=`, raises the hinge up and can ease this interference. It should probably be equal to a layer thickness or two. -// If the hinge knuckle is close to the hinged part then the mating part may interfere. You can create clearance to address this problem by increasing the offset -// to move the hinge knuckles farther away. Another method is to cut out a curved recess on the parts to allow space for the other hinges. This is possible -// using the `knuckle_clearance=` parameter, which specifies the extra space to cut away to leave room for the hinge knuckles. It must be positive for any space -// to be cut, and to use this option you must make the hinge a child of some object and specify {{diff()}} for the parent object of the hinge. +// A hinge requires clearance so its parts don't interfere. If the hinge pin is exactly centered on +// the top of your part, then the hinge may not close all the way due to interference at the edge. +// A small clearance, specified with `clearance=`, raises the hinge up and can ease this +// interference. It should probably be equal to a layer thickness or two. If the hinge knuckle is +// close to the hinged part then the mating part may interfere. You can create clearance to address +// this problem by increasing the offset to move the hinge knuckles farther away. Another method is +// to cut out a curved recess on the parts to allow space for the other hinges. This is possible +// using the `knuckle_clearance=` parameter, which specifies the extra space to cut away to leave +// room for the hinge knuckles. It must be positive for any space to be cut, and to use this option +// you must make the hinge a child of some object and specify {{diff()}} for the parent object of +// the hinge. // Figure(2D,Med,NoScales): The basic hinge form appears on the left. If fill is set to true the gap between the mount surface and hinge arm is filled as shown on the right. // _knuckle_hinge_profile(4, 5, $fn=32, fill=false); // right(13)_knuckle_hinge_profile(4, 5, $fn=32, fill=true); @@ -336,6 +345,9 @@ module _knuckle_hinge_profile(offset, arm_height, arm_angle=45, knuckle_diam=4, // Module: living_hinge_mask() +// Synopsis: Creates a mask to make a folding "living" hinge. +// Topics: Hinges, Parts +// See Also: knuckle_hinge(), living_hinge_mask(), snap_lock(), snap_socket(), apply_folding_hinges_and_snaps() // Usage: // living_hinge_mask(l, thick, [layerheight=], [foldangle=], [hingegap=], [$slop=], [anchor=], [spin=], [orient=]) [ATTACHMENTS]; // Description: @@ -378,6 +390,9 @@ module folding_hinge_mask(l, thick, layerheight=0.2, foldangle=90, hingegap=unde // Module: apply_folding_hinges_and_snaps() +// Synopsis: Adds snap shapes and removes living hinges from a child shape. +// Topics: Hinges, Parts +// See Also: knuckle_hinge(), living_hinge_mask(), snap_lock(), snap_socket() // Usage: // apply_folding_hinges_and_snaps(thick, [foldangle=], [hinges=], [snaps=], [sockets=], [snaplen=], [snapdiam=], [hingegap=], [layerheight=], [$slop=]) CHILDREN; // Description: @@ -460,6 +475,9 @@ module apply_folding_hinges_and_snaps(thick, foldangle=90, hinges=[], snaps=[], // Module: snap_lock() +// Synopsis: Creates a snap-lock shape. +// Topics: Hinges, Parts +// See Also: knuckle_hinge(), living_hinge_mask(), snap_lock(), snap_socket() // Usage: // snap_lock(thick, [snaplen=], [snapdiam=], [layerheight=], [foldangle=], [hingegap=], [$slop=], [anchor=], [spin=], [orient=]) [ATTACHMENTS]; // Description: @@ -496,6 +514,9 @@ module snap_lock(thick, snaplen=5, snapdiam=5, layerheight=0.2, foldangle=90, hi // Module: snap_socket() +// Synopsis: Creates a snap-lock socket shape. +// Topics: Hinges, Parts +// See Also: knuckle_hinge(), living_hinge_mask(), snap_lock(), snap_socket() // Usage: // snap_socket(thick, [snaplen=], [snapdiam=], [layerheight=], [foldangle=], [hingegap=], [$slop=], [anchor=], [spin=], [orient=]) [ATTACHMENTS]; // Description: @@ -533,3 +554,6 @@ module snap_socket(thick, snaplen=5, snapdiam=5, layerheight=0.2, foldangle=90, } } + + +// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap diff --git a/joiners.scad b/joiners.scad index 7cf7a98..bdf0a90 100644 --- a/joiners.scad +++ b/joiners.scad @@ -16,11 +16,13 @@ include // Function&Module: half_joiner_clear() +// Synopsis: Creates a mask to clear space for a {{half_joiner()}}. +// Topics: Joiners, Parts +// See Also: half_joiner_clear(), half_joiner(), half_joiner2(), joiner_clear(), joiner(), snap_pin(), rabbit_clip(), dovetail() // Usage: As Module // half_joiner_clear(l, w, [ang=], [clearance=], [overlap=]) [ATTACHMENTS]; // Usage: As Function // vnf = half_joiner_clear(l, w, [ang=], [clearance=], [overlap=]); -// Topics: Joiners, Parts // Description: // Creates a mask to clear an area so that a half_joiner can be placed there. // Arguments: @@ -33,7 +35,6 @@ include // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` -// See Also: half_joiner_clear(), half_joiner(), half_joiner2(), joiner_clear(), joiner() // Example: // half_joiner_clear(); function half_joiner_clear(l=20, w=10, ang=30, clearance=0, overlap=0.01, anchor=CENTER, spin=0, orient=UP) = @@ -60,11 +61,13 @@ module half_joiner_clear(l=20, w=10, ang=30, clearance=0, overlap=0.01, anchor=C // Function&Module: half_joiner() +// Synopsis: Creates a half-joiner shape to mate with a {{half_joiner2()}} shape.. +// Topics: Joiners, Parts +// See Also: half_joiner_clear(), half_joiner(), half_joiner2(), joiner_clear(), joiner(), snap_pin(), rabbit_clip(), dovetail() // Usage: As Module // half_joiner(l, w, [base=], [ang=], [screwsize=], [$slop=]) [ATTACHMENTS]; // Usage: As Function // vnf = half_joiner(l, w, [base=], [ang=], [screwsize=], [$slop=]); -// Topics: Joiners, Parts // Description: // Creates a half_joiner object that can be attached to a matching half_joiner2 object. // Arguments: @@ -78,7 +81,6 @@ module half_joiner_clear(l=20, w=10, ang=30, clearance=0, overlap=0.01, anchor=C // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` // $slop = Printer specific slop value to make parts fit more closely. -// See Also: half_joiner_clear(), half_joiner(), half_joiner2(), joiner_clear(), joiner() // Examples(FlatSpin,VPD=75): // half_joiner(screwsize=3); // half_joiner(l=20,w=10,base=10); @@ -241,11 +243,13 @@ module half_joiner(l=20, w=10, base=10, ang=30, screwsize, anchor=CENTER, spin=0 // Function&Module: half_joiner2() +// Synopsis: Creates a half_joiner2 shape to mate with a {{half_joiner()}} shape.. +// Topics: Joiners, Parts +// See Also: half_joiner_clear(), half_joiner(), half_joiner2(), joiner_clear(), joiner(), snap_pin(), rabbit_clip(), dovetail() // Usage: As Module // half_joiner2(l, w, [base=], [ang=], [screwsize=]) // Usage: As Function // vnf = half_joiner2(l, w, [base=], [ang=], [screwsize=]) -// Topics: Joiners, Parts // Description: // Creates a half_joiner2 object that can be attached to half_joiner object. // Arguments: @@ -258,7 +262,6 @@ module half_joiner(l=20, w=10, base=10, ang=30, screwsize, anchor=CENTER, spin=0 // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` -// See Also: half_joiner_clear(), half_joiner(), half_joiner2(), joiner_clear(), joiner() // Examples(FlatSpin,VPD=75): // half_joiner2(screwsize=3); // half_joiner2(w=10,base=10,l=20); @@ -444,11 +447,13 @@ module half_joiner2(l=20, w=10, base=10, ang=30, screwsize, anchor=CENTER, spin= // Module: joiner_clear() +// Synopsis: Creates a mask to clear space for a {{joiner()}} shape. +// Topics: Joiners, Parts +// See Also: half_joiner_clear(), half_joiner(), half_joiner2(), joiner_clear(), joiner(), snap_pin(), rabbit_clip(), dovetail() // Description: // Creates a mask to clear an area so that a joiner can be placed there. // Usage: // joiner_clear(l, w, [ang=], [clearance=], [overlap=]) [ATTACHMENTS]; -// Topics: Joiners, Parts // Arguments: // l = Length of the joiner to clear space for. // w = Width of the joiner to clear space for. @@ -459,7 +464,6 @@ module half_joiner2(l=20, w=10, base=10, ang=30, screwsize, anchor=CENTER, spin= // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` -// See Also: half_joiner_clear(), half_joiner(), half_joiner2(), joiner_clear(), joiner() // Example: // joiner_clear(); function joiner_clear(l=40, w=10, ang=30, clearance=0, overlap=0.01, anchor=CENTER, spin=0, orient=UP) = no_function("joiner_clear"); @@ -482,9 +486,11 @@ module joiner_clear(l=40, w=10, ang=30, clearance=0, overlap=0.01, anchor=CENTER // Module: joiner() +// Synopsis: Creates a joiner shape that can mate with another rotated joiner shape. +// Topics: Joiners, Parts +// See Also: half_joiner_clear(), half_joiner(), half_joiner2(), joiner_clear(), joiner(), snap_pin(), rabbit_clip(), dovetail() // Usage: // joiner(l, w, base, [ang=], [screwsize=], [$slop=]) [ATTACHMENTS]; -// Topics: Joiners, Parts // Description: // Creates a joiner object that can be attached to another joiner object. // Arguments: @@ -498,7 +504,6 @@ module joiner_clear(l=40, w=10, ang=30, clearance=0, overlap=0.01, anchor=CENTER // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` // $slop = Printer specific slop value to make parts fit more closely. -// See Also: half_joiner_clear(), half_joiner(), half_joiner2(), joiner_clear(), joiner() // Examples(FlatSpin,VPD=125): // joiner(screwsize=3); // joiner(l=40, w=10, base=10); @@ -532,6 +537,9 @@ module joiner(l=40, w=10, base=10, ang=30, screwsize, anchor=CENTER, spin=0, ori // Section: Dovetails // Module: dovetail() +// Synopsis: Creates a possibly tapered dovetail shape. +// Topics: Joiners, Parts +// See Also: joiner(), snap_pin(), rabbit_clip() // // Usage: // dovetail(gender, w=|width, h=|height, slide|thickness=, [slope=|angle=], [taper=|back_width=], [chamfer=], [r=|radius=], [round=], [extra=], [$slop=]) @@ -799,6 +807,9 @@ function _pin_size(size) = // Module: snap_pin() +// Synopsis: Creates a snap-pin that can slot into a {{snap_pin_socket()}} to join two parts. +// Topics: Joiners, Parts +// See Also: snap_pin_socket(), joiner(), dovetail(), snap_pin(), rabbit_clip() // Usage: // snap_pin(size, [pointed=], [anchor=], [spin=], [orient]=) [ATTACHMENTS]; // snap_pin(r=|radius=|d=|diameter=, l=|length=, nub_depth=, snap=, thickness=, [clearance=], [preload=], [pointed=]) [ATTACHMENTS]; @@ -869,6 +880,9 @@ module snap_pin(size,r,radius,d,diameter, l,length, nub_depth, snap, thickness, } // Module: snap_pin_socket() +// Synopsis: Creates a snap-pin socket for a {{snap_pin()}} to slot into. +// Topics: Joiners, Parts +// See Also: snap_pin(), joiner(), dovetail(), snap_pin(), rabbit_clip() // Usage: // snap_pin_socket(size, [fixed=], [fins=], [pointed=], [anchor=], [spin=], [orient=]) [ATTACHMENTS]; // snap_pin_socket(r=|radius=|d=|diameter=, l=|length=, nub_depth=, snap=, [fixed=], [pointed=], [fins=]) [ATTACHMENTS]; @@ -939,6 +953,9 @@ module snap_pin_socket(size, r, radius, l,length, d,diameter,nub_depth, snap, fi // Module: rabbit_clip() +// Synopsis: Creates a rabbit-eared clip that can snap into a slot. +// Topics: Joiners, Parts +// See Also: snap_pin(), joiner(), dovetail(), snap_pin(), rabbit_clip() // Usage: // rabbit_clip(type, length, width, snap, thickness, depth, [compression=], [clearance=], [lock=], [lock_clearance=], [splineteps=], [anchor=], [orient=], [spin=]) [ATTACHMENTS]; // Description: From 401e9ad4669129056696886e0dea55d01cf2facc Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Tue, 4 Apr 2023 15:59:45 -0700 Subject: [PATCH 3/8] Synopses for cubetruss.scad --- cubetruss.scad | 487 ++++++++++++++++++++++++++----------------------- 1 file changed, 260 insertions(+), 227 deletions(-) diff --git a/cubetruss.scad b/cubetruss.scad index 02d8f19..7f01417 100644 --- a/cubetruss.scad +++ b/cubetruss.scad @@ -16,81 +16,67 @@ $cubetruss_clip_thickness = 1.6; // Section: Cube Trusses -// Function: cubetruss_dist() +// Module: cubetruss() +// Synopsis: Creates a multi-cube straight cubetruss shape. +// Topics: Trusses, CubeTruss, FDM Optimized, Parts +// See Also: cubetruss_segment(), cubetruss_support(), cubetruss(), cubetruss_corner() // Usage: -// cubetruss_dist(cubes, gaps, [size], [strut]); +// cubetruss(extents, [clips], [bracing], [size], [strut], [clipthick]); // Description: -// Function to calculate the length of a cubetruss truss. -// Arguments: -// cubes = The number of cubes along the truss's length. -// gaps = The number of extra strut widths to add in, corresponding to each time a truss butts up against another. -// size = The length of each side of the cubetruss cubes. Default: `$cubetruss_size` (usually 30) -// strut = The width of the struts on the cubetruss cubes. Default: `$cubetruss_strut_size` (usually 3) -// Topics: Trusses -function cubetruss_dist(cubes=0, gaps=0, size, strut) = - let( - size = is_undef(size)? $cubetruss_size : size, - strut = is_undef(strut)? $cubetruss_strut_size : strut - ) cubes*(size-strut)+gaps*strut; - - -// Module: cubetruss_segment() -// Usage: -// cubetruss_segment([size], [strut], [bracing]); -// Description: -// Creates a single cubetruss cube segment. +// Creates a cubetruss truss, assembled out of one or more cubical segments. // Arguments: +// extents = The number of cubes in length to make the truss. If given as a [X,Y,Z] vector, specifies the number of cubes in each dimension. +// clips = List of vectors pointing towards the sides to add clips to. // size = The length of each side of the cubetruss cubes. Default: `$cubetruss_size` (usually 30) // strut = The width of the struts on the cubetruss cubes. Default: `$cubetruss_strut_size` (usually 3) // bracing = If true, adds internal cross-braces. Default: `$cubetruss_bracing` (usually true) +// clipthick = The thickness of the clips. Default: `$cubetruss_clip_thickness` (usually 1.6) // --- // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` // spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP` // Topics: Attachable, Trusses // Examples: -// cubetruss_segment(bracing=false); -// cubetruss_segment(bracing=true); -// cubetruss_segment(strut=4); -// cubetruss_segment(size=40); -module cubetruss_segment(size, strut, bracing, anchor=CENTER, spin=0, orient=UP) { +// cubetruss(extents=3); +// cubetruss(extents=3, clips=FRONT); +// cubetruss(extents=3, clips=[FRONT,BACK]); +// cubetruss(extents=[2,3]); +// cubetruss(extents=[1,4,2]); +// cubetruss(extents=[1,4,2], bracing=false); +module cubetruss(extents=6, clips=[], bracing, size, strut, clipthick, anchor=CENTER, spin=0, orient=UP) { + clips = is_vector(clips)? [clips] : clips; size = is_undef(size)? $cubetruss_size : size; strut = is_undef(strut)? $cubetruss_strut_size : strut; bracing = is_undef(bracing)? $cubetruss_bracing : bracing; - h = size; - crossthick = strut/sqrt(2); - voffset = 0.333; - attachable(anchor,spin,orient, size=[size,size,size]) { - render(convexity=10) + clipthick = is_undef(clipthick)? $cubetruss_clip_thickness : clipthick; + extents = is_vector(extents)? point3d(extents,fill=1) : [1,extents,1]; + w = extents[0]; + l = extents[1]; + h = extents[2]; + s = [cubetruss_dist(w,1), cubetruss_dist(l,1), cubetruss_dist(h,1)]; + attachable(anchor,spin,orient, size=s) { union() { - difference() { - // Start with a cube. - cube([size, size, h], center=true); - - cube([size-strut*2, size-strut*2, h-strut*2], center=true); - - // Hollow out octogons in X and Y axes. - zrot_copies([0,90]) { - xrot(90) zrot(180/8) cylinder(h=max(h,size)+1, d=(min(h,size)-2*strut)/cos(180/8), center=true, $fn=8); + for (zrow = [0:h-1]) { + up((zrow-(h-1)/2)*(size-strut)) { + for (xcol = [0:w-1]) { + right((xcol-(w-1)/2)*(size-strut)) { + for (ycol = [0:l-1]) { + back((ycol-(l-1)/2)*(size-strut)) { + cubetruss_segment(size=size, strut=strut, bracing=bracing); + } + } + } + } } - - // Hollow out octogon vertically. - zrot(180/8) cylinder(h=max(h,size)+1, d=(min(h,size)-2*strut)/cos(180/8), center=true, $fn=8); } - - // Interior cross-supports - if (bracing) { - for (i = [-1,1]) { - zrot(i*45) { - difference() { - cube([crossthick, (size-strut)*sqrt(2), h], center=true); - up(i*voffset) { - yscale(1.3) { - yrot(90) { - zrot(180/6) { - cylinder(h=crossthick+1, d=(min(h,size)-2*strut)/cos(180/6)-2*voffset, center=true, $fn=6); - } - } + if (clipthick > 0) { + for (vec = clips) { + exts = v_abs(rot(from=FWD, to=vec, p=extents)); + rot(from=FWD,to=vec) { + for (zrow = [0:1:exts.z-1]) { + up((zrow-(exts.z-1)/2)*(size-strut)) { + fwd((exts.y*(size-strut)+strut)/2) { + cubetruss_clip(size=size, strut=strut, extents=exts.x, clipthick=clipthick); } } } @@ -103,7 +89,86 @@ module cubetruss_segment(size, strut, bracing, anchor=CENTER, spin=0, orient=UP) } +// Module: cubetruss_corner() +// Synopsis: Creates a multi-cube corner cubetruss shape. +// Topics: Trusses, CubeTruss, FDM Optimized, Parts +// See Also: cubetruss_segment(), cubetruss_support(), cubetruss(), cubetruss_corner() +// Usage: +// cubetruss_corner(h, extents, [bracing], [size], [strut], [clipthick]); +// Description: +// Creates a corner cubetruss with extents jutting out in one or more directions. +// Arguments: +// h = The number of cubes high to make the base and horizontal extents. +// extents = The number of cubes to extend beyond the corner. If given as a vector of cube counts, gives the number of cubes to extend right, back, left, front, and up in order. If the vector is shorter than length 5 the extra cube counts are taken to be zero. +// size = The length of each side of the cubetruss cubes. Default: `$cubetruss_size` (usually 30) +// strut = The width of the struts on the cubetruss cubes. Default: `$cubetruss_strut_size` (usually 3) +// bracing = If true, adds internal cross-braces. Default: `$cubetruss_bracing` (usually true) +// clipthick = The thickness of the clips. Default: `$cubetruss_clip_thickness` (usually 1.6) +// --- +// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` +// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0` +// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP` +// Topics: Attachable, Trusses +// Examples: +// cubetruss_corner(extents=2); +// cubetruss_corner(extents=2, h=2); +// cubetruss_corner(extents=[3,3,0,0,2]); +// cubetruss_corner(extents=[3,0,3,0,2]); +// cubetruss_corner(extents=[3,3,3,3,2]); +module cubetruss_corner(h=1, extents=[1,1,0,0,1], bracing, size, strut, clipthick, anchor=CENTER, spin=0, orient=UP) { + size = is_undef(size)? $cubetruss_size : size; + strut = is_undef(strut)? $cubetruss_strut_size : strut; + bracing = is_undef(bracing)? $cubetruss_bracing : bracing; + clipthick = is_undef(clipthick)? $cubetruss_clip_thickness : clipthick; + exts = is_vector(extents)? list_pad(extents,5,fill=0) : [extents, extents, 0, 0, extents]; + dummy = assert(len(exts)==5, "Input extents must be a scalar or vector with length 5 or less."); + s = [cubetruss_dist(exts[0]+1+exts[2],1), cubetruss_dist(exts[1]+1+exts[3],1), cubetruss_dist(h+exts[4],1)]; + offset = [cubetruss_dist(exts[0]-exts[2],0), cubetruss_dist(exts[1]-exts[3],0), cubetruss_dist(h+exts[4]-1,0)]/2; + attachable(anchor,spin,orient, size=s, offset=offset) { + union() { + for (zcol = [0:h-1]) { + up((size-strut)*zcol) { + cubetruss_segment(size=size, strut=strut, bracing=bracing); + } + } + for (dir = [0:3]) { + if (exts[dir] != undef && exts[dir] > 0) { + zrot(dir*90) { + for (zcol = [0:h-1]) { + up((size-strut+0.01)*zcol) { + for (i = [1:exts[dir]]) { + right((size-strut+0.01)*i) cubetruss_segment(size=size, strut=strut, bracing=bracing); + } + if (clipthick > 0) { + right(exts[dir]*(size-strut)+size/2) { + zrot(90) cubetruss_clip(size=size, strut=strut, clipthick=clipthick); + } + } + } + } + } + } + } + if (exts[4] != undef && exts[4] > 0) { + for (i = [1:exts[4]]) { + up((size-strut+0.01)*(i+h-1)) cubetruss_segment(size=size, strut=strut, bracing=bracing); + } + if (clipthick > 0) { + up((exts[4]+h-1)*(size-strut)+size/2) { + xrot(-90) cubetruss_clip(size=size, strut=strut, clipthick=clipthick); + } + } + } + } + children(); + } +} + + // Module: cubetruss_support() +// Synopsis: Creates a cubetruss support structure shape. +// Topics: Trusses, CubeTruss, FDM Optimized, Parts +// See Also: cubetruss_segment(), cubetruss_support(), cubetruss(), cubetruss_corner() // Usage: // cubetruss_support([size], [strut], [extents], [anchor], [spin], [orient]) [ATTACHMENTS]; // Description: @@ -164,72 +229,13 @@ module cubetruss_support(size, strut, extents=1, anchor=CENTER, spin=0, orient=U } -// Module: cubetruss_clip() -// Usage: -// cubetruss_clip(extents, [size], [strut], [clipthick], [$slop=], [anchor=], [spin=], [orient=]) [ATTACHMENTS]; -// Description: -// Creates a pair of clips to add onto the end of a truss. -// Arguments: -// extents = How many cubes to separate the clips by. -// size = The length of each side of the cubetruss cubes. Default: `$cubetruss_size` (usually 30) -// strut = The width of the struts on the cubetruss cubes. Default: `$cubetruss_strut_size` (usually 3) -// clipthick = The thickness of the clip. Default: `$cubetruss_clip_thickness` (usually 1.6) -// --- -// $slop = allowance for printer overextrusion -// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` -// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0` -// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP` -// Topics: Attachable, Trusses -// Examples: -// cubetruss_clip(extents=2); -// cubetruss_clip(extents=1); -// cubetruss_clip(clipthick=2.5); -module cubetruss_clip(extents=1, size, strut, clipthick, anchor=CENTER, spin=0, orient=UP) { - size = is_undef(size)? $cubetruss_size : size; - strut = is_undef(strut)? $cubetruss_strut_size : strut; - clipthick = is_undef(clipthick)? $cubetruss_clip_thickness : clipthick; - cliplen = strut * 2.6; - clipheight = min(size+strut, size/3+2*strut*2.6); - clipsize = 0.5; - s = [extents*(size-strut)+strut+2*clipthick, strut*2, clipheight-2*strut]; - attachable(anchor,spin,orient, size=s) { - xflip_copy(offset=(extents*(size-strut)+strut)/2) { - difference() { - union() { - difference() { - right(clipthick/2-0.01) { - back(strut) { - difference() { - xrot(90) prismoid([clipthick, clipheight], [clipthick, clipheight-cliplen*2], h=cliplen); - right(clipthick/2) chamfer_edge_mask(l=clipheight+0.1, chamfer=clipthick); - } - } - } - fwd(strut*3/2) { - cube([get_slop(), strut*3, size], center=true); - } - } - right(get_slop()/2+0.01) { - fwd(strut*1.25+get_slop()) { - yrot(-90) prismoid([clipheight-cliplen*2, strut/2], [clipheight-cliplen*2-2*clipsize, strut/2], h=clipsize+0.01); - } - } - } - fwd(strut*1.6) { - left(clipsize) { - yscale(1.5) chamfer_edge_mask(l=size+1, chamfer=clipsize+clipthick/3); - } - } - zcopies(clipheight-strut) cube([clipthick*3, cliplen*2, strut], center=true); - zcopies(clipheight-2*strut) right(clipthick) chamfer_edge_mask(l=cliplen*2, chamfer=clipthick, orient=BACK); - } - } - children(); - } -} +// Section: Cubetruss Support // Module: cubetruss_foot() +// Synopsis: Creates a foot that can connect two cubetrusses. +// Topics: Trusses, CubeTruss, FDM Optimized, Parts +// See Also: cubetruss_segment(), cubetruss_support(), cubetruss(), cubetruss_corner() // Usage: // cubetruss_foot(w, [size], [strut], [clipthick], [$slop=], [anchor=], [spin=], [orient=]) [ATTACHMENTS]; // Description: @@ -307,6 +313,9 @@ module cubetruss_foot(w=1, size, strut, clipthick, anchor=CENTER, spin=0, orient // Module: cubetruss_joiner() +// Synopsis: Creates a joiner that can connect two cubetrusses end-to-end. +// Topics: Trusses, CubeTruss, FDM Optimized, Parts +// See Also: cubetruss_segment(), cubetruss_support(), cubetruss(), cubetruss_corner() // Usage: // cubetruss_joiner([w], [vert], [size], [strut], [clipthick], [$slop=], [anchor=], [spin=], [orient=]) [ATTACHMENTS]; // Description: @@ -375,6 +384,9 @@ module cubetruss_joiner(w=1, vert=true, size, strut, clipthick, anchor=CENTER, s // Module: cubetruss_uclip() +// Synopsis: Creates a joiner that can connect two cubetrusses end-to-end. +// Topics: Trusses, CubeTruss, FDM Optimized, Parts +// See Also: cubetruss_segment(), cubetruss_support(), cubetruss(), cubetruss_corner() // Usage: // cubetruss_uclip(dual, [size], [strut], [clipthick], [$slop=], [anchor=], [spin=], [orient=]) [ATTACHMENTS]; // Description: @@ -420,126 +432,68 @@ module cubetruss_uclip(dual=true, size, strut, clipthick, anchor=CENTER, spin=0, } -// Module: cubetruss() + +// Section: Cubetruss Primitives + +// Module: cubetruss_segment() +// Synopsis: Creates a single cubetruss cube. +// Topics: Trusses, CubeTruss, FDM Optimized, Parts +// See Also: cubetruss_segment(), cubetruss_support(), cubetruss(), cubetruss_corner() // Usage: -// cubetruss(extents, [clips], [bracing], [size], [strut], [clipthick]); +// cubetruss_segment([size], [strut], [bracing]); // Description: -// Creates a cubetruss truss, assembled out of one or more cubical segments. +// Creates a single cubetruss cube segment. // Arguments: -// extents = The number of cubes in length to make the truss. If given as a [X,Y,Z] vector, specifies the number of cubes in each dimension. -// clips = List of vectors pointing towards the sides to add clips to. // size = The length of each side of the cubetruss cubes. Default: `$cubetruss_size` (usually 30) // strut = The width of the struts on the cubetruss cubes. Default: `$cubetruss_strut_size` (usually 3) // bracing = If true, adds internal cross-braces. Default: `$cubetruss_bracing` (usually true) -// clipthick = The thickness of the clips. Default: `$cubetruss_clip_thickness` (usually 1.6) // --- // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` // spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP` // Topics: Attachable, Trusses // Examples: -// cubetruss(extents=3); -// cubetruss(extents=3, clips=FRONT); -// cubetruss(extents=3, clips=[FRONT,BACK]); -// cubetruss(extents=[2,3]); -// cubetruss(extents=[1,4,2]); -// cubetruss(extents=[1,4,2], bracing=false); -module cubetruss(extents=6, clips=[], bracing, size, strut, clipthick, anchor=CENTER, spin=0, orient=UP) { - clips = is_vector(clips)? [clips] : clips; +// cubetruss_segment(bracing=false); +// cubetruss_segment(bracing=true); +// cubetruss_segment(strut=4); +// cubetruss_segment(size=40); +module cubetruss_segment(size, strut, bracing, anchor=CENTER, spin=0, orient=UP) { size = is_undef(size)? $cubetruss_size : size; strut = is_undef(strut)? $cubetruss_strut_size : strut; bracing = is_undef(bracing)? $cubetruss_bracing : bracing; - clipthick = is_undef(clipthick)? $cubetruss_clip_thickness : clipthick; - extents = is_vector(extents)? point3d(extents,fill=1) : [1,extents,1]; - w = extents[0]; - l = extents[1]; - h = extents[2]; - s = [cubetruss_dist(w,1), cubetruss_dist(l,1), cubetruss_dist(h,1)]; - attachable(anchor,spin,orient, size=s) { + h = size; + crossthick = strut/sqrt(2); + voffset = 0.333; + attachable(anchor,spin,orient, size=[size,size,size]) { + render(convexity=10) union() { - for (zrow = [0:h-1]) { - up((zrow-(h-1)/2)*(size-strut)) { - for (xcol = [0:w-1]) { - right((xcol-(w-1)/2)*(size-strut)) { - for (ycol = [0:l-1]) { - back((ycol-(l-1)/2)*(size-strut)) { - cubetruss_segment(size=size, strut=strut, bracing=bracing); - } - } - } - } - } - } - if (clipthick > 0) { - for (vec = clips) { - exts = v_abs(rot(from=FWD, to=vec, p=extents)); - rot(from=FWD,to=vec) { - for (zrow = [0:1:exts.z-1]) { - up((zrow-(exts.z-1)/2)*(size-strut)) { - fwd((exts.y*(size-strut)+strut)/2) { - cubetruss_clip(size=size, strut=strut, extents=exts.x, clipthick=clipthick); - } - } - } - } - } - } - } - children(); - } -} + difference() { + // Start with a cube. + cube([size, size, h], center=true); + cube([size-strut*2, size-strut*2, h-strut*2], center=true); -// Module: cubetruss_corner() -// Usage: -// cubetruss_corner(h, extents, [bracing], [size], [strut], [clipthick]); -// Description: -// Creates a corner cubetruss with extents jutting out in one or more directions. -// Arguments: -// h = The number of cubes high to make the base and horizontal extents. -// extents = The number of cubes to extend beyond the corner. If given as a vector of cube counts, gives the number of cubes to extend right, back, left, front, and up in order. If the vector is shorter than length 5 the extra cube counts are taken to be zero. -// size = The length of each side of the cubetruss cubes. Default: `$cubetruss_size` (usually 30) -// strut = The width of the struts on the cubetruss cubes. Default: `$cubetruss_strut_size` (usually 3) -// bracing = If true, adds internal cross-braces. Default: `$cubetruss_bracing` (usually true) -// clipthick = The thickness of the clips. Default: `$cubetruss_clip_thickness` (usually 1.6) -// --- -// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` -// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0` -// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP` -// Topics: Attachable, Trusses -// Examples: -// cubetruss_corner(extents=2); -// cubetruss_corner(extents=2, h=2); -// cubetruss_corner(extents=[3,3,0,0,2]); -// cubetruss_corner(extents=[3,0,3,0,2]); -// cubetruss_corner(extents=[3,3,3,3,2]); -module cubetruss_corner(h=1, extents=[1,1,0,0,1], bracing, size, strut, clipthick, anchor=CENTER, spin=0, orient=UP) { - size = is_undef(size)? $cubetruss_size : size; - strut = is_undef(strut)? $cubetruss_strut_size : strut; - bracing = is_undef(bracing)? $cubetruss_bracing : bracing; - clipthick = is_undef(clipthick)? $cubetruss_clip_thickness : clipthick; - exts = is_vector(extents)? list_pad(extents,5,fill=0) : [extents, extents, 0, 0, extents]; - dummy = assert(len(exts)==5, "Input extents must be a scalar or vector with length 5 or less."); - s = [cubetruss_dist(exts[0]+1+exts[2],1), cubetruss_dist(exts[1]+1+exts[3],1), cubetruss_dist(h+exts[4],1)]; - offset = [cubetruss_dist(exts[0]-exts[2],0), cubetruss_dist(exts[1]-exts[3],0), cubetruss_dist(h+exts[4]-1,0)]/2; - attachable(anchor,spin,orient, size=s, offset=offset) { - union() { - for (zcol = [0:h-1]) { - up((size-strut)*zcol) { - cubetruss_segment(size=size, strut=strut, bracing=bracing); + // Hollow out octogons in X and Y axes. + zrot_copies([0,90]) { + xrot(90) zrot(180/8) cylinder(h=max(h,size)+1, d=(min(h,size)-2*strut)/cos(180/8), center=true, $fn=8); } + + // Hollow out octogon vertically. + zrot(180/8) cylinder(h=max(h,size)+1, d=(min(h,size)-2*strut)/cos(180/8), center=true, $fn=8); } - for (dir = [0:3]) { - if (exts[dir] != undef && exts[dir] > 0) { - zrot(dir*90) { - for (zcol = [0:h-1]) { - up((size-strut+0.01)*zcol) { - for (i = [1:exts[dir]]) { - right((size-strut+0.01)*i) cubetruss_segment(size=size, strut=strut, bracing=bracing); - } - if (clipthick > 0) { - right(exts[dir]*(size-strut)+size/2) { - zrot(90) cubetruss_clip(size=size, strut=strut, clipthick=clipthick); + + // Interior cross-supports + if (bracing) { + for (i = [-1,1]) { + zrot(i*45) { + difference() { + cube([crossthick, (size-strut)*sqrt(2), h], center=true); + up(i*voffset) { + yscale(1.3) { + yrot(90) { + zrot(180/6) { + cylinder(h=crossthick+1, d=(min(h,size)-2*strut)/cos(180/6)-2*voffset, center=true, $fn=6); + } } } } @@ -547,15 +501,73 @@ module cubetruss_corner(h=1, extents=[1,1,0,0,1], bracing, size, strut, clipthic } } } - if (exts[4] != undef && exts[4] > 0) { - for (i = [1:exts[4]]) { - up((size-strut+0.01)*(i+h-1)) cubetruss_segment(size=size, strut=strut, bracing=bracing); - } - if (clipthick > 0) { - up((exts[4]+h-1)*(size-strut)+size/2) { - xrot(-90) cubetruss_clip(size=size, strut=strut, clipthick=clipthick); + } + children(); + } +} + + +// Module: cubetruss_clip() +// Synopsis: Creates a clip for the end of a cubetruss to snap-lock it to another cubetruss. +// Topics: Trusses, CubeTruss, FDM Optimized, Parts +// See Also: cubetruss_segment(), cubetruss_support(), cubetruss(), cubetruss_corner() +// Usage: +// cubetruss_clip(extents, [size], [strut], [clipthick], [$slop=], [anchor=], [spin=], [orient=]) [ATTACHMENTS]; +// Description: +// Creates a pair of clips to add onto the end of a truss. +// Arguments: +// extents = How many cubes to separate the clips by. +// size = The length of each side of the cubetruss cubes. Default: `$cubetruss_size` (usually 30) +// strut = The width of the struts on the cubetruss cubes. Default: `$cubetruss_strut_size` (usually 3) +// clipthick = The thickness of the clip. Default: `$cubetruss_clip_thickness` (usually 1.6) +// --- +// $slop = allowance for printer overextrusion +// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` +// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0` +// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP` +// Topics: Attachable, Trusses +// Examples: +// cubetruss_clip(extents=2); +// cubetruss_clip(extents=1); +// cubetruss_clip(clipthick=2.5); +module cubetruss_clip(extents=1, size, strut, clipthick, anchor=CENTER, spin=0, orient=UP) { + size = is_undef(size)? $cubetruss_size : size; + strut = is_undef(strut)? $cubetruss_strut_size : strut; + clipthick = is_undef(clipthick)? $cubetruss_clip_thickness : clipthick; + cliplen = strut * 2.6; + clipheight = min(size+strut, size/3+2*strut*2.6); + clipsize = 0.5; + s = [extents*(size-strut)+strut+2*clipthick, strut*2, clipheight-2*strut]; + attachable(anchor,spin,orient, size=s) { + xflip_copy(offset=(extents*(size-strut)+strut)/2) { + difference() { + union() { + difference() { + right(clipthick/2-0.01) { + back(strut) { + difference() { + xrot(90) prismoid([clipthick, clipheight], [clipthick, clipheight-cliplen*2], h=cliplen); + right(clipthick/2) chamfer_edge_mask(l=clipheight+0.1, chamfer=clipthick); + } + } + } + fwd(strut*3/2) { + cube([get_slop(), strut*3, size], center=true); + } + } + right(get_slop()/2+0.01) { + fwd(strut*1.25+get_slop()) { + yrot(-90) prismoid([clipheight-cliplen*2, strut/2], [clipheight-cliplen*2-2*clipsize, strut/2], h=clipsize+0.01); + } } } + fwd(strut*1.6) { + left(clipsize) { + yscale(1.5) chamfer_edge_mask(l=size+1, chamfer=clipsize+clipthick/3); + } + } + zcopies(clipheight-strut) cube([clipthick*3, cliplen*2, strut], center=true); + zcopies(clipheight-2*strut) right(clipthick) chamfer_edge_mask(l=cliplen*2, chamfer=clipthick, orient=BACK); } } children(); @@ -563,5 +575,26 @@ module cubetruss_corner(h=1, extents=[1,1,0,0,1], bracing, size, strut, clipthic } +// Function: cubetruss_dist() +// Synopsis: Returns the length of a cubetruss truss. +// Topics: Trusses, CubeTruss, FDM Optimized, Parts +// See Also: cubetruss_segment(), cubetruss_support(), cubetruss(), cubetruss_corner() +// Usage: +// cubetruss_dist(cubes, gaps, [size], [strut]); +// Description: +// Function to calculate the length of a cubetruss truss. +// Arguments: +// cubes = The number of cubes along the truss's length. +// gaps = The number of extra strut widths to add in, corresponding to each time a truss butts up against another. +// size = The length of each side of the cubetruss cubes. Default: `$cubetruss_size` (usually 30) +// strut = The width of the struts on the cubetruss cubes. Default: `$cubetruss_strut_size` (usually 3) +// Topics: Trusses +function cubetruss_dist(cubes=0, gaps=0, size, strut) = + let( + size = is_undef(size)? $cubetruss_size : size, + strut = is_undef(strut)? $cubetruss_strut_size : strut + ) cubes*(size-strut)+gaps*strut; + + // vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap From 7179bc7711ef8f21ef8a1b1b156776cab7ec25c2 Mon Sep 17 00:00:00 2001 From: Adrian Mariano Date: Tue, 4 Apr 2023 19:55:05 -0400 Subject: [PATCH 4/8] Screw update: 4x faster, higbee renamed blunt start and on by default --- bottlecaps.scad | 42 ++- screws.scad | 100 +++-- skin.scad | 250 +++++++------ threading.scad | 949 +++++++++++++++++++++++++++++++++--------------- 4 files changed, 887 insertions(+), 454 deletions(-) diff --git a/bottlecaps.scad b/bottlecaps.scad index 4668e7e..3b48d46 100644 --- a/bottlecaps.scad +++ b/bottlecaps.scad @@ -117,7 +117,7 @@ module pco1810_neck(wall=2, anchor="support-ring", spin=0, orient=UP) thread_depth=thread_h+0.1, flank_angle=flank_angle, turns=810/360, - taper=-thread_h*2, + lead_in=-thread_h*2, anchor=TOP ); zrot_copies(rots=[90,270]) { @@ -190,7 +190,7 @@ module pco1810_cap(wall=2, texture="none", anchor=BOTTOM, spin=0, orient=UP) } up(wall) cyl(d=cap_id, h=tamper_ring_h+wall, anchor=BOTTOM); } - up(wall+2) thread_helix(d=thread_od-thread_depth*2, pitch=thread_pitch, thread_depth=thread_depth, flank_angle=flank_angle, turns=810/360, taper=-thread_depth, internal=true, anchor=BOTTOM); + up(wall+2) thread_helix(d=thread_od-thread_depth*2, pitch=thread_pitch, thread_depth=thread_depth, flank_angle=flank_angle, turns=810/360, lead_in=-thread_depth, internal=true, anchor=BOTTOM); } children(); } @@ -306,7 +306,7 @@ module pco1881_neck(wall=2, anchor="support-ring", spin=0, orient=UP) thread_depth=thread_h+0.1, flank_angle=flank_angle, turns=650/360, - taper=-thread_h*2, + lead_in=-thread_h*2, anchor=TOP ); zrot_copies(rots=[90,270]) { @@ -371,7 +371,7 @@ module pco1881_cap(wall=2, texture="none", anchor=BOTTOM, spin=0, orient=UP) } up(wall) cyl(d=28.58, h=11.2+wall, anchor=BOTTOM); } - up(wall+2) thread_helix(d=25.5, pitch=2.7, thread_depth=1.6, flank_angle=15, turns=650/360, taper=-1.6, internal=true, anchor=BOTTOM); + up(wall+2) thread_helix(d=25.5, pitch=2.7, thread_depth=1.6, flank_angle=15, turns=650/360, lead_in=-1.6, internal=true, anchor=BOTTOM); } children(); } @@ -475,7 +475,7 @@ module generic_bottle_neck( thread_depth = thread_h + 0.1 * diamMagMult, flank_angle = flank_angle, turns = (height - pitch - lip_roundover_r) * .6167 / pitch, - taper = -thread_h * 2, + lead_in = -thread_h * 2, anchor = TOP ); zrot_copies(rots = [90, 270]) { @@ -579,7 +579,7 @@ module generic_bottle_cap( difference(){ up(wall + pitch / 2) { thread_helix(d = neckOuterDTol, pitch = pitch, thread_depth = threadDepth, flank_angle = flank_angle, - turns = ((height - pitch) / pitch), taper = -threadDepth, internal = true, anchor = BOTTOM); + turns = ((height - pitch) / pitch), lead_in = -threadDepth, internal = true, anchor = BOTTOM); } } } @@ -954,8 +954,9 @@ function bottle_adapter_neck_to_neck( // 400, 410 and 415. The 400 type neck has 360 degrees of thread, the 410 // neck has 540 degrees of thread, and the 415 neck has 720 degrees of thread. // You can also choose between the L style thread, which is symmetric and -// the M style thread, which is an asymmetric buttress thread. You can -// specify the wall thickness (measured from the base of the threads) or +// the M style thread, which is an asymmetric buttress thread. The M style +// may be good for 3d printing if printed with the flat face up. +// You can specify the wall thickness (measured from the base of the threads) or // the inner diameter, and you can specify an optional bead at the base of the threads. // Arguments: // diam = nominal outer diameter of threads @@ -1094,6 +1095,8 @@ module sp_neck(diam,type,wall,id,style="L",bead=false, anchor, spin, orient) H = entry[2]; S = entry[3]; tpi = entry[4]; + + // a is the width of the thread a = (style=="M" && tpi==12) ? 1.3 : struct_val(_sp_thread_width,tpi); twist = struct_val(_sp_twist, type); @@ -1126,7 +1129,7 @@ module sp_neck(diam,type,wall,id,style="L",bead=false, anchor, spin, orient) up((H+extra_bot)/2){ difference(){ union(){ - thread_helix(d=T-.01, profile=profile, pitch = INCH/tpi, turns=twist/360, taper=taperlen, anchor=TOP); + thread_helix(d=T-.01, profile=profile, pitch = INCH/tpi, turns=twist/360, lead_in=taperlen, anchor=TOP); cylinder(d=T-depth*2,h=H,anchor=TOP); if (bead) down(bead_shift) @@ -1154,12 +1157,15 @@ module sp_neck(diam,type,wall,id,style="L",bead=false, anchor, spin, orient) // the M style thread, which is an asymmetric buttress thread. Note that it // is OK to mix styles, so you can put an L-style cap onto an M-style neck. // . -// These caps often contain a cardboard or foam sealer disk, which can be as much as 1mm thick. -// If you don't include this, your cap may bottom out on the bead on the neck instead of sealing -// against the top. If you set top_adj to 1 it will make the top space 1mm smaller so that the -// cap will not bottom out. The 410 and 415 caps have very long unthreaded sections at the bottom. -// The bot_adj parameter specifies an amount to reduce that bottom extension. Be careful that -// you don't shrink past the threads. +// The 410 and 415 caps have very long unthreaded sections at the bottom. +// The bot_adj parameter specifies an amount to reduce that bottom extension, which might be +// necessary if the cap bottoms out on the bead. Be careful that you don't shrink past the threads, +// especially if making adjustments to 400 caps which have a very small bottom extension. +// These caps often contain a cardboard or foam sealer disk, which can be as much as 1mm thick, and +// would cause the cap to stop in a higher position. +// . +// You can also adjust the space between the top of the cap and the threads using top_adj. This +// will change how the threads engage when the cap is fully seated. // . // The inner diameter of the cap is set to allow 10% of the thread depth in clearance. The diameter // is further increased by `2 * $slop` so you can increase clearance if necessary. @@ -1182,6 +1188,7 @@ module sp_neck(diam,type,wall,id,style="L",bead=false, anchor, spin, orient) // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` // Examples: // sp_cap(48,400,2); +// sp_cap(22,400,2); // sp_cap(22,410,2); // sp_cap(28,415,1.5,style="M"); module sp_cap(diam,type,wall,style="L",top_adj=0, bot_adj=0, texture="none", anchor, spin, orient) @@ -1194,13 +1201,14 @@ module sp_cap(diam,type,wall,style="L",top_adj=0, bot_adj=0, texture="none", anc T = entry[0]; I = entry[1]; - H = entry[2]-1; + H = entry[2]-0.5; S = entry[3]; tpi = entry[4]; a = (style=="M" && tpi==12) ? 1.3 : struct_val(_sp_thread_width,tpi); twist = struct_val(_sp_twist, type); + echo(top_adj=top_adj,bot_adj=bot_adj); dum3=assert(top_adj0 ? flat_height:0; // Adjustment because flathead height doesn't count toward shoulder length shoulder_full = _shoulder_len==0 ? 0 : _shoulder_len + flat_height; shank_len = is_def(user_thread_len) ? length - user_thread_len - (_shoulder_len==0?flat_height:0) : 0; @@ -647,6 +652,8 @@ module screw(spec, head, drive, thread, drive_size, : is_def(vnf) ? undef : head_height+flat_height+flat_cbore_height; bevelsize = default(bevelsize, d_major/12); + bevel1 = first_defined([bevel1,bevel,true]); + bevel2 = first_defined([bevel2,bevel,headless && _shoulder_len==0 && shank_len==0]); attachable( vnf = vnf, d = u_add(u_mul(attach_d, rad_scale), islop), @@ -671,8 +678,16 @@ module screw(spec, head, drive, thread, drive_size, if (shank_len>0 || pitch==0){ L = pitch==0 ? length - (_shoulder_len==0?flat_height:0) : shank_len; bevsize = (_internal ? -1 : 1)*bevelsize; - bev1 = details && pitch==0 && first_defined([bevel1,bevel,!_internal]) ? bevsize : 0; - bev2 = details && pitch==0 && first_defined([bevel2,bevel,headless && !_internal]) ? bevsize : 0; + bev1 = pitch!=0 ? 0 + : bevel1==true ? bevsize + : bevel1==false ? 0 + : bevel1=="reverse" ? -bevsize + : bevel1; + bev2 = pitch!=0 ? 0 + : bevel2==true ? bevsize + : bevel2==false ? 0 + : bevel2=="reverse" ? -bevsize + : bevel2; down(_shoulder_len+flat_height-eps_shank) if (_teardrop) teardrop(d=d_major*rad_scale+islop, h=L+eps_shank, anchor=FRONT, orient=BACK, $fn=sides, chamfer1=bev1, chamfer2=bev2); @@ -680,18 +695,15 @@ module screw(spec, head, drive, thread, drive_size, cyl(d=d_major*rad_scale+islop, h=L+eps_shank, anchor=TOP, $fn=sides, chamfer1=bev1, chamfer2=bev2); } if (thread_len>0 && pitch>0){ - bev1 = details && first_defined([bevel1,bevel,!_internal]); - bev2 = details && first_defined([bevel2,bevel,!_internal && (flathead || _shoulder_len>0 || headless)]); down(_shoulder_len+flat_height+shank_len-eps_thread) threaded_rod([mean(struct_val(threadspec, "d_minor")), mean(struct_val(threadspec, "d_pitch")), d_major], pitch = struct_val(threadspec, "pitch"), l=thread_len+eps_thread, left_handed=false, internal=_internal, - bevel1=bev1, - bevel2=bev2, - higbee1=higbee && !_internal, - higbee2=(!headless && !_internal) || is_undef(higbee) ? false : higbee, + bevel1=bevel1, + bevel2=bevel2, + blunt_start=blunt_start, blunt_start1=blunt_start1, blunt_start2=blunt_start2, $fn=sides, anchor=TOP); } @@ -704,10 +716,9 @@ module screw(spec, head, drive, thread, drive_size, - // Module: screw_hole() // Usage: -// screw_hole([spec], [head], [thread=], [length=|l=], [oversize=], [hole_oversize=], [teardrop=], [head_oversize], [tolerance=], [$slop=], [anchor=], [atype=], [orient=], [spin=]) [ATTACHMENTS]; +// screw_hole([spec], [head], [thread=], [length=|l=], [oversize=], [hole_oversize=], [teardrop=], [head_oversize], [tolerance=], [$slop=], [blunt_start=], [anchor=], [atype=], [orient=], [spin=]) [ATTACHMENTS]; // Description: // Create a screw hole mask. See [screw and nut parameters](#section-screw-and-nut-parameters) for details on the parameters that define a screw. // The screw hole can be threaded to receive a screw or it can be an unthreaded clearance hole. @@ -755,7 +766,9 @@ module screw(spec, head, drive, thread, drive_size, // bevel = if true create bevel at both ends of hole. Default: see below // bevel1 = if true create bevel at bottom end of hole. Default: false // bevel2 = if true create bevel at top end of hole. Default: true when tolerance="self tap", false otherwise -// higbee = if true and hole is threaded, create blunt start threads at the top of the hole. Default: false +// blunt_start = if true and hole is threaded, create blunt start threads. Default: true +// blunt_start1 = if true and hole is threaded, create blunt start threads at bottom end. +// blunt_start2 = if true and hole is threaded, create blunt start threads top end. // $slop = add extra gap to account for printer overextrusion. Default: 0 // atype = anchor type, one of "screw", "head", "shaft", "threads", "shank" // anchor = Translate so anchor point on the shaft is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` @@ -795,14 +808,20 @@ module screw(spec, head, drive, thread, drive_size, // cuboid(20) // attach(TOP) // screw_hole("1/4-20,.5",head="flat",counterbore=0,anchor=TOP); -// Example: Threaded hole -// diff() -// cuboid(20) -// attach(FRONT) -// screw_hole("M16,15",anchor=TOP,thread=true); +// Example: Threaded hole, with inward bevel at the base +// bottom_half() +// diff() +// cuboid(20) +// attach(FRONT) +// screw_hole("M16,15",anchor=TOP,thread=true,bevel1="reverse"); +function screw_hole(spec, head, thread, oversize, hole_oversize, head_oversize, + length, l, thread_len, tolerance=undef, counterbore, teardrop=false, + bevel, bevel1, bevel2, blunt_start, blunt_start1, blunt_start2, + atype="screw",anchor=CENTER,spin=0, orient=UP) + = no_function("screw_hole"); module screw_hole(spec, head, thread, oversize, hole_oversize, head_oversize, length, l, thread_len, tolerance=undef, counterbore, teardrop=false, - bevel, bevel1, bevel2, higbee=false, + bevel, bevel1, bevel2, blunt_start, blunt_start1, blunt_start2, atype="screw",anchor=CENTER,spin=0, orient=UP) { screwspec = _get_spec(spec, "screw_info", "screw_hole", @@ -821,9 +840,10 @@ module screw_hole(spec, head, thread, oversize, hole_oversize, head_oversize, head_oversize = first_defined([head_oversize, oversize[1],struct_val(screwspec,"head_oversize")]); if (threaded || is_def(hole_oversize) || tolerance==0 || tolerance=="none") { default_tag("remove") - screw(spec,head=head,thread=thread,shaft_undersize=u_mul(-1,hole_oversize), head_undersize=u_mul(-1,head_oversize), higbee=higbee, + screw(spec,head=head,thread=thread,shaft_undersize=u_mul(-1,hole_oversize), head_undersize=u_mul(-1,head_oversize), + blunt_start=blunt_start, blunt_start1=blunt_start1, blunt_start2=blunt_start2, length=length,l=l,thread_len=thread_len, tolerance=tolerance, _counterbore=counterbore, - bevel=bevel, bevel1=bevel1, bevel2=bevel2, + bevel1=bevel1, bevel2=bevel2, atype=atype, anchor=anchor, spin=spin, orient=orient, _internal=true, _teardrop=teardrop) children(); } @@ -944,7 +964,7 @@ module screw_hole(spec, head, thread, oversize, hole_oversize, head_oversize, default_tag("remove") screw(spec,head=head,thread=0,shaft_undersize=-hole_oversize, head_undersize=-head_oversize, length=length,l=l,thread_len=thread_len, _counterbore=counterbore, - bevel=bevel, bevel1=bevel1, bevel2=bevel2, bevelsize=pitch>0?pitch:undef, higbee=higbee, + bevel1=bevel1, bevel2=bevel2, bevelsize=pitch>0?pitch:undef, atype=atype, anchor=anchor, spin=spin, orient=orient, _internal=true, _teardrop=teardrop) children(); } @@ -1025,8 +1045,13 @@ module screw_hole(spec, head, thread, oversize, hole_oversize, head_oversize, // shoulder_screw("iso", 16, length=20, head="none"); // Example: Changing head height // shoulder_screw("iso", 16, length=20, head_size=[24,5]); +function shoulder_screw(s,d,length,head, thread_len, tolerance, head_size, drive, drive_size, thread, + undersize, shaft_undersize, head_undersize, shoulder_undersize=0, + blunt_start, blunt_start1, blunt_start2, + atype="screw", anchor=BOT, orient,spin) = no_function("shoulder_screw"); module shoulder_screw(s,d,length,head, thread_len, tolerance, head_size, drive, drive_size, thread, - undersize, shaft_undersize, head_undersize, shoulder_undersize=0, + undersize, shaft_undersize, head_undersize, shoulder_undersize=0, + blunt_start, blunt_start1, blunt_start2, atype="screw", anchor=BOT, orient,spin) { d1= assert(is_num(d) && d>0, "Must specify shoulder diameter") @@ -1121,6 +1146,7 @@ module shoulder_screw(s,d,length,head, thread_len, tolerance, head_size, drive, screw(struct_set(info, headfields), _shoulder_len = length, _shoulder_diam = shoulder_diam-shoulder_tol, length=thread_len, tolerance=tolerance, shaft_undersize=shaft_undersize, head_undersize=head_undersize, + blunt_start=blunt_start, blunt_start1=blunt_start1, blunt_start2=blunt_start2, atype=atype, anchor=anchor, orient=orient, spin=spin) children(); } @@ -1486,9 +1512,9 @@ module screw_head(screw_info,details=false, counterbore=0,flat_height,teardrop=f // ibevel = if true, bevel the inside (the hole). Default: true // ibevel1 = if true bevel the inside, bottom end. // ibevel2 = if true bevel the inside, top end. -// higbee = If true apply higbee thread truncation at both ends, or set to an angle to adjust higbee cut point. Default: false -// higbee1 = If true apply higbee thread truncation at bottom end, or set to an angle to adjust higbee cut point. -// higbee2 = If true apply higbee thread truncation at top end, or set to an angle to adjust higbee cut point. +// blunt_start = If true apply truncated blunt start threads at both ends. Default: true +// blunt_start1 = If true apply truncated blunt start threads bottom end. +// blunt_start2 = If true apply truncated blunt start threads top end. // tolerance = nut tolerance. Determines actual nut thread geometry based on nominal sizing. See [tolerance](#subsection-tolerance). Default is "2B" for UTS and "6H" for ISO. // $slop = extra space left to account for printing over-extrusion. Default: 0 // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` @@ -1537,7 +1563,7 @@ function nut(spec, shape, thickness, nutwidth, thread, tolerance, hole_oversize, bevel,bevel1,bevel2,bevang=15,ibevel,ibevel1,ibevel2, higbee, higbee1, higbee2, anchor=BOTTOM, spin=0, orient=UP, oversize=0) = no_function("nut"); module nut(spec, shape, thickness, nutwidth, thread, tolerance, hole_oversize, - bevel,bevel1,bevel2,bevang=15,ibevel,ibevel1,ibevel2, higbee, higbee1, higbee2, anchor=BOTTOM, spin=0, orient=UP, oversize=0) + bevel,bevel1,bevel2,bevang=15,ibevel,ibevel1,ibevel2,blunt_start, blunt_start1, blunt_start2, anchor=BOTTOM, spin=0, orient=UP, oversize=0) { dummyA = assert(is_undef(nutwidth) || (is_num(nutwidth) && nutwidth>0)); @@ -1565,11 +1591,15 @@ module nut(spec, shape, thickness, nutwidth, thread, tolerance, hole_oversize, shape=shape, bevel=bevel,bevel1=bevel1,bevel2=bevel2,bevang=bevang, ibevel=ibevel,ibevel1=ibevel1,ibevel2=ibevel2, - higbee=higbee, higbee1=higbee1, higbee2=higbee2, + blunt_start=blunt_start, blunt_start1=blunt_start1, blunt_start2=blunt_start2, anchor=anchor,spin=spin,orient=orient) children(); } + + + + // Module: nut_trap_side() // Usage: // nut_trap_side(trap_width, [spec], [shape], [thickness], [nutwidth=], [poke_len=], [poke_diam=], [$slop=], [anchor=], [orient=], [spin=]) [ATTACHMENTS]; diff --git a/skin.scad b/skin.scad index 560a630..c709418 100644 --- a/skin.scad +++ b/skin.scad @@ -1053,132 +1053,140 @@ module rotate_sweep( // Takes a closed 2D polygon path, centered on the XY plane, and sweeps/extrudes it along a 3D spiral path // of a given radius, height and degrees of rotation. The origin in the profile traces out the helix of the specified radius. // If turns is positive the path will be right-handed; if turns is negative the path will be left-handed. +// Such an extrusion can be used to make screw threads. // . -// The taper options specify tapering at of the ends of the extrusion, and are given as the linear distance -// over which to taper. If taper is positive the extrusion lengthened by the specified distance; if taper -// is negative, the taper is included in the extrusion length specified by `turns`. +// The lead_in options specify a lead-in setiton where the ends of the spiral scale down to avoid a sharp cut face at the ends. +// You can specify the length of this scaling directly with the lead_in parameters or as an angle using the lead_in_ang parameters. +// If you give a positive value, the extrusion is lengthenend by the specified distance or angle; if you give a negative +// value then the scaled end is included in the extrusion length specified by `turns`. If the value is zero then no scaled ends +// are produced. The shape of the scaled ends can be controlled with the lead_in_shape parameter. Supported options are "sqrt", "linear" +// "smooth" and "cut". +// . +// The inside argument changes how the extrusion lead-in sections are formed. If it is true then they scale +// towards the outside, like would be needed for internal threading. If internal is fale then the lead-in sections scale +// towards the inside, like would be appropriate for external threads. // Arguments: // poly = Array of points of a polygon path, to be extruded. -// h = height of the spiral to extrude along. -// r = Radius of the spiral to extrude along. -// turns = number of revolutions to spiral up along the height. +// h = height of the spiral extrusion path +// r = Radius of the spiral extrusion path +// turns = number of revolutions to include in the spiral // --- -// d = Diameter of the spiral to extrude along. +// d = Diameter of the spiral extrusion path. // d1/r1 = Bottom inside diameter or radius of spiral to extrude along. // d2/r2 = Top inside diameter or radius of spiral to extrude along. -// taper = Length of tapers for thread ends. Positive to add taper to threads, negative to taper within specified length. Default: 0 -// taper1 = Length of taper for bottom thread end -// taper2 = Length of taper for top thread end -// internal = if true make internal threads. The only effect this has is to change how the extrusion tapers if tapering is selected. When true, the extrusion tapers towards the outside; when false, it tapers towards the inside. Default: false +// lead_in = Specify linear length of the lead-in scaled section of the spiral. Default: 0 +// lead_in1 = Specify linear length of the lead-in scaled section of the spiral at the bottom +// lead_in2 = Specify linear length of the lead-in scaled section of the spiral at the top +// lead_in_ang = Specify angular length of the lead-in scaled section of the spiral +// lead_in_ang1 = Specify angular length of the lead-in scaled section of the spiral at the bottom +// lead_in_ang2 = Specify angular length of the lead-in scaled section of the spiral at the top +// lead_in_shape = Specify the shape of the thread lead in by giving a text string or function. Default: "sqrt" +// lead_in_shape1 = Specify the shape of the thread lead-in at the bottom by giving a text string or function. +// lead_in_shape2 = Specify the shape of the thread lead-in at the top by giving a text string or function. +// lead_in_sample = Factor to increase sample rate in the lead-in section. Default: 10 +// internal = if true make internal threads. The only effect this has is to change how the extrusion lead-in section are formed. When true, the extrusion scales towards the outside; when false, it scales towards the inside. Default: false // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` -// center = If given, overrides `anchor`. A true value sets `anchor=CENTER`, false sets `anchor=BOTTOM`. -// See Also: sweep(), linear_sweep(), rotate_sweep(), path_sweep() +// See Also: sweep(), linear_sweep(), rotate_sweep(), path_sweep(), thread_helix() // Example: // poly = [[-10,0], [-3,-5], [3,-5], [10,0], [0,-30]]; // spiral_sweep(poly, h=200, r=50, turns=3, $fn=36); -function _taperfunc_orig_1d(x,L) = - x>1 ? 1 : x<0 ? 0: - let( - higofs = pow(0.05,2) // Smallest hig scale is the square root of this value - ) - sqrt((1-higofs)*x+higofs); - -function _taperfunc_orig(x,L) = - let(s=_taperfunc_orig_1d(x)) - x>1 ? [1,1] - : x<0 ? [0,0] - - : [lerp(s,1,.25),s]; -function _taperfunc_ellipse(x) = - sqrt(1-(1-x)^2); -function _taperfunc_linear(x) = - x>1 ? 1 : x<0 ? 0 : x; -function _taperfunc_ogive_width(x,L) = - let( minscale = .2, +_leadin_ogive=function (x,L) + let( minscale = .05, r=(L^2+(1-minscale^2))/2/(1-minscale), scale = sqrt(r^2-(L*(1-x))^2) -(r-1) ) x>1 ? [1,1] - : x<0 ? [0,0] - : [scale,1]; -function _taperfunc_ogive_width_circle(x,L,h) = - let( minscale = .2, - r=(L^2+(1-minscale^2))/2/(1-minscale), - scale = sqrt(r^2-(L*(1-x))^2) -(r-1), - vscale = x*L>h ? h : sqrt(h^2-(x*L-h)^2) - ) + : x<0 ? [lerp(minscale,1,.25),0] + : [lerp(scale,1,.25),scale]; + +_leadin_cut = function(x,L) x>0 ? [1,1] : [1,0]; + +_leadin_sqrt = function(x,L) + let(end=0.05) // Smallest scale at the end x>1 ? [1,1] - : x<0.02 ? [0,0] - : [scale,vscale/h]; -function _taperfunc_ogive_height(x,L) = - let( minscale = .1,L=3*L, - r=(L^2+(1-minscale^2))/2/(1-minscale), - scale = sqrt(r^2-(L*(1-x))^2) -(r-1) + : x<0 ? [lerp(end,1,.25),0] + : let( + s = sqrt(x + end^2 * (1-x)) ) + [lerp(s,1,.25),s]; // thread width scale, thread height scale + +_leadin_linear = function(x,L) + let(minscale=.1) x>1 ? [1,1] - : x<0 ? [0,0] //minscale,0] - : [1,scale]; -function _taperfunc_ogive(x,L) = - let( minscale = .3, - r=(L^2+(1-minscale^2))/2/(1-minscale), - scale = sqrt(r^2-(L*(1-x))^2) -(r-1) - ) - x>1 ? [1,1] - : x<0 ? [0,0] - : [scale,scale]; -function _taperfunc_ogive_orig(x,L) = - let( minscale = .3, - r=(L^2+(1-minscale^2))/2/(1-minscale), - scale = sqrt(r^2-(L*(1-x))^2) -(r-1) - ) - x>1 ? [1,1] - : x<0 ? [0,0] - : [lerp(_taperfunc_orig_1d(x),1,.25),scale]; - -function _taperfunc_cut(x,L) = x>1 ? [1,1] : [0,0]; - - -function _taperfunc(x,L,h) = _taperfunc_ogive_width_circle(x,L,h); -//function _taperfunc(x,L,h) = _taperfunc_orig(x,L); -//function _taperfunc(x,L,h) = _taperfunc_ogive_width(x,L); -function _taperfunc(x,L,h) = _taperfunc_orig(x,L); - + : x<0 ? [lerp(minscale,1,.25),0] + : let(scale = lerp(minscale,1,x)) + [lerp(scale,1,.25),scale]; +_lead_in_table = [ + ["default", _leadin_sqrt], + ["sqrt", _leadin_sqrt], + ["cut", _leadin_cut], + ["smooth", _leadin_ogive], + ["linear", _leadin_linear] +]; + function _ss_polygon_r(N,theta) = let( alpha = 360/N ) cos(alpha/2)/(cos(posmod(theta,alpha)-alpha/2)); -function spiral_sweep(poly, h, r, turns=1, taper, center, r1, r2, d, d1, d2, taper1, taper2, internal=false, anchor=CENTER, spin=0, orient=UP) = +function spiral_sweep(poly, h, r, turns=1, taper, r1, r2, d, d1, d2, internal=false, + lead_in_shape,lead_in_shape1, lead_in_shape2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + height,l,length, + lead_in_sample = 10, + anchor=CENTER, spin=0, orient=UP) = assert(is_num(turns) && turns != 0, "turns must be a nonzero number") assert(all_positive([h]), "Spiral height must be a positive number") let( - tapersample = 10, // Oversample factor for higbee tapering dir = sign(turns), - r1 = get_radius(r1=r1, r=r, d1=d1, d=d, dflt=50), - r2 = get_radius(r1=r2, r=r, d1=d2, d=d, dflt=50), + r1 = get_radius(r1=r1, r=r, d1=d1, d=d), + r2 = get_radius(r1=r2, r=r, d1=d2, d=d), bounds = pointlist_bounds(poly), yctr = (bounds[0].y+bounds[1].y)/2, xmin = bounds[0].x, xmax = bounds[1].x, poly = path3d(clockwise_polygon(poly)), - anchor = get_anchor(anchor,center,BOT,BOT), sides = segs(max(r1,r2)), ang_step = 360/sides, turns = abs(turns), - taper1 = first_defined([taper1, taper, 0]), - taper2 = first_defined([taper2, taper, 0]), - taperang1 = 360 * abs(taper1) / (2 * r1 * PI), - taperang2 = 360 * abs(taper2) / (2 * r2 * PI), - minang = taper1<=0 ? 0 : -taperang1, - tapercut1 = taper1<=0 ? taperang1 : 0, - maxang = taper2<=0 ? 360*turns : 360*turns+taperang2, - tapercut2 = taper2<=0 ? 360*turns-taperang2 : 360*turns + lead_in1 = first_defined([lead_in1, lead_in]), + lead_in2 = first_defined([lead_in1, lead_in]), + lead_in_ang1 = + let( + user_ang = first_defined([lead_in_ang1,lead_in_ang]) + ) + assert(is_undef(user_ang) || is_undef(lead_in1), "Cannot define lead_in/lead_in1 by both length and angle") + is_def(user_ang) ? user_ang : default(lead_in1,0)*360/(2*PI*r1), + lead_in_ang2 = + let( + user_ang = first_defined([lead_in_ang2,lead_in_ang]) + ) + assert(is_undef(user_ang) || is_undef(lead_in2), "Cannot define lead_in/lead_in2 by both length and angle") + is_def(user_ang) ? user_ang : default(lead_in2,0)*360/(2*PI*r2), + minang = -max(0,lead_in_ang1), + maxang = 360*turns + max(0,lead_in_ang2), + cut_ang1 = minang+abs(lead_in_ang1), + cut_ang2 = maxang-abs(lead_in_ang1), + lead_in_shape1 = first_defined([lead_in_shape1, lead_in_shape, "default"]), + lead_in_shape2 = first_defined([lead_in_shape2, lead_in_shape, "default"]), + lead_in_func1 = is_func(lead_in_shape1) ? lead_in_shape1 + : assert(is_string(lead_in_shape1),"lead_in_shape/lead_in_shape1 must be a function or string") + let(ind = search([lead_in_shape1], _lead_in_table,0)[0]) + assert(ind!=[],str("Unknown lead_in_shape, \"",lead_in_shape1,"\"")) + _lead_in_table[ind[0]][1], + lead_in_func2 = is_func(lead_in_shape2) ? lead_in_shape2 + : assert(is_string(lead_in_shape2),"lead_in_shape/lead_in_shape2 must be a function or string") + let(ind = search([lead_in_shape2], _lead_in_table,0)[0]) + assert(ind!=[],str("Unknown lead_in_shape, \"",lead_in_shape2,"\"")) + _lead_in_table[ind[0]][1] ) - assert( tapercut1tapercut1+EPSILON && atapercut2+EPSILON) a + for(a=orig_anglist) if (acut_ang1+EPSILON && acut_ang2+EPSILON) a ], interp_ang = [ - for(i=idx(anglist,e=-2)) + for(i=idx(anglist,e=-2)) each lerpn(anglist[i],anglist[i+1], - (taper1!=0 && anglist[i+1]<=tapercut1) || (taper2!=0 && anglist[i]>=tapercut2) - ? ceil((anglist[i+1]-anglist[i])/ang_step*tapersample) + (lead_in_ang1!=0 && anglist[i+1]<=cut_ang1) || (lead_in_ang2!=0 && anglist[i]>=cut_ang2) + ? ceil((anglist[i+1]-anglist[i])/ang_step*lead_in_sample) : 1, endpoint=false), last(anglist) @@ -1207,8 +1215,8 @@ function spiral_sweep(poly, h, r, turns=1, taper, center, r1, r2, d, d1, d2, tap skewmat = affine3d_skew_xz(xa=atan2(r2-r1,h)), points = [ for (a = interp_ang) let ( - hsc = atapercut2 ? _taperfunc((maxang-a)/taperang2,abs(taper2),xmax-xmin) + hsc = acut_ang2 ? lead_in_func2((maxang-a)/abs(lead_in_ang2),abs(lead_in_ang2)*2*PI*r2/360) : [1,1], u = a/(360*turns), r = lerp(r1,r2,u), @@ -1230,15 +1238,30 @@ function spiral_sweep(poly, h, r, turns=1, taper, center, r1, r2, d, d1, d2, tap -module spiral_sweep(poly, h, r, turns=1, taper, center, r1, r2, d, d1, d2, taper1, taper2, internal=false, anchor=CENTER, spin=0, orient=UP) { - vnf = spiral_sweep(poly, h, r, turns, taper, center, r1, r2, d, d1, d2, taper1, taper2, internal); - r1 = get_radius(r1=r1, r=r, d1=d1, d=d, dflt=50); - r2 = get_radius(r1=r2, r=r, d1=d2, d=d, dflt=50); - taper1 = first_defined([taper1,taper,0]); - taper2 = first_defined([taper2,taper,0]); - extra = PI/2*(max(0,taper1/r1)+max(0,taper2/r2)); +module spiral_sweep(poly, h, r, turns=1, taper, r1, r2, d, d1, d2, internal=false, + lead_in_shape,lead_in_shape1, lead_in_shape2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + height,l,length, + lead_in_sample=10, + anchor=CENTER, spin=0, orient=UP) +{ + vnf = spiral_sweep(poly=poly, h=h, r=r, turns=turns, r1=r1, r2=r2, d=d, d1=d1, d2=d2, internal=internal, + lead_in_shape=lead_in_shape,lead_in_shape1=lead_in_shape1, lead_in_shape2=lead_in_shape2, + lead_in=lead_in, lead_in1=lead_in1, lead_in2=lead_in2, + lead_in_ang=lead_in_ang, lead_in_ang1=lead_in_ang1, lead_in_ang2=lead_in_ang2, + height=height,l=length,length=length, + lead_in_sample=lead_in_sample); + h = one_defined([h,height,length,l],"h,height,length,l"); + r1 = get_radius(r1=r1, r=r, d1=d1, d=d); + r2 = get_radius(r1=r2, r=r, d1=d2, d=d); + lead_in1 = u_mul(first_defined([lead_in1,lead_in]),1/(2*PI*r1)); + lead_in2 = u_mul(first_defined([lead_in2,lead_in]),1/(2*PI*r2)); + lead_in_ang1 = first_defined([lead_in_ang1,lead_in_ang]); + lead_in_ang2 = first_defined([lead_in_ang2,lead_in_ang]); + extra_turns = max(0,first_defined([lead_in1,lead_in_ang1,0]))+max(0,first_defined([lead_in2,lead_in_ang2,0])); attachable(anchor,spin,orient, r1=r1, r2=r2, l=h) { - vnf_polyhedron(vnf, convexity=ceil(2*(abs(turns)+extra))); + vnf_polyhedron(vnf, convexity=ceil(2*(abs(turns)+extra_turns))); children(); } } @@ -1796,7 +1819,22 @@ function path_sweep(shape, path, method="incremental", normal, closed, twist=0, ) assert(approx(ynormal*znormal,0),str("Supplied normal is parallel to the path tangent at point ",i)) translate(path[i%L])*rotation*zrot(-twist*tpathfrac[i]) - ] + ] + : method=="cross"? + let( + crossnormal_mid = [for(i=[(closed?0:1):L-(closed?1:2)]) + let(v= cross( select(path,i+1)-path[i], path[i]-select(path,i-1)), + f=assert(norm(v)>EPSILON) + ) + v + ], + crossnormal = closed ? crossnormal_mid : [crossnormal_mid[0], each crossnormal_mid, last(crossnormal_mid)] + ) + [for(i=[0:L-(closed?0:1)]) let( + rotation = frame_map(x=crossnormal[i%L], z=tangents[i%L]) + ) + translate(path[i%L])*rotation*zrot(-twist*tpathfrac[i]) + ] : method=="natural" ? // map x axis of shape to the path normal, which points in direction of curvature let (pathnormal = path_normals(path, tangents, closed)) assert(all_defined(pathnormal),"Natural normal vanishes on your curve, select a different method") diff --git a/threading.scad b/threading.scad index 465af98..1fbb746 100644 --- a/threading.scad +++ b/threading.scad @@ -22,7 +22,7 @@ // using the specification parameters. // Arguments: // d = Outer diameter of threaded rod, or a triplet of [d_min, d_pitch, d_major]. -// l / length = length of threaded rod. +// l / length / h / height = length of threaded rod. // pitch = Length between threads. // --- // left_handed = if true, create left-handed threads. Default = false @@ -33,9 +33,19 @@ // internal = If true, make this a mask for making internal threads. // d1 = Bottom outside diameter of threads. // d2 = Top outside diameter of threads. -// higbee = If true apply higbee thread truncation at both ends, or set to an angle to adjust higbee cut point. Default: false -// higbee1 = If true apply higbee thread truncation at bottom end, or set to an angle to adjust higbee cut point. -// higbee2 = If true apply higbee thread truncation at top end, or set to an angle to adjust higbee cut point. +// blunt_start = If true apply truncated blunt start threads at both ends. Default: true +// blunt_start1 = If true apply truncated blunt start threads bottom end. +// blunt_start2 = If true apply truncated blunt start threads top end. +// end_len = Specify the unthreaded length at the end after blunt start threads. Default: 0 +// end_len1 = Specify unthreaded length at the bottom +// end_len2 = Specify unthreaded length at the top +// lead_in = Specify linear length of the lead in section of the threading with blunt start threads +// lead_in1 = Specify linear length of the lead in section of the threading at the bottom with blunt start threads +// lead_in2 = Specify linear length of the lead in section of the threading at the top with blunt start threads +// lead_in_ang = Specify angular length in degrees of the lead in section of the threading with blunt start threads +// lead_in_ang1 = Specify angular length in degrees of the lead in section of the threading at the bottom with blunt start threads +// lead_in_ang2 = Specify angular length in degrees of the lead in section of the threading at the top with blunt start threads +// lead_in_shape = Specify the shape of the thread lead in by giving a text string or function. Default: "default" // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` @@ -44,18 +54,19 @@ // projection(cut=true) // threaded_rod(d=10, l=15, pitch=1.5, orient=BACK); // Examples(Med): +// threaded_rod(d=25, height=20, pitch=2, $fa=1, $fs=1); // threaded_rod(d=10, l=20, pitch=1.25, left_handed=true, $fa=1, $fs=1); -// threaded_rod(d=25, l=20, pitch=2, $fa=1, $fs=1); -// threaded_rod(d=25, l=20, pitch=2, $fa=1, $fs=1, bevel=true); -// rot(90)threaded_rod(d=25, l=20, pitch=2, $fa=1, $fs=1, higbee=true); +// threaded_rod(d=25, l=20, pitch=2, $fa=1, $fs=1, end_len=1.5, bevel=true); +// threaded_rod(d=25, l=20, pitch=2, $fa=1, $fs=1, blunt_start=false); // Example: Diamond threading where both left-handed and right-handed nuts travel (in the same direction) on the threaded rod: +// $fn=32; // $slop = 0.075; // d = 3/8*INCH; // pitch = 1/16*INCH; // starts=3; // xdistribute(19){ // intersection(){ -// threaded_rod(l=40, pitch=pitch, d=d,starts=starts,anchor=BOTTOM); +// threaded_rod(l=40, pitch=pitch, d=d,starts=starts,anchor=BOTTOM,end_len=.44); // threaded_rod(l=40, pitch=pitch, d=d, left_handed=true,starts=starts,anchor=BOTTOM); // } // threaded_nut(nutwidth=4.5/8*INCH,id=d,h=3/8*INCH,pitch=pitch,starts=starts,anchor=BOTTOM); @@ -66,8 +77,12 @@ function threaded_rod( left_handed=false, bevel,bevel1,bevel2,starts=1, internal=false, - d1, d2, - higbee, higbee1, higbee2, + d1, d2, length, h, height, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", anchor, spin, orient ) = no_function("threaded_rod"); @@ -76,14 +91,17 @@ module threaded_rod( left_handed=false, bevel,bevel1,bevel2,starts=1, internal=false, - d1, d2, length, - higbee, higbee1, higbee2, + d1, d2, length, h, height, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", anchor, spin, orient ) { dummy1= assert(all_positive(pitch)) - assert(all_positive(d)) - assert(all_positive(l)); + assert(all_positive(d) || (is_undef(d) && all_positive([d1,d2]))); basic = is_num(d) || is_undef(d) || is_def(d1) || is_def(d2); dummy2 = assert(basic || is_vector(d,3)); depth = basic ? cos(30) * 5/8 @@ -116,10 +134,11 @@ module threaded_rod( profile=profile,starts=starts, left_handed=left_handed, bevel=bevel,bevel1=bevel1,bevel2=bevel2, - internal=internal, length=length, - higbee=higbee, - higbee1=higbee1, - higbee2=higbee2, + internal=internal, length=length, height=height, h=h, + blunt_start=blunt_start, blunt_start1=blunt_start1, blunt_start2=blunt_start2, + lead_in=lead_in, lead_in1=lead_in1, lead_in2=lead_in2, lead_in_shape=lead_in_shape, + lead_in_ang=lead_in_ang, lead_in_ang1=lead_in_ang1, lead_in_ang2=lead_in_ang2, + end_len=end_len, end_len1=end_len1, end_len2=end_len2, anchor=anchor, spin=spin, orient=orient @@ -136,7 +155,7 @@ module threaded_rod( // Arguments: // nutwidth = flat to flat width of nut // id = diameter of threaded rod to screw onto. -// h / height / thickness = height/thickness of nut. +// h / height / l / length / thickness = height/thickness of nut. // pitch = Distance between threads, or zero for no threads. // --- // shape = specifies shape of nut, either "hex" or "square". Default: "hex" @@ -149,9 +168,19 @@ module threaded_rod( // ibevel = if true, bevel the inside (the hole). Default: true // ibevel1 = if true bevel the inside, bottom end. // ibevel2 = if true bevel the inside, top end. -// higbee = If true apply higbee thread truncation at both ends, or set to an angle to adjust higbee cut point. Default: false -// higbee1 = If true apply higbee thread truncation at bottom end, or set to an angle to adjust higbee cut point. -// higbee2 = If true apply higbee thread truncation at top end, or set to an angle to adjust higbee cut point. +// blunt_start = If true apply truncated blunt start threads at both ends. Default: true +// blunt_start1 = If true apply truncated blunt start threads bottom end. +// blunt_start2 = If true apply truncated blunt start threads top end. +// end_len = Specify the unthreaded length at the end after blunt start threads. Default: 0 +// end_len1 = Specify unthreaded length at the bottom +// end_len2 = Specify unthreaded length at the top +// lead_in = Specify linear length of the lead in section of the threading with blunt start threads +// lead_in1 = Specify linear length of the lead in section of the threading at the bottom with blunt start threads +// lead_in2 = Specify linear length of the lead in section of the threading at the top with blunt start threads +// lead_in_ang = Specify angular length in degrees of the lead in section of the threading with blunt start threads +// lead_in_ang1 = Specify angular length in degrees of the lead in section of the threading at the bottom with blunt start threads +// lead_in_ang2 = Specify angular length in degrees of the lead in section of the threading at the top with blunt start threads +// lead_in_shape = Specify the shape of the thread lead in by giving a text string or function. Default: "default" // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` @@ -161,18 +190,29 @@ module threaded_rod( // threaded_nut(nutwidth=16, id=8, h=8, pitch=1.25, left_handed=true, bevel=false, $slop=0.1, $fa=1, $fs=1); // threaded_nut(shape="square", nutwidth=16, id=8, h=8, pitch=1.25, $slop=0.1, $fa=1, $fs=1); // threaded_nut(shape="square", nutwidth=16, id=8, h=8, pitch=1.25, bevel2=true, $slop=0.1, $fa=1, $fs=1); -// rot(90)threaded_nut(nutwidth=16, id=8, h=8, pitch=1.25,higbee=true, $slop=0.1, $fa=1, $fs=1); +// rot(90)threaded_nut(nutwidth=16, id=8, h=8, pitch=1.25,blunt_start=false, $slop=0.1, $fa=1, $fs=1); function threaded_nut( nutwidth, id, h, pitch, starts=1, shape="hex", left_handed=false, bevel, bevel1, bevel2, id1,id2, - ibevel1, ibevel2, ibevel, bevang=30, thickness, height, + ibevel1, ibevel2, ibevel, bevang=30, thickness, height, + length, l, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", anchor, spin, orient )=no_function("threaded_nut"); module threaded_nut( nutwidth, id, h, pitch, starts=1, shape="hex", left_handed=false, bevel, bevel1, bevel2, id1,id2, ibevel1, ibevel2, ibevel, bevang=30, thickness, height, - higbee, higbee1, higbee2, + length, l, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", anchor, spin, orient ) { dummy1= @@ -207,8 +247,11 @@ module threaded_nut( left_handed=left_handed, bevel=bevel,bevel1=bevel1,bevel2=bevel2, ibevel1=ibevel1, ibevel2=ibevel2, ibevel=ibevel, - height=height, thickness=thickness, bevang=bevang, - higbee=higbee, higbee1=higbee1, higbee2=higbee2, + blunt_start=blunt_start, blunt_start1=blunt_start1, blunt_start2=blunt_start2, + lead_in=lead_in, lead_in1=lead_in1, lead_in2=lead_in2, lead_in_shape=lead_in_shape, + lead_in_ang=lead_in_ang, lead_in_ang1=lead_in_ang1, lead_in_ang2=lead_in_ang2, + end_len=end_len, end_len1=end_len1, end_len2=end_len2, + l=l,length=length, anchor=anchor, spin=spin, orient=orient ) children(); @@ -255,7 +298,7 @@ module threaded_nut( // } // Arguments: // d = Outer diameter of threaded rod. -// l / length = Length of threaded rod. +// l / length / h / height = Length of threaded rod. // pitch = Thread spacing. // thread_angle = Angle between two thread faces. Default: 30 // thread_depth = Depth of threads. Default: pitch/2 @@ -268,9 +311,19 @@ module threaded_nut( // internal = If true, make this a mask for making internal threads. Default: false // d1 = Bottom outside diameter of threads. // d2 = Top outside diameter of threads. -// higbee = If true apply higbee thread truncation at both ends, or set to an angle to adjust higbee cut point. Default: false -// higbee1 = If true apply higbee thread truncation at bottom end, or set to an angle to adjust higbee cut point. -// higbee2 = If true apply higbee thread truncation at top end, or set to an angle to adjust higbee cut point. +// blunt_start = If true apply truncated blunt start threads at both ends. Default: true +// blunt_start1 = If true apply truncated blunt start threads bottom end. +// blunt_start2 = If true apply truncated blunt start threads top end. +// end_len = Specify the unthreaded length at the end after blunt start threads. Default: 0 +// end_len1 = Specify unthreaded length at the bottom +// end_len2 = Specify unthreaded length at the top +// lead_in = Specify linear length of the lead in section of the threading with blunt start threads +// lead_in1 = Specify linear length of the lead in section of the threading at the bottom with blunt start threads +// lead_in2 = Specify linear length of the lead in section of the threading at the top with blunt start threads +// lead_in_ang = Specify angular length in degrees of the lead in section of the threading with blunt start threads +// lead_in_ang1 = Specify angular length in degrees of the lead in section of the threading at the bottom with blunt start threads +// lead_in_ang2 = Specify angular length in degrees of the lead in section of the threading at the top with blunt start threads +// lead_in_shape = Specify the shape of the thread lead in by giving a text string or function. Default: "default" // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` @@ -280,16 +333,18 @@ module threaded_nut( // trapezoidal_threaded_rod(d=10, l=15, pitch=2, orient=BACK); // Examples(Med): // trapezoidal_threaded_rod(d=10, l=40, pitch=2, $fn=32); // Standard metric threading -// rot(-65)trapezoidal_threaded_rod(d=10, l=17, pitch=2, higbee=25, $fn=32); // Standard metric threading +// rot(-65)trapezoidal_threaded_rod(d=10, l=17, pitch=2, blunt_start=false, $fn=32); // Standard metric threading // trapezoidal_threaded_rod(d=10, l=17, pitch=2, bevel=true, $fn=32); // Standard metric threading -// trapezoidal_threaded_rod(d=10, l=30, pitch=2, left_handed=true, $fa=1, $fs=1); // Standard metric threading +// trapezoidal_threaded_rod(d=10, h=30, pitch=2, left_handed=true, $fa=1, $fs=1); // Standard metric threading // trapezoidal_threaded_rod(d=10, l=40, pitch=3, left_handed=true, starts=3, $fn=36); // trapezoidal_threaded_rod(l=25, d=10, pitch=2, starts=3, $fa=1, $fs=1, bevel=true, orient=RIGHT, anchor=BOTTOM); -// trapezoidal_threaded_rod(d=60, l=16, pitch=8, thread_depth=3, thread_angle=90, left_handed=true, $fa=2, $fs=2); -// trapezoidal_threaded_rod(d=60, l=16, pitch=8, thread_depth=3, thread_angle=90, left_handed=true, starts=4, $fa=2, $fs=2); +// trapezoidal_threaded_rod(d=60, l=16, pitch=8, thread_depth=3, thread_angle=90, blunt_start=false, $fa=2, $fs=2); +// trapezoidal_threaded_rod(d=60, l=16, pitch=8, thread_depth=3, thread_angle=90, end_len=0, $fa=2, $fs=2); +// trapezoidal_threaded_rod(d=60, l=16, pitch=8, thread_depth=3, thread_angle=90, left_handed=true, starts=4, $fa=2, $fs=2,end_len=0); // trapezoidal_threaded_rod(d=16, l=40, pitch=2, thread_angle=60); -// trapezoidal_threaded_rod(d=25, l=40, pitch=10, thread_depth=8/3, thread_angle=100, starts=4, anchor=BOT, $fa=2, $fs=2); -// trapezoidal_threaded_rod(d=50, l=35, pitch=8, thread_angle=60, starts=11, higbee=true,$fn=120); +// trapezoidal_threaded_rod(d=25, l=40, pitch=10, thread_depth=8/3, thread_angle=100, starts=4, anchor=BOT, $fa=2, $fs=2,end_len=-2); +// trapezoidal_threaded_rod(d=50, l=35, pitch=8, thread_angle=60, starts=11, lead_in=3, $fn=120); +// trapezoidal_threaded_rod(d=10, l=40, end_len2=10, pitch=2, $fn=32); // Unthreaded top end section // Example(Med): Using as a Mask to Make Internal Threads // bottom_half() difference() { // cube(50, center=true); @@ -301,9 +356,14 @@ function trapezoidal_threaded_rod( thread_depth=undef, left_handed=false, bevel,bevel1,bevel2, - starts=1, length, + starts=1, internal=false, - higbee, higbee1, higbee2,d1,d2, + d1, d2, length, h, height, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", anchor, spin, orient ) = no_function("trapezoidal_threaded_rod"); module trapezoidal_threaded_rod( @@ -312,9 +372,14 @@ module trapezoidal_threaded_rod( thread_depth=undef, left_handed=false, bevel,bevel1,bevel2, - starts=1, length, + starts=1, internal=false, - higbee, higbee1, higbee2,d1,d2, + d1, d2, length, h, height, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", anchor, spin, orient ) { dummy0 = assert(all_positive(pitch)); @@ -332,8 +397,13 @@ module trapezoidal_threaded_rod( [ z2, rr1], ]; generic_threaded_rod(d=d,l=l,pitch=pitch,profile=profile, - left_handed=left_handed,bevel=bevel,bevel1=bevel1,bevel2=bevel2,starts=starts,internal=internal,d1=d1,d2=d2, - higbee=higbee,higbee1=higbee1,higbee2=higbee2,anchor=anchor,spin=spin,orient=orient,length=length) + left_handed=left_handed,bevel=bevel,bevel1=bevel1,bevel2=bevel2,starts=starts,d1=d1,d2=d2, + internal=internal, length=length, height=height, h=h, + blunt_start=blunt_start, blunt_start1=blunt_start1, blunt_start2=blunt_start2, + lead_in=lead_in, lead_in1=lead_in1, lead_in2=lead_in2, lead_in_shape=lead_in_shape, + lead_in_ang=lead_in_ang, lead_in_ang1=lead_in_ang1, lead_in_ang2=lead_in_ang2, + end_len=end_len, end_len1=end_len1, end_len2=end_len2, + anchor=anchor,spin=spin,orient=orient) children(); } @@ -349,7 +419,7 @@ module trapezoidal_threaded_rod( // Arguments: // nutwidth = flat to flat width of nut // id = diameter of threaded rod to screw onto. -// h / height / thickness = height/thickness of nut. +// h / height / l / length / thickness = height/thickness of nut. // pitch = Thread spacing. // thread_angle = Angle between two thread faces. Default: 30 // thread_depth = Depth of the threads. Default: pitch/2 @@ -364,19 +434,29 @@ module trapezoidal_threaded_rod( // ibevel = if true, bevel the inside (the hole). Default: true // ibevel1 = if true bevel the inside, bottom end. // ibevel2 = if true bevel the inside, top end. -// higbee = If true apply higbee thread truncation at both ends, or set to an angle to adjust higbee cut point. Default: false -// higbee1 = If true apply higbee thread truncation at bottom end, or set to an angle to adjust higbee cut point. -// higbee2 = If true apply higbee thread truncation at top end, or set to an angle to adjust higbee cut point. +// blunt_start = If true apply truncated blunt start threads at both ends. Default: true +// blunt_start1 = If true apply truncated blunt start threads bottom end. +// blunt_start2 = If true apply truncated blunt start threads top end. +// end_len = Specify the unthreaded length at the end after blunt start threads. Default: 0 +// end_len1 = Specify unthreaded length at the bottom +// end_len2 = Specify unthreaded length at the top +// lead_in = Specify linear length of the lead in section of the threading with blunt start threads +// lead_in1 = Specify linear length of the lead in section of the threading at the bottom with blunt start threads +// lead_in2 = Specify linear length of the lead in section of the threading at the top with blunt start threads +// lead_in_ang = Specify angular length in degrees of the lead in section of the threading with blunt start threads +// lead_in_ang1 = Specify angular length in degrees of the lead in section of the threading at the bottom with blunt start threads +// lead_in_ang2 = Specify angular length in degrees of the lead in section of the threading at the top with blunt start threads +// lead_in_shape = Specify the shape of the thread lead in by giving a text string or function. Default: "default" // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` // $slop = The printer-specific slop value, which adds clearance (`4*$slop`) to internal threads. // Examples(Med): // trapezoidal_threaded_nut(nutwidth=16, id=8, h=8, pitch=2, $slop=0.1, anchor=UP); -// trapezoidal_threaded_nut(nutwidth=16, id=8, h=8, pitch=2, bevel=true, $slop=0.05, anchor=UP); +// trapezoidal_threaded_nut(nutwidth=16, id=8, h=8, pitch=2, bevel=false, $slop=0.05, anchor=UP); // trapezoidal_threaded_nut(nutwidth=17.4, id=10, h=10, pitch=2, $slop=0.1, left_handed=true); // trapezoidal_threaded_nut(nutwidth=17.4, id=10, h=10, pitch=2, starts=3, $fa=1, $fs=1, $slop=0.15); -// trapezoidal_threaded_nut(nutwidth=17.4, id=10, h=10, pitch=2, starts=3, $fa=1, $fs=1, $slop=0.15, higbee=true); +// trapezoidal_threaded_nut(nutwidth=17.4, id=10, h=10, pitch=2, starts=3, $fa=1, $fs=1, $slop=0.15, blunt_start=false); // trapezoidal_threaded_nut(nutwidth=17.4, id=10, h=10, pitch=0, $slop=0.2); // No threads function trapezoidal_threaded_nut( nutwidth, @@ -391,7 +471,12 @@ function trapezoidal_threaded_nut( ibevel1,ibevel2,ibevel, thickness,height, id1,id2, - higbee,higbee1,higbee2, + length, l, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", anchor, spin, orient ) = no_function("trapezoidal_threaded_nut"); module trapezoidal_threaded_nut( @@ -407,7 +492,12 @@ module trapezoidal_threaded_nut( ibevel1,ibevel2,ibevel, thickness,height, id1,id2, - higbee,higbee1,higbee2, + length, l, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", anchor, spin, orient ) { dummy1 = assert(is_num(pitch) && pitch>=0 && thread_angle>=0 && thread_angle<180); @@ -426,7 +516,11 @@ module trapezoidal_threaded_nut( generic_threaded_nut(nutwidth=nutwidth,id=id,h=h,pitch=pitch,profile=profile,id1=id1,id2=id2, shape=shape,left_handed=left_handed,bevel=bevel,bevel1=bevel1,bevel2=bevel2,starts=starts, ibevel=ibevel,ibevel1=ibevel1,ibevel2=ibevel2,bevang=bevang,height=height,thickness=thickness, - higbee=higbee, higbee1=higbee1, higbee2=higbee2, + blunt_start=blunt_start, blunt_start1=blunt_start1, blunt_start2=blunt_start2, + lead_in=lead_in, lead_in1=lead_in1, lead_in2=lead_in2, lead_in_shape=lead_in_shape, + lead_in_ang=lead_in_ang, lead_in_ang1=lead_in_ang1, lead_in_ang2=lead_in_ang2, + end_len=end_len, end_len1=end_len1, end_len2=end_len2, + l=l,length=length, anchor=anchor,spin=spin,orient=orient) children(); } @@ -440,7 +534,7 @@ module trapezoidal_threaded_nut( // symmetric trapezoidal thread. // Arguments: // d = Outer diameter of threaded rod. -// l / length = length of threaded rod. +// l / length / h / height = Length of threaded rod. // tpi = threads per inch. // --- // pitch = thread spacing (alternative to tpi) @@ -450,9 +544,19 @@ module trapezoidal_threaded_nut( // bevel1 = if true bevel the bottom end. // bevel2 = if true bevel the top end. // internal = If true, this is a mask for making internal threads. -// higbee = If true apply higbee thread truncation at both ends, or set to an angle to adjust higbee cut point. Default: false -// higbee1 = If true apply higbee thread truncation at bottom end, or set to an angle to adjust higbee cut point. -// higbee2 = If true apply higbee thread truncation at top end, or set to an angle to adjust higbee cut point. +// blunt_start = If true apply truncated blunt start threads at both ends. Default: true +// blunt_start1 = If true apply truncated blunt start threads bottom end. +// blunt_start2 = If true apply truncated blunt start threads top end. +// end_len = Specify the unthreaded length at the end after blunt start threads. Default: 0 +// end_len1 = Specify unthreaded length at the bottom +// end_len2 = Specify unthreaded length at the top +// lead_in = Specify linear length of the lead in section of the threading with blunt start threads +// lead_in1 = Specify linear length of the lead in section of the threading at the bottom with blunt start threads +// lead_in2 = Specify linear length of the lead in section of the threading at the top with blunt start threads +// lead_in_ang = Specify angular length in degrees of the lead in section of the threading with blunt start threads +// lead_in_ang1 = Specify angular length in degrees of the lead in section of the threading at the bottom with blunt start threads +// lead_in_ang2 = Specify angular length in degrees of the lead in section of the threading at the top with blunt start threads +// lead_in_shape = Specify the shape of the thread lead in by giving a text string or function. Default: "default" // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` @@ -468,8 +572,13 @@ function acme_threaded_rod( starts=1, left_handed=false, bevel,bevel1,bevel2, - internal=false, length, - higbee, higbee1, higbee2, + internal=false, + d1, d2, length, h, height, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", anchor, spin, orient ) = no_function("acme_threaded_rod"); module acme_threaded_rod( @@ -477,8 +586,13 @@ module acme_threaded_rod( starts=1, left_handed=false, bevel,bevel1,bevel2, - internal=false, length, - higbee, higbee1, higbee2, + internal=false, + d1, d2, length, h, height, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", anchor, spin, orient ) { dummy = assert(num_defined([pitch,tpi])==1,"Must give exactly one of pitch and tpi"); @@ -490,8 +604,11 @@ module acme_threaded_rod( starts=starts, left_handed=left_handed, bevel=bevel,bevel1=bevel1,bevel2=bevel2, - internal=internal, length=length, - higbee=higbee, + internal=internal, length=length, height=height, h=h, + blunt_start=blunt_start, blunt_start1=blunt_start1, blunt_start2=blunt_start2, + lead_in=lead_in, lead_in1=lead_in1, lead_in2=lead_in2, lead_in_shape=lead_in_shape, + lead_in_ang=lead_in_ang, lead_in_ang1=lead_in_ang1, lead_in_ang2=lead_in_ang2, + end_len=end_len, end_len1=end_len1, end_len2=end_len2, anchor=anchor, spin=spin, orient=orient @@ -508,7 +625,7 @@ module acme_threaded_rod( // Arguments: // nutwidth = flat to flat width of nut. // id = diameter of threaded rod to screw onto. -// h / height / thickness = height/thickness of nut. +// h / height / l / length / thickness = height/thickness of nut. // tpi = threads per inch // --- // pitch = Thread spacing (alternative to tpi) @@ -522,17 +639,27 @@ module acme_threaded_rod( // ibevel = if true, bevel the inside (the hole). Default: true // ibevel1 = if true bevel the inside, bottom end. // ibevel2 = if true bevel the inside, top end. -// higbee = If true apply higbee thread truncation at both ends, or set to an angle to adjust higbee cut point. Default: false -// higbee1 = If true apply higbee thread truncation at bottom end, or set to an angle to adjust higbee cut point. -// higbee2 = If true apply higbee thread truncation at top end, or set to an angle to adjust higbee cut point. +// blunt_start = If true apply truncated blunt start threads at both ends. Default: true +// blunt_start1 = If true apply truncated blunt start threads bottom end. +// blunt_start2 = If true apply truncated blunt start threads top end. +// end_len = Specify the unthreaded length at the end after blunt start threads. Default: 0 +// end_len1 = Specify unthreaded length at the bottom +// end_len2 = Specify unthreaded length at the top +// lead_in = Specify linear length of the lead in section of the threading with blunt start threads +// lead_in1 = Specify linear length of the lead in section of the threading at the bottom with blunt start threads +// lead_in2 = Specify linear length of the lead in section of the threading at the top with blunt start threads +// lead_in_ang = Specify angular length in degrees of the lead in section of the threading with blunt start threads +// lead_in_ang1 = Specify angular length in degrees of the lead in section of the threading at the bottom with blunt start threads +// lead_in_ang2 = Specify angular length in degrees of the lead in section of the threading at the top with blunt start threads +// lead_in_shape = Specify the shape of the thread lead in by giving a text string or function. Default: "default" // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` // $slop = The printer-specific slop value, which adds clearance (`4*$slop`) to internal threads. // Examples(Med): -// acme_threaded_nut(nutwidth=16, id=3/8*INCH, h=8, tpi=8, $slop=0.05); +// acme_threaded_nut(nutwidth=16, id=3/8*INCH, h=8, tpi=8, $slop=0.05,end_len=0,ibevel=1); // acme_threaded_nut(nutwidth=16, id=1/2*INCH, h=10, tpi=12, starts=3, $slop=0.1, $fa=1, $fs=1); -// acme_threaded_nut(nutwidth=16, id=1/2*INCH, h=10, tpi=12, starts=3, $slop=0.1, $fa=1, $fs=1,ibevel=false,higbee=true); +// acme_threaded_nut(nutwidth=16, id=1/2*INCH, h=10, tpi=12, starts=3, $slop=0.1, $fa=1, $fs=1, blunt_start=false); function acme_threaded_nut( nutwidth, id, h, tpi, pitch, starts=1, @@ -540,7 +667,12 @@ function acme_threaded_nut( bevel,bevel1,bevel2,bevang=30, ibevel,ibevel1,ibevel2, height,thickness, - higbee,higbee1,higbee2, + length, l, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", anchor, spin, orient ) = no_function("acme_threaded_nut"); module acme_threaded_nut( @@ -550,7 +682,12 @@ module acme_threaded_nut( bevel,bevel1,bevel2,bevang=30, ibevel,ibevel1,ibevel2, height,thickness, - higbee,higbee1,higbee2, + length, l, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", anchor, spin, orient ) { dummy = assert(num_defined([pitch,tpi])==1,"Must give exactly one of pitch and tpi"); @@ -564,8 +701,12 @@ module acme_threaded_nut( bevel=bevel,bevel1=bevel1,bevel2=bevel2, ibevel=ibevel,ibevel1=ibevel1,ibevel2=ibevel2, height=height,thickness=thickness, + blunt_start=blunt_start, blunt_start1=blunt_start1, blunt_start2=blunt_start2, + lead_in=lead_in, lead_in1=lead_in1, lead_in2=lead_in2, lead_in_shape=lead_in_shape, + lead_in_ang=lead_in_ang, lead_in_ang1=lead_in_ang1, lead_in_ang2=lead_in_ang2, + end_len=end_len, end_len1=end_len1, end_len2=end_len2, + l=l,length=length, starts=starts, - higbee=higbee, higbee1=higbee1, higbee2=higbee2, anchor=anchor, spin=spin, orient=orient @@ -684,7 +825,7 @@ module npt_threaded_rod( left_handed=left_handed, bevel=bevel,bevel1=bevel1,bevel2=bevel2, internal=internal, - higbee=true + blunt_start=true ); if (hollow) cylinder(h=l+1, d=size*INCH, center=true); } @@ -705,7 +846,7 @@ module npt_threaded_rod( // vises, which are loaded only in one direction. // Arguments: // d = Outer diameter of threaded rod. -// l / length = length of threaded rod. +// l / length / h / height = Length of threaded rod. // pitch = Thread spacing. // --- // left_handed = if true, create left-handed threads. Default = false @@ -714,9 +855,19 @@ module npt_threaded_rod( // bevel1 = if true bevel the bottom end. // bevel2 = if true bevel the top end. // internal = If true, this is a mask for making internal threads. -// higbee = If true apply higbee thread truncation at both ends, or set to an angle to adjust higbee cut point. Default: false -// higbee1 = If true apply higbee thread truncation at bottom end, or set to an angle to adjust higbee cut point. -// higbee2 = If true apply higbee thread truncation at top end, or set to an angle to adjust higbee cut point. +// blunt_start = If true apply truncated blunt start threads at both ends. Default: true +// blunt_start1 = If true apply truncated blunt start threads bottom end. +// blunt_start2 = If true apply truncated blunt start threads top end. +// end_len = Specify the unthreaded length at the end after blunt start threads. Default: 0 +// end_len1 = Specify unthreaded length at the bottom +// end_len2 = Specify unthreaded length at the top +// lead_in = Specify linear length of the lead in section of the threading with blunt start threads +// lead_in1 = Specify linear length of the lead in section of the threading at the bottom with blunt start threads +// lead_in2 = Specify linear length of the lead in section of the threading at the top with blunt start threads +// lead_in_ang = Specify angular length in degrees of the lead in section of the threading with blunt start threads +// lead_in_ang1 = Specify angular length in degrees of the lead in section of the threading at the bottom with blunt start threads +// lead_in_ang2 = Specify angular length in degrees of the lead in section of the threading at the top with blunt start threads +// lead_in_shape = Specify the shape of the thread lead in by giving a text string or function. Default: "default" // d1 = Bottom outside diameter of threads. // d2 = Top outside diameter of threads. // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` @@ -727,49 +878,55 @@ module npt_threaded_rod( // projection(cut=true) // buttress_threaded_rod(d=10, l=15, pitch=2, orient=BACK); // Examples(Med): +// buttress_threaded_rod(d=25, l=20, pitch=2, $fa=1, $fs=1,end_len=0); // buttress_threaded_rod(d=10, l=20, pitch=1.25, left_handed=true, $fa=1, $fs=1); -// buttress_threaded_rod(d=25, l=20, pitch=2, $fa=1, $fs=1); function buttress_threaded_rod( d, l, pitch, - left_handed=false, + left_handed=false, starts=1, bevel,bevel1,bevel2, internal=false, - higbee, higbee1, higbee2, - d1,d2,starts=1,length, + d1, d2, length, h, height, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", anchor, spin, orient ) = no_function("buttress_threaded_rod"); module buttress_threaded_rod( d, l, pitch, - left_handed=false, + left_handed=false, starts=1, bevel,bevel1,bevel2, internal=false, - higbee,higbee1,higbee2, - d1,d2,starts=1,length, + d1, d2, length, h, height, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", anchor, spin, orient ) { depth = pitch * 3/4; profile = [ + [ -1/2, -0.77], [ -7/16, -0.75], [ 5/16, 0], [ 7/16, 0], [ 7/16, -0.75], - [ 1/ 2, -0.77], + [ 1/2, -0.77], ]; - higbee2 = !internal || (!higbee && !higbee2) ? higbee2 - : let (higval = first_defined([higbee2,higbee])) - is_num(higval) ? higval + 270 - : 270; generic_threaded_rod( d=d, l=l, pitch=pitch, profile=profile, left_handed=left_handed, bevel=bevel,bevel1=bevel1,bevel2=bevel2, - internal=internal, - higbee=higbee, - higbee1=higbee1, - higbee2=higbee2, + internal=internal, length=length, height=height, h=h, + blunt_start=blunt_start, blunt_start1=blunt_start1, blunt_start2=blunt_start2, + lead_in=lead_in, lead_in1=lead_in1, lead_in2=lead_in2, lead_in_shape=lead_in_shape, + lead_in_ang=lead_in_ang, lead_in_ang1=lead_in_ang1, lead_in_ang2=lead_in_ang2, + end_len=end_len, end_len1=end_len1, end_len2=end_len2, d1=d1,d2=d2, - anchor=anchor,length=length, + anchor=anchor, spin=spin,starts=starts, orient=orient ) children(); @@ -785,7 +942,7 @@ module buttress_threaded_rod( // Arguments: // nutwidth = diameter of the nut. // id = diameter of threaded rod to screw onto. -// h = height/thickness of nut. +// h / height / l / length / thickness = height/thickness of nut. // pitch = Thread spacing. // --- // shape = specifies shape of nut, either "hex" or "square". Default: "hex" @@ -798,9 +955,19 @@ module buttress_threaded_rod( // ibevel = if true, bevel the inside (the hole). Default: true // ibevel1 = if true bevel the inside, bottom end. // ibevel2 = if true bevel the inside, top end. -// higbee = If true apply higbee thread truncation at both ends, or set to an angle to adjust higbee cut point. Default: false -// higbee1 = If true apply higbee thread truncation at bottom end, or set to an angle to adjust higbee cut point. -// higbee2 = If true apply higbee thread truncation at top end, or set to an angle to adjust higbee cut point. +// blunt_start = If true apply truncated blunt start threads at both ends. Default: true +// blunt_start1 = If true apply truncated blunt start threads bottom end. +// blunt_start2 = If true apply truncated blunt start threads top end. +// end_len = Specify the unthreaded length at the end after blunt start threads. Default: 0 +// end_len1 = Specify unthreaded length at the bottom +// end_len2 = Specify unthreaded length at the top +// lead_in = Specify linear length of the lead in section of the threading with blunt start threads +// lead_in1 = Specify linear length of the lead in section of the threading at the bottom with blunt start threads +// lead_in2 = Specify linear length of the lead in section of the threading at the top with blunt start threads +// lead_in_ang = Specify angular length in degrees of the lead in section of the threading with blunt start threads +// lead_in_ang1 = Specify angular length in degrees of the lead in section of the threading at the bottom with blunt start threads +// lead_in_ang2 = Specify angular length in degrees of the lead in section of the threading at the top with blunt start threads +// lead_in_shape = Specify the shape of the thread lead in by giving a text string or function. Default: "default" // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` @@ -812,7 +979,12 @@ function buttress_threaded_nut( pitch, shape="hex", left_handed=false, bevel,bevel1,bevel2,bevang=30,starts=1, ibevel,ibevel1,ibevel2,height,thickness, - higbee,higbee1,higbee2, + length, l, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", anchor, spin, orient ) = no_function("buttress_threaded_nut"); module buttress_threaded_nut( @@ -820,21 +992,23 @@ module buttress_threaded_nut( pitch, shape="hex", left_handed=false, bevel,bevel1,bevel2,bevang=30,starts=1, ibevel,ibevel1,ibevel2,height,thickness, - higbee,higbee1,higbee2, + length, l, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", anchor, spin, orient ) { depth = pitch * 3/4; profile = [ + [ -1/2, -0.77], [ -7/16, -0.75], [ 5/16, 0], [ 7/16, 0], [ 7/16, -0.75], [ 1/ 2, -0.77], ]; - higbee2 = !higbee && !higbee2 ? higbee2 - : let (higval = first_defined([higbee2,higbee])) - is_num(higval) ? higval + 270 - : 270; generic_threaded_nut( nutwidth=nutwidth, id=id, h=h, pitch=pitch, @@ -843,7 +1017,11 @@ module buttress_threaded_nut( left_handed=left_handed,starts=starts, bevel=bevel,bevel1=bevel1,bevel2=bevel2,bevang=bevang, ibevel=ibevel,ibevel1=ibevel1,ibevel2=ibevel2, - higbee=higbee, higbee1=higbee1, higbee2=higbee2, + blunt_start=blunt_start, blunt_start1=blunt_start1, blunt_start2=blunt_start2, + lead_in=lead_in, lead_in1=lead_in1, lead_in2=lead_in2, lead_in_shape=lead_in_shape, + lead_in_ang=lead_in_ang, lead_in_ang1=lead_in_ang1, lead_in_ang2=lead_in_ang2, + end_len=end_len, end_len1=end_len1, end_len2=end_len2, + l=l,length=length, anchor=anchor, spin=spin, height=height, thickness=thickness, orient=orient ) children(); @@ -861,7 +1039,7 @@ module buttress_threaded_nut( // They produce no radial load on the nut. However, square threads cannot carry as much load as trapezoidal threads. // Arguments: // d = Outer diameter of threaded rod. -// l / length = length of threaded rod. +// l / length / h / height = Length of threaded rod. // pitch = Thread spacing. // --- // left_handed = if true, create left-handed threads. Default = false @@ -870,9 +1048,20 @@ module buttress_threaded_nut( // bevel1 = if true bevel the bottom end. // bevel2 = if true bevel the top end. // internal = If true, this is a mask for making internal threads. -// higbee = If true apply higbee thread truncation at both ends, or set to an angle to adjust higbee cut point. Default: false -// higbee1 = If true apply higbee thread truncation at bottom end, or set to an angle to adjust higbee cut point. -// higbee2 = If true apply higbee thread truncation at top end, or set to an angle to adjust higbee cut point. + +// blunt_start = If true apply truncated blunt start threads at both ends. Default: true +// blunt_start1 = If true apply truncated blunt start threads bottom end. +// blunt_start2 = If true apply truncated blunt start threads top end. +// end_len = Specify the unthreaded length at the end after blunt start threads. Default: 0 +// end_len1 = Specify unthreaded length at the bottom +// end_len2 = Specify unthreaded length at the top +// lead_in = Specify linear length of the lead in section of the threading with blunt start threads +// lead_in1 = Specify linear length of the lead in section of the threading at the bottom with blunt start threads +// lead_in2 = Specify linear length of the lead in section of the threading at the top with blunt start threads +// lead_in_ang = Specify angular length in degrees of the lead in section of the threading with blunt start threads +// lead_in_ang1 = Specify angular length in degrees of the lead in section of the threading at the bottom with blunt start threads +// lead_in_ang2 = Specify angular length in degrees of the lead in section of the threading at the top with blunt start threads +// lead_in_shape = Specify the shape of the thread lead in by giving a text string or function. Default: "default" // d1 = Bottom outside diameter of threads. // d2 = Top outside diameter of threads. // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` @@ -890,8 +1079,12 @@ function square_threaded_rod( bevel,bevel1,bevel2, starts=1, internal=false, - higbee, higbee1, higbee2, - d1,d2, + d1, d2, length, h, height, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", anchor, spin, orient ) = no_function("square_threaded_rod"); module square_threaded_rod( @@ -900,8 +1093,12 @@ module square_threaded_rod( bevel,bevel1,bevel2, starts=1, internal=false, - higbee, higbee1, higbee2, - d1,d2,length, + d1, d2, length, h, height, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", anchor, spin, orient ) { trapezoidal_threaded_rod( @@ -910,13 +1107,13 @@ module square_threaded_rod( left_handed=left_handed, bevel=bevel,bevel1=bevel1,bevel2=bevel2, starts=starts, - internal=internal, - higbee=higbee, - higbee1=higbee1, - higbee2=higbee2, + internal=internal, length=length, height=height, h=h, + blunt_start=blunt_start, blunt_start1=blunt_start1, blunt_start2=blunt_start2, + lead_in=lead_in, lead_in1=lead_in1, lead_in2=lead_in2, lead_in_shape=lead_in_shape, + lead_in_ang=lead_in_ang, lead_in_ang1=lead_in_ang1, lead_in_ang2=lead_in_ang2, + end_len=end_len, end_len1=end_len1, end_len2=end_len2, d1=d1, d2=d2, - length=length, anchor=anchor, spin=spin, orient=orient @@ -933,7 +1130,7 @@ module square_threaded_rod( // Arguments: // nutwidth = diameter of the nut. // id = diameter of threaded rod to screw onto. -// h / height / thickness = height/thickness of nut. +// h / height / l / length / thickness = height/thickness of nut. // pitch = Length between threads. // --- // shape = specifies shape of nut, either "hex" or "square". Default: "hex" @@ -946,9 +1143,19 @@ module square_threaded_rod( // ibevel = if true, bevel the inside (the hole). Default: true // ibevel1 = if true bevel the inside, bottom end. // ibevel2 = if true bevel the inside, top end. -// higbee = If true apply higbee thread truncation at both ends, or set to an angle to adjust higbee cut point. Default: false -// higbee1 = If true apply higbee thread truncation at bottom end, or set to an angle to adjust higbee cut point. -// higbee2 = If true apply higbee thread truncation at top end, or set to an angle to adjust higbee cut point. +// blunt_start = If true apply truncated blunt start threads at both ends. Default: true +// blunt_start1 = If true apply truncated blunt start threads bottom end. +// blunt_start2 = If true apply truncated blunt start threads top end. +// end_len = Specify the unthreaded length at the end after blunt start threads. Default: 0 +// end_len1 = Specify unthreaded length at the bottom +// end_len2 = Specify unthreaded length at the top +// lead_in = Specify linear length of the lead in section of the threading with blunt start threads +// lead_in1 = Specify linear length of the lead in section of the threading at the bottom with blunt start threads +// lead_in2 = Specify linear length of the lead in section of the threading at the top with blunt start threads +// lead_in_ang = Specify angular length in degrees of the lead in section of the threading with blunt start threads +// lead_in_ang1 = Specify angular length in degrees of the lead in section of the threading at the bottom with blunt start threads +// lead_in_ang2 = Specify angular length in degrees of the lead in section of the threading at the top with blunt start threads +// lead_in_shape = Specify the shape of the thread lead in by giving a text string or function. Default: "default" // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` @@ -962,8 +1169,13 @@ function square_threaded_nut( bevel,bevel1,bevel2,bevang=30, ibevel,ibevel1,ibevel2, height,thickness, + length, l, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", starts=1, - higbee,higbee1,higbee2, anchor, spin, orient ) = no_function("square_threaded_nut"); module square_threaded_nut( @@ -973,7 +1185,12 @@ module square_threaded_nut( bevel,bevel1,bevel2,bevang=30, ibevel,ibevel1,ibevel2, height,thickness, - higbee,higbee1,higbee2, + length, l, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", starts=1, anchor, spin, orient ) { @@ -986,7 +1203,11 @@ module square_threaded_nut( ibevel=ibevel, ibevel1=ibevel1, ibevel2=ibevel2, height=height,thickness=thickness, starts=starts, - higbee=higbee, higbee1=higbee1, higbee2=higbee2, + blunt_start=blunt_start, blunt_start1=blunt_start1, blunt_start2=blunt_start2, + lead_in=lead_in, lead_in1=lead_in1, lead_in2=lead_in2, lead_in_shape=lead_in_shape, + lead_in_ang=lead_in_ang, lead_in_ang1=lead_in_ang1, lead_in_ang2=lead_in_ang2, + end_len=end_len, end_len1=end_len1, end_len2=end_len2, + l=l,length=length, anchor=anchor, spin=spin, orient=orient @@ -1003,7 +1224,7 @@ module square_threaded_nut( // Constructs a ball screw rod. This type of rod is used with ball bearings. // Arguments: // d = Outer diameter of threaded rod. -// l / length = length of threaded rod. +// l / length / h / height = Length of threaded rod. // pitch = Thread spacing. Also, the diameter of the ball bearings used. // ball_diam = The diameter of the ball bearings to use with this ball screw. // ball_arc = The arc portion that should touch the ball bearings. Default: 120 degrees. @@ -1014,27 +1235,46 @@ module square_threaded_nut( // bevel1 = if true bevel the bottom end. // bevel2 = if true bevel the top end. // internal = If true, make this a mask for making internal threads. +// blunt_start = If true apply truncated blunt start threads at both ends. Default: true +// blunt_start1 = If true apply truncated blunt start threads bottom end. +// blunt_start2 = If true apply truncated blunt start threads top end. +// end_len = Specify the unthreaded length at the end after blunt start threads. Default: 0 +// end_len1 = Specify unthreaded length at the bottom +// end_len2 = Specify unthreaded length at the top +// lead_in = Specify linear length of the lead in section of the threading with blunt start threads +// lead_in1 = Specify linear length of the lead in section of the threading at the bottom with blunt start threads +// lead_in2 = Specify linear length of the lead in section of the threading at the top with blunt start threads +// lead_in_ang = Specify angular length in degrees of the lead in section of the threading with blunt start threads +// lead_in_ang1 = Specify angular length in degrees of the lead in section of the threading at the bottom with blunt start threads +// lead_in_ang2 = Specify angular length in degrees of the lead in section of the threading at the top with blunt start threads +// lead_in_shape = Specify the shape of the thread lead in by giving a text string or function. Default: "default" // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` // $slop = The printer-specific slop value, which adds clearance (`4*$slop`) to internal threads. // Example(2D): Thread Profile, ball_diam=4, ball_arc=100 -// projection(cut=true) ball_screw_rod(d=10, l=15, pitch=5, ball_diam=4, ball_arc=100, orient=BACK, $fn=24); +// projection(cut=true) ball_screw_rod(d=10, l=15, pitch=5, ball_diam=4, ball_arc=100, orient=BACK, $fn=24, blunt_start=false); // Example(2D): Thread Profile, ball_diam=4, ball_arc=120 -// projection(cut=true) ball_screw_rod(d=10, l=15, pitch=5, ball_diam=4, ball_arc=120, orient=BACK, $fn=24); +// projection(cut=true) ball_screw_rod(d=10, l=15, pitch=5, ball_diam=4, ball_arc=120, orient=BACK, $fn=24, blunt_start=false); // Example(2D): Thread Profile, ball_diam=3, ball_arc=120 -// projection(cut=true) ball_screw_rod(d=10, l=15, pitch=5, ball_diam=3, ball_arc=120, orient=BACK, $fn=24); +// projection(cut=true) ball_screw_rod(d=10, l=15, pitch=5, ball_diam=3, ball_arc=120, orient=BACK, $fn=24, blunt_start=false); // Examples(Med): -// ball_screw_rod(d=15, l=20, pitch=8, ball_diam=5, ball_arc=120, $fa=1, $fs=0.5); -// ball_screw_rod(d=15, l=20, pitch=5, ball_diam=4, ball_arc=120, $fa=1, $fs=0.5); -// ball_screw_rod(d=15, l=20, pitch=5, ball_diam=4, ball_arc=120, left_handed=true, $fa=1, $fs=0.5); +// ball_screw_rod(d=15, l=20, pitch=8, ball_diam=5, ball_arc=120, $fa=1, $fs=0.5, blunt_start=false); +// ball_screw_rod(d=15, l=20, pitch=5, ball_diam=4, ball_arc=120, $fa=1, $fs=0.5, blunt_start=false); +// ball_screw_rod(d=15, l=20, pitch=5, ball_diam=4, ball_arc=120, left_handed=true, $fa=1, $fs=0.5, blunt_start=false); function ball_screw_rod( d, l, pitch, ball_diam=5, ball_arc=100, starts=1, left_handed=false, internal=false, - bevel,bevel1,bevel2, length, + length, h, height, + bevel, bevel1, bevel2, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", anchor, spin, orient ) = no_function("ball_screw_rod"); module ball_screw_rod( @@ -1043,7 +1283,13 @@ module ball_screw_rod( starts=1, left_handed=false, internal=false, - bevel,bevel1,bevel2, length, + length, h, height, + bevel, bevel1, bevel2, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", anchor, spin, orient ) { n = max(3,ceil(segs(ball_diam/2)*ball_arc/2/360)); @@ -1059,8 +1305,11 @@ module ball_screw_rod( left_handed=left_handed, starts=starts, bevel=bevel,bevel1=bevel1,bevel2=bevel2, - internal=internal, - higbee=false, length=length, + internal=internal, length=length, height=height, h=h, + blunt_start=blunt_start, blunt_start1=blunt_start1, blunt_start2=blunt_start2, + lead_in=lead_in, lead_in1=lead_in1, lead_in2=lead_in2, lead_in_shape=lead_in_shape, + lead_in_ang=lead_in_ang, lead_in_ang1=lead_in_ang1, lead_in_ang2=lead_in_ang2, + end_len=end_len, end_len1=end_len1, end_len2=end_len2, anchor=anchor, spin=spin, orient=orient @@ -1068,7 +1317,6 @@ module ball_screw_rod( } - // Section: Generic Threading // Module: generic_threaded_rod() @@ -1082,7 +1330,7 @@ module ball_screw_rod( // must be between -1/2 and 1/2. The Y=0 point will align with the specified rod diameter, so generally you want a Y value of zero at the peak (which // makes your specified diameter the outer diameter of the threads). // The value in the valleys of the thread should then be `-depth/pitch` due to the scaling by the thread pitch. The segment between the end -// of one thread and the start of the next is added automatically, so you should not have the path start and end at equivalent points (X = ±1/2 with the same Y value). +// of one thread and the start of the next is added automatically, so you should not have the path start and end at equivalent points (X = +-1/2 with the same Y value). // Generally you should center the profile horizontally in the interval [-1/2, 1/2]. // . // If internal is true then produce a thread mask to difference from an object. @@ -1100,21 +1348,31 @@ module ball_screw_rod( // giving more space at the end. Higbee works on both internal and external threads. // Arguments: // d = Outer diameter of threaded rod. -// l / length = Length of threaded rod. +// l / length / h / height = Length of threaded rod. // pitch = Thread spacing. // profile = A 2D path giving the shape of a thread // --- // left_handed = If true, create left-handed threads. Default: false // starts = The number of lead starts. Default: 1 -// bevel = if true, bevel the thread ends. Default: false -// bevel1 = if true bevel the bottom end. -// bevel2 = if true bevel the top end. // internal = If true, make this a mask for making internal threads. Default: false // d1 = Bottom outside diameter of threads. // d2 = Top outside diameter of threads. -// higbee = If true apply higbee thread truncation at both ends, or set to an angle to adjust higbee cut point. Default: false -// higbee1 = If true apply higbee thread truncation at bottom end, or set to an angle to adjust higbee cut point. -// higbee2 = If true apply higbee thread truncation at top end, or set to an angle to adjust higbee cut point. +// bevel = set to true to bevel both ends, a number to specify a bevel size, false for no bevel, and "reverse" for an inverted bevel +// bevel1 = set bevel for bottom end. +// bevel2 = set bevel for top end. +// blunt_start = If true apply truncated blunt start threads at both ends. Default: true +// blunt_start1 = If true apply truncated blunt start threads bottom end. +// blunt_start2 = If true apply truncated blunt start threads top end. +// end_len = Specify the unthreaded length at the end after blunt start threads. Default: 0 +// end_len1 = Specify unthreaded length at the bottom +// end_len2 = Specify unthreaded length at the top +// lead_in = Specify linear length of the lead in section of the threading with blunt start threads +// lead_in1 = Specify linear length of the lead in section of the threading at the bottom with blunt start threads +// lead_in2 = Specify linear length of the lead in section of the threading at the top with blunt start threads +// lead_in_ang = Specify angular length in degrees of the lead in section of the threading with blunt start threads +// lead_in_ang1 = Specify angular length in degrees of the lead in section of the threading at the bottom with blunt start threads +// lead_in_ang2 = Specify angular length in degrees of the lead in section of the threading at the top with blunt start threads +// lead_in_shape = Specify the shape of the thread lead in by giving a text string or function. Default: "default" // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` @@ -1143,185 +1401,243 @@ module ball_screw_rod( // [ 7/16, -depth/pitch*1.07] // ]; // generic_threaded_rod(d=10, l=40, pitch=2, profile=profile); + function generic_threaded_rod( d, l, pitch, profile, - left_handed=false, - bevel, - bevel1, bevel2, + left_handed=false, internal=false, + bevel, bevel1, bevel2, starts=1, - internal=false, - d1, d2, length, - higbee, higbee1, higbee2, + d1, d2, length, h, height, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", anchor, spin, orient ) = no_function("generic_threaded_rod"); module generic_threaded_rod( d, l, pitch, profile, - left_handed=false, - bevel, - bevel1, bevel2, + left_handed=false, internal=false, + bevel, bevel1, bevel2, starts=1, - internal=false, - d1, d2, length, - higbee, higbee1, higbee2, + d1, d2, length, h, height, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", anchor, spin, orient ) { - l = one_defined([l,length],"l,length"); - bevel1 = first_defined([bevel1,bevel,false]); - bevel2 = first_defined([bevel2,bevel,false]); - thigbee1 = first_defined([higbee1,higbee,false]); - thigbee2 = first_defined([higbee2,higbee,false]); - // Zero higbee should be treated as "true", default angle, but it tests as false so adjust - higbee1 = thigbee1==0 ? true : thigbee1; - higbee2 = thigbee2==0 ? true : thigbee2; - extra_thread1 = higbee1==false && internal ? 1 : 0; - extra_thread2 = higbee2==false && internal ? 1 : 0; + len = one_defined([l,length,h,height],"l,length,h,height"); + bevel1 = first_defined([bevel1,bevel]); + bevel2 = first_defined([bevel2,bevel]); + blunt_start1 = first_defined([blunt_start1, blunt_start, true]); + blunt_start2 = first_defined([blunt_start2, blunt_start, true]); r1 = get_radius(d1=d1, d=d); r2 = get_radius(d1=d2, d=d); + lead_in1 = first_defined([lead_in1, lead_in]); + lead_in2 = first_defined([lead_in2, lead_in]); + lead_in_func = is_func(lead_in_shape) ? lead_in_shape + : assert(is_string(lead_in_shape),"lead_in_shape must be a function or string") + let(ind = search([lead_in_shape], _lead_in_table,0)[0]) + assert(ind!=[],str("Unknown lead_in_shape, \"",lead_in_shape,"\"")) + _lead_in_table[ind[0]][1]; dummy0 = assert(all_positive([pitch]),"Thread pitch must be a positive value") - assert(all_positive([l]),"Length must be a postive value") + assert(all_positive([len]),"Length must be a postive value") assert(is_path(profile),"Profile must be a path") - assert(is_finite(higbee1) || is_bool(higbee1), str("higbee",is_undef(higbee)?"1":""," must be boolean or a number")) - assert(is_finite(higbee2) || is_bool(higbee2), str("higbee",is_undef(higbee)?"1":""," must be boolean or a number")) + assert(is_bool(blunt_start1), "blunt_start1/blunt_start must be boolean") + assert(is_bool(blunt_start2), "blunt_start2/blunt_start must be boolean") assert(is_bool(left_handed)) - assert(all_positive([r1,r2]), "Must give d or both d1 and d2 as positive values"); + assert(all_positive([r1,r2]), "Must give d or both d1 and d2 as positive values") + assert(is_undef(bevel1) || is_num(bevel1) || is_bool(bevel1) || bevel1=="reverse", "bevel1/bevel must be a number, boolean or \"reverse\"") + assert(is_undef(bevel2) || is_num(bevel2) || is_bool(bevel2) || bevel2=="reverse", "bevel2/bevel must be a number, boolean or \"reverse\""); sides = quantup(segs(max(r1,r2)), starts); - rsc = internal? (1/cos(180/sides)) : 1; + rsc = internal? (1/cos(180/sides)) : 1; // Internal radius adjusted for faceting islop = internal? 2*get_slop() : 0; - _r1 = r1 * rsc + islop; - _r2 = r2 * rsc + islop; - threads = extra_thread1+extra_thread2+quantup(l/pitch+2,1); // Was quantup(1/pitch+2,2*starts); - dir = left_handed? -1 : 1; - twist = 360 * l / pitch / starts; - profile = !internal ? profile - : [ - for(entry=profile) if (entry.x>=0) [entry.x-1/2,entry.y], - for(entry=profile) if (entry.x<0) [entry.x+1/2,entry.y] + r1adj = r1 * rsc + islop; + r2adj = r2 * rsc + islop; + + extreme = internal? max(column(profile,1)) : min(column(profile,1)); + profile = !internal ? profile + : let( + maxidx = [for(i=idx(profile)) if (profile[i].y==extreme) i], + cutpt = len(maxidx)==1 ? profile(maxidx[0]).x + : mean([profile[maxidx[0]].x, profile[maxidx[1]].x]) + ) + [ + for(entry=profile) if (entry.x>=cutpt) [entry.x-cutpt-1/2,entry.y], + for(entry=profile) if (entry.xdepth && _r2>depth, "Screw profile deeper than rod radius"); - map_threads = right((_r1 + _r2) / 2) // Shift profile out to thread radius - * affine3d_skew(sxz=(_r2-_r1)/l) // Skew correction for tapered threads + rmax = max(r1adj,r2adj)+pmax; + + // These parameters give the size of the bevel, negative for an outward bevel (e.g. on internal thread mask) + bev1 = (bevel1=="reverse"?-1:1)*(internal?-1:1) * + ( is_num(bevel1)? bevel1 + : bevel1==false? 0 + : blunt_start1? (bevel1==undef?0 + :internal ? r1/6 + :(r1+profmin)/6) + : pmax-profmin); + bev2 = (bevel2=="reverse"?-1:1)*(internal?-1:1) * + ( is_num(bevel2)? bevel2 + : bevel2==false? 0 + : blunt_start2? (bevel2==undef?0 + :internal ? r2/6 + :(r2+profmin)/6) + : pmax-profmin); + // This is the bevel size used for constructing the polyhedron. The bevel is integrated when blunt start is on, but + // applied later via difference/union if blunt start is off, so set bevel to zero in the latter case. + bevel_size1 = blunt_start1?bev1:0; + bevel_size2 = blunt_start2?bev2:0; + // This is the bevel size for clipping, which is only done when blunt start is off + clip_bev1 = blunt_start1?0:bev1; + clip_bev2 = blunt_start2?0:bev2; + end_len1_base = !blunt_start1? 0 : first_defined([end_len1,end_len, 0]); + end_len2_base = !blunt_start2? 0 : first_defined([end_len2,end_len, 0]); + // Enlarge end lengths to give sufficient room for requested bevel + end_len1 = abs(bevel_size1)>0 ? max(end_len1_base, abs(bevel_size1)) : end_len1_base; + end_len2 = abs(bevel_size2)>0 ? max(end_len2_base, abs(bevel_size2)) : end_len2_base; + // length to create below/above z=0, with an extra revolution in non-blunt-start case so + // the threads can continue to the specified length and we can clip off the blunt start + len1 = -len/2 - (blunt_start1?0:pitch); + len2 = len/2 + (blunt_start2?0:pitch); + + // Thread turns below and above z=0, with extra to ensure we go beyond the length needed + turns1 = len1/pitch-1; + turns2 = len2/pitch+1; + dir = left_handed? -1 : 1; + dummy2= + assert(abs(bevel_size1)+abs(bevel_size2)0, "bevel1 is too large to fit screw diameter") + assert(r2adj+extreme*pitch-bevel_size2>0, "bevel2 is too large to fit screw diameter"); + + margin1 = profile[0].y==extreme ? profile[0].x : -1/2; + margin2 = last(profile).y==extreme? last(profile).x : 1/2; + lead_in_default = pmax-profmin;//2*pitch; + // 0*360/10;// /4/32*360; higlen_default;//0*4/32*360; //2/32*360;//360*max(pitch/2, pmax-depth)/(2*PI*r2adj); + // lead_in length needs to be quantized to match the samples + lead_in_ang1 = !blunt_start1? 0 : + let( + user_ang = first_defined([lead_in_ang1,lead_in_ang]) + ) + assert(is_undef(user_ang) || is_undef(lead_in1), "Cannot define lead_in/lead_in1 by both length and angle") + quantup( + is_def(user_ang) ? user_ang : default(lead_in1, lead_in_default)*360/(2*PI*r1adj) + , 360/sides); + lead_in_ang2 = !blunt_start2? 0 : + let( + user_ang = first_defined([lead_in_ang2,lead_in_ang]) + ) + assert(is_undef(user_ang) || is_undef(lead_in2), "Cannot define lead_in/lead_in2 by both length and angle") + quantup( + is_def(user_ang) ? user_ang : default(lead_in2, lead_in_default)*360/(2*PI*r2adj) + , 360/sides); + // cut_ang also need to be quantized, but the comparison is offset by 36*turns1/starts, so we need to pull that factor out + // of the quantization. (The loop over angle starts at 360*turns1/starts, not at a multiple of 360/sides.) +// cut_ang1 = 360 * (len1/pitch-margin1+end_len1/pitch) / starts + lead_in_ang1; +// cut_ang2 = 360 * (len2/pitch-margin2-end_len2/pitch) / starts - lead_in_ang2; + cut_ang1 = quantup(360 * (len1/pitch-margin1+end_len1/pitch) / starts + lead_in_ang1-360*turns1/starts,360/sides)+360*turns1/starts; + cut_ang2 = quantdn(360 * (len2/pitch-margin2-end_len2/pitch) / starts - lead_in_ang2-360*turns1/starts,360/sides)+360*turns1/starts; + dummy1 = + assert(cut_ang10 && r2adj+profmin>0, "Screw profile deeper than rod radius"); + map_threads = right((r1adj + r2adj) / 2) // Shift profile out to thread radius + * affine3d_skew(sxz=(r2adj-r1adj)/len) // Skew correction for tapered threads * frame_map(x=[0,0,1], y=[1,0,0]) // Map profile to 3d, parallel to z axis * scale(pitch); // scale profile by pitch start_steps = sides / starts; - higlen = 2/32*360;//360*max(pitch/2, pmax-depth)/(2*PI*_r2); - echo(higlen=higlen); + + // This is the location for clipping the polyhedron, below the bevel, if one is present, or at length otherwise + // Clipping is done before scaling to pitch, so we need to divide by the pitch + rod_clip1 = (len1+abs(bevel_size1))/pitch; + rod_clip2 = (len2-abs(bevel_size2))/pitch; + prof3d=path3d(profile,1); thread_verts = [ // Outer loop constructs a vertical column of the screw at each angle - // covering 1/starts * 360 degrees of the cylinder. + // covering 360/starts degrees of the cylinder. for (step = [0:1:start_steps]) let( ang = 360 * step/sides, dz = step / start_steps, // z offset for threads at this angle rot_prof = zrot(ang*dir)*map_threads, // Rotate profile to correct angular location full_profile = [ // profile for the entire rod - for (thread = [-threads/2:1:threads/2-1]) + for (turns = [turns1:1:turns2]) let( - tang = thread/starts * 360 + ang, - hsc = tang < -twist/2+higang1 ? _taperfunc(1-(-twist/2+higang1-tang)/higlen,PI*2*_r1*higlen/360 ) - : tang > twist/2-higang2 ? _taperfunc(1-(tang-twist/2+higang2)/higlen,PI*2*_r2*higlen/360 ) + tang = turns/starts * 360 + ang, + // EPSILON offset prevents funny looking extensions of the thread from its very tip + // by forcing values near the tip to evaluate as less than zero = beyond the tip end + hsc = tang < cut_ang1 ? lead_in_func(-EPSILON+1-(cut_ang1-tang)/lead_in_ang1,PI*2*r1adj*lead_in_ang1/360 ) + : tang > cut_ang2 ? lead_in_func(-EPSILON+1-(tang-cut_ang2)/lead_in_ang2,PI*2*r2adj*lead_in_ang2/360 ) : [1,1], - higscale=scale([hsc.x, hsc.y,1], cp=[0,internal ? pmax/pitch:-pdepth, 0]) -// higscale=scale([lerp(hsc,1,0.25),hsc,1], cp=[0,internal ? pmax/pitch:-pdepth, 0]) -// higscale=scale([lerp(hsc,1,0.25),1,1], cp=[0,internal ? pmax/pitch:-pdepth, 0]) -// higscale=scale([1,hsc,1], cp=[0,internal ? pmax/pitch:-pdepth, 0]) + shift_and_scale = [[hsc.x, 0], [0,hsc.y], [dz+turns,(1-hsc.y)*extreme]] ) + // This is equivalent to apply(right(dz+turns)*higscale, profile) + // // The right movement finds the position of the thread along - // what will be the z axis after the profile is mapped to 3d - each apply(right(dz + thread) * higscale, prof3d) - ] + // what will be the z axis after the profile is mapped to 3d, + // and higscale creates a taper and the end of the threads. + each prof3d*shift_and_scale + ], + // Clip profile at the ends of the rod and add a z coordinate + full_profile_clipped = [ + for(pts=full_profile) [max(rod_clip1,min(rod_clip2,pts.x)), pts.y, 0] + ] ) [ - [0, 0, -l/2-pitch-1-extra_thread1*pitch], - each apply(rot_prof , full_profile), - [0, 0, +l/2+pitch+1+extra_thread2*pitch] + [0,0,len1], + //if (true) apply(rot_prof, [len1/pitch,extreme+2/pitch ,0]), + if (bevel_size1) apply(rot_prof, [len1/pitch,extreme-bevel_size1/pitch ,0]), + each apply(rot_prof, full_profile_clipped), + if (bevel_size2) apply(rot_prof, [len2/pitch,extreme-bevel_size2/pitch ,0]), + //if (true) apply(rot_prof, [len2/pitch,extreme+2/pitch ,0]), + [0, 0, len2] ] ]; style=internal?"concave":"convex"; - - thread_vnfs = vnf_join( - [ - // Main thread faces - for (i=[0:1:starts-1]) - zrot(i*360/starts, p=vnf_vertex_array(thread_verts, reverse=left_handed, style=style)), - // Top closing face(s) of thread - for (i=[0:1:starts-1]) - let( - rmat = zrot(i*360/starts), - pts = deduplicate(list_head(thread_verts[0], len(prof3d)+1)), - faces = [for (i=idx(pts,e=-2)) left_handed ? [0, i, i+1] : [0, i+1, i]] - ) - [apply(rmat,pts), faces], - // Bottom closing face(s) of thread - for (i=[0:1:starts-1]) - let( - rmat = zrot(i*360/starts), - pts = deduplicate(list_tail(last(thread_verts), -len(prof3d)-2)), - faces = [for (i=idx(pts,e=-2)) left_handed ? [len(pts)-1, i+1, i] : [len(pts)-1, i, i+1]] - ) - [apply(rmat,pts), faces] - ] - ); - - slope = (_r1-_r2)/l; - maxlen = 5*pitch; - attachable(anchor,spin,orient, r1=_r1, r2=_r2, l=l) { + thread_vnf = vnf_join([ + for (i=[0:1:starts-1]) + zrot(i*360/starts, p=vnf_vertex_array(thread_verts, reverse=left_handed, style=style,col_wrap=false)), + ]); + slope = (r1adj-r2adj)/len; + dummy3 = + assert(r1adj+pmax-clip_bev1>0, "bevel1 is too large to fit screw diameter") + assert(r2adj+pmax-clip_bev2>0, "bevel2 is too large to fit screw diameter") + assert(abs(clip_bev1)+abs(clip_bev2)0) + rotate_extrude() + polygon([[ 0,-len/2], + [r1adj+pmax-clip_bev1 ,-len/2], + [r1adj+pmax-slope*clip_bev1,-len/2+clip_bev1], + [ rmax+1,-len/2+clip_bev1], + [ rmax+1, len1-1], + [ 0, len1-1]]); + if (clip_bev2>0) + rotate_extrude() + polygon([[ 0, len/2], + [r2adj+pmax-clip_bev2 , len/2], + [r2adj+pmax+slope*clip_bev2, len/2-clip_bev2], + [ rmax+1, len/2-clip_bev2], + [ rmax+1, len2+1], + [ 0, len2+1]]); + if (!blunt_start1 && clip_bev1<=0) + down(len/2) cuboid([2*rmax+1,2*rmax+1, -len1+1], anchor=TOP); + if (!blunt_start2 && clip_bev2<=0) + up(len/2) cuboid([2*rmax+1,2*rmax+1, len2+1], anchor=BOTTOM); } - /* // slower, simpler approach for beveling - intersection(){ - //vnf_validate(vnf_quantize(thread_vnfs), size=0.1); - vnf_polyhedron(vnf_quantize(thread_vnfs), convexity=10); - cyl(l=l, r1=_r1+pmax, r2=_r2+pmax, chamfer1=bevel1?depth:undef, chamfer2=bevel2?depth:undef); - } - */ - // Add bevel for internal thread mask - if (internal) { - if (bevel1) - down(l/2+.001)cyl(l=depth, r1=_r1+pmax, r2=_r1+pmax-slope*depth-depth,anchor=BOTTOM); - if (bevel2) - up(l/2+.001)cyl(l=depth, r2=_r2+pmax, r1=_r2+pmax+slope*depth-depth,anchor=TOP); - } + if (clip_bev1<0) + down(len/2+.001)cyl(l=-clip_bev1, r2=r1adj+profmin, r1=r1adj+profmin+slope*clip_bev1-clip_bev1,anchor=BOTTOM); + if (clip_bev2<0) + up(len/2+.001)cyl(l=-clip_bev2, r1=r2adj+profmin, r2=r2adj+profmin+slope*clip_bev1-clip_bev2,anchor=TOP); } children(); } @@ -1345,6 +1661,8 @@ module generic_threaded_rod( // shape = specifies shape of nut, either "hex" or "square". Default: "hex" // left_handed = if true, create left-handed threads. Default = false // starts = The number of lead starts. Default = 1 +// id1 = inner diameter at the bottom +// id2 = inner diameter at the top // bevel = if true, bevel the outside of the nut. Default: true for hex nuts, false for square nuts // bevel1 = if true, bevel the outside of the nut bottom. // bevel2 = if true, bevel the outside of the nut top. @@ -1352,11 +1670,19 @@ module generic_threaded_rod( // ibevel = if true, bevel the inside (the hole). Default: true // ibevel1 = if true bevel the inside, bottom end. // ibevel2 = if true bevel the inside, top end. -// higbee = If true apply higbee thread truncation at both ends, or set to an angle to adjust higbee cut point. Default: false -// higbee1 = If true apply higbee thread truncation at bottom end, or set to an angle to adjust higbee cut point. -// higbee2 = If true apply higbee thread truncation at top end, or set to an angle to adjust higbee cut point. -// id1 = inner diameter at the bottom -// id2 = inner diameter at the top +// blunt_start = If true apply truncated blunt start threads at both ends. Default: true +// blunt_start1 = If true apply truncated blunt start threads bottom end. +// blunt_start2 = If true apply truncated blunt start threads top end. +// end_len = Specify the unthreaded length at the end after blunt start threads. Default: 0 +// end_len1 = Specify unthreaded length at the bottom +// end_len2 = Specify unthreaded length at the top +// lead_in = Specify linear length of the lead in section of the threading with blunt start threads +// lead_in1 = Specify linear length of the lead in section of the threading at the bottom with blunt start threads +// lead_in2 = Specify linear length of the lead in section of the threading at the top with blunt start threads +// lead_in_ang = Specify angular length in degrees of the lead in section of the threading with blunt start threads +// lead_in_ang1 = Specify angular length in degrees of the lead in section of the threading at the bottom with blunt start threads +// lead_in_ang2 = Specify angular length in degrees of the lead in section of the threading at the top with blunt start threads +// lead_in_shape = Specify the shape of the thread lead in by giving a text string or function. Default: "default" // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` @@ -1373,7 +1699,12 @@ function generic_threaded_nut( bevel,bevel1,bevel2,bevang=30, ibevel, ibevel1, ibevel2, id1,id2, height, thickness, - higbee,higbee1,higbee2, + length, l, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", anchor, spin, orient ) = no_function("generic_threaded_nut"); module generic_threaded_nut( @@ -1388,14 +1719,19 @@ module generic_threaded_nut( bevel,bevel1,bevel2,bevang=30, ibevel, ibevel1, ibevel2, id1,id2, height, thickness, - higbee,higbee1,higbee2, + length, l, + blunt_start, blunt_start1, blunt_start2, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + end_len, end_len1, end_len2, + lead_in_shape="default", anchor, spin, orient ) { extra = 0.01; id1 = first_defined([id1,id]); id2 = first_defined([id2,id]); - h = one_defined([h,height,thickness],"h,height,thickness"); + h = one_defined([h,height,thickness,l,length],"h,height,thickness,l,length"); dummyA = assert(is_num(pitch) && pitch>=0, "pitch must be a nonnegative number") assert(is_num(h) && h>0, "height/thickness must be a positive number") assert(in_list(shape,["square","hex"]), "shape must be \"hex\" or \"square\"") @@ -1414,7 +1750,9 @@ module generic_threaded_nut( difference() { _nutshape(nutwidth,h, shape,bevel1,bevel2); if (pitch==0) - cyl(l=h+extra, d1=full_id1+4*get_slop(), d2=full_id2+4*get_slop(), chamfer1=ibevel1?-IBEV*full_id1:undef, chamfer2=ibevel2?-IBEV*full_id2:undef); + cyl(l=h+extra, d1=full_id1+4*get_slop(), d2=full_id2+4*get_slop(), + chamfer1=ibevel1?-IBEV*full_id1:undef, + chamfer2=ibevel2?-IBEV*full_id2:undef); else generic_threaded_rod( d1=full_id1,d2=full_id2, @@ -1425,7 +1763,10 @@ module generic_threaded_nut( starts=starts, internal=true, bevel1=ibevel1,bevel2=ibevel2, - higbee=higbee, higbee1=higbee1, higbee2=higbee2 + blunt_start=blunt_start, blunt_start1=blunt_start1, blunt_start2=blunt_start2, + lead_in=lead_in, lead_in1=lead_in1, lead_in2=lead_in2, lead_in_shape=lead_in_shape, + lead_in_ang=lead_in_ang, lead_in_ang1=lead_in_ang1, lead_in_ang2=lead_in_ang2, + end_len=end_len, end_len1=end_len1, end_len2=end_len2 ); } children(); @@ -1535,9 +1876,9 @@ module _nutshape(nutwidth, h, shape, bevel1, bevel2) // } // Examples: // thread_helix(d=10, pitch=2, thread_depth=0.75, flank_angle=15, turns=2.5, $fn=72); -// thread_helix(d=10, pitch=2, thread_depth=0.75, flank_angle=15, turns=2.5, taper=1, $fn=72); -// thread_helix(d=10, pitch=2, thread_depth=0.75, flank_angle=15, turns=2, taper=2, internal=true, $fn=72); -// thread_helix(d=10, pitch=2, thread_depth=0.75, flank_angle=15, turns=1, left_handed=true, taper=1, $fn=36); +// thread_helix(d=10, pitch=2, thread_depth=0.75, flank_angle=15, turns=2.5, lead_in=1, $fn=72); +// thread_helix(d=10, pitch=2, thread_depth=0.75, flank_angle=15, turns=2, lead_in=2, internal=true, $fn=72); +// thread_helix(d=10, pitch=2, thread_depth=0.75, flank_angle=15, turns=1, left_handed=true, lead_in=1, $fn=36); function thread_helix( d, pitch, thread_depth, flank_angle, turns, profile, starts=1, left_handed=false, internal=false, @@ -1545,13 +1886,19 @@ function thread_helix( anchor, spin, orient ) = no_function("thread_helix"); module thread_helix( - d, pitch, thread_depth, flank_angle, turns=2, + d, pitch, thread_depth, flank_angle, turns, profile, starts=1, left_handed=false, internal=false, - d1, d2, taper, taper1, taper2, + d1, d2, + lead_in_shape, + lead_in, lead_in1, lead_in2, + lead_in_ang, lead_in_ang1, lead_in_ang2, + lead_in_sample=10, anchor, spin, orient ) { dummy1=assert(is_undef(profile) || !any_defined([thread_depth, flank_angle]),"Cannot give thread_depth or flank_angle with a profile") - assert(all_positive([turns]), "The turns parameter must be a positive number"); + assert(all_positive([turns]), "The turns parameter must be a positive number") + assert(is_def(profile) || is_def(thread_depth), "If profile is not given, must give thread depth"); + flank_angle = default(flank_angle,15); h = pitch*starts*abs(turns); r1 = get_radius(d1=d1, d=d, dflt=10); r2 = get_radius(d1=d2, d=d, dflt=10); @@ -1578,8 +1925,13 @@ module thread_helix( pline = mirror([-1,1], p = profile * pitch); dir = left_handed? -1 : 1; attachable(anchor,spin,orient, r1=r1, r2=r2, l=h) { - zrot_copies(n=starts) { - spiral_sweep(pline, h=h, r1=r1, r2=r2, turns=turns*dir, taper=taper, taper1=taper1, taper2=taper2, internal=internal, anchor=CENTER); + union(){ + zrot_copies(n=starts) + spiral_sweep(pline, h=h, r1=r1, r2=r2, turns=turns*dir, internal=internal, + lead_in_shape=lead_in_shape, + lead_in=lead_in, lead_in1=lead_in1, lead_in2=lead_in2, + lead_in_ang=lead_in_ang, lead_in_ang1=lead_in_ang1, lead_in_ang2=lead_in_ang2, + lead_in_sample=lead_in_sample,anchor=CENTER); } children(); } @@ -1594,3 +1946,8 @@ module thread_helix( // // Need explanation of what exactly the diff is between threaded_rod and helix_threads. // Higbee is different, angle in one and length in another. Need to reconcile + +// end_len = 0 default? +// What about blunt_start for ball screws? +// Fold in nuts +// Should default bevel be capped at 1mm or 2mm or something like that? Including/especially inner bevel on nuts From bb2d67725cd425cecee5b56d1b880dcb9ba858ba Mon Sep 17 00:00:00 2001 From: Adrian Mariano Date: Tue, 4 Apr 2023 20:12:19 -0400 Subject: [PATCH 5/8] synopsis tweaks --- lists.scad | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lists.scad b/lists.scad index ed32a0d..c83ca85 100644 --- a/lists.scad +++ b/lists.scad @@ -54,7 +54,7 @@ function _same_type(a,b, depth) = // Function: min_length() -// Synopsis: Returns the length of the shortest list. +// Synopsis: Given a list of sublists, returns the length of the shortest sublist. // Topics: List Handling // See Also: max_length() // Usage: @@ -71,7 +71,7 @@ function min_length(list) = // Function: max_length() -// Synopsis: Returns the length of the longest list. +// Synopsis: Given a list of sublists, returns the length of the longest sublist. // Topics: List Handling // See Also: min_length() // Usage: @@ -233,7 +233,7 @@ function select(list, start, end) = // Function: slice() -// Synopsis: Returns part of a list, not including the last index. +// Synopsis: Returns part of a list without wrapping. // Topics: List Handling // See Also: select(), column(), last() // Usage: @@ -286,7 +286,7 @@ function last(list) = // Function: list_head() -// Synopsis: Returns the head of the given list. +// Synopsis: Returns the elements at the beginning of a list. // Topics: List Handling // See Also: select(), slice(), list_tail(), last() // Usage: @@ -315,7 +315,7 @@ function list_head(list, to=-2) = // Function: list_tail() -// Synopsis: Returns the tail of the given list. +// Synopsis: Returns the elements at the end of a list. // Topics: List Handling // See Also: select(), slice(), list_tail(), last() // Usage: @@ -346,7 +346,7 @@ function list_tail(list, from=1) = // Function: bselect() -// Synopsis: Cherry-picks specific items from a list. +// Synopsis: Select list items using boolean index list. // Topics: List Handling // See Also: list_bset() // Usage: @@ -369,7 +369,7 @@ function bselect(list,index) = // Function: repeat() -// Synopsis: Returns a list of N copies of a value. +// Synopsis: Returns a list of repeated copies of a value. // Topics: List Handling // See Also: count(), lerpn() // Usage: @@ -395,7 +395,7 @@ function repeat(val, n, i=0) = // Function: list_bset() -// Synopsis: Returns a list where specific values are set from a list of values. +// Synopsis: Returns a list where values are spread to locations indicated by a boolean index list. // Topics: List Handling // See Also: bselect() // Usage: @@ -473,7 +473,7 @@ function force_list(value, n=1, fill) = // Section: List Modification // Function: reverse() -// Synopsis: Reverses the ordering of a list. +// Synopsis: Reverses the elements of a list. // Topics: List Handling // See Also: select(), list_rotate() // Usage: @@ -529,7 +529,7 @@ function list_rotate(list,n=1) = // Function: shuffle() -// Synopsis: Randomizes the ordering of a list. +// Synopsis: Randomizes the order of a list. // Topics: List Handling // See Also: sort(), sortidx(), unique(), unique_count() // Usage: @@ -563,7 +563,7 @@ function shuffle(list,seed) = // Function: repeat_entries() -// Synopsis: Repeats items in a list to expand it to a given length. +// Synopsis: Repeats list entries (as uniformly as possible) to make list of specified length. // Topics: List Handling // See Also: repeat() // Usage: @@ -605,7 +605,7 @@ function repeat_entries(list, N, exact=true) = // Function: list_pad() -// Synopsis: Adds items to the end of a list until it is a given length. +// Synopsis: Extend list to specified length. // Topics: List Handling // See Also: force_list(), scalar_vec3() // Usage: @@ -717,7 +717,7 @@ function list_insert(list, indices, values) = // Function: list_remove() -// Synopsis: Removes items from the middle of a list. +// Synopsis: Removes items by index from a list. // Topics: List Handling // See Also: list_set(), list_insert(), list_remove_values() // Usage: @@ -760,7 +760,7 @@ function list_remove(list, ind) = // Function: list_remove_values() -// Synopsis: Removes specific values from a list. +// Synopsis: Removes items by value from a list. // Topics: List Handling // See Also: list_set(), list_insert(), list_remove() // Usage: @@ -861,7 +861,7 @@ function idx(list, s=0, e=-1, step=1) = // Function: pair() -// Synopsis: Returns a list of consecutive pairs in a list. +// Synopsis: Returns a list of overlapping consecutive pairs in a list. // Topics: List Handling, Iteration // See Also: idx(), triplet(), combinations(), permutations() // Usage: @@ -895,7 +895,7 @@ function pair(list, wrap=false) = // Function: triplet() -// Synopsis: Returns a list of consecutive triplets in a list. +// Synopsis: Returns a list of overlapping consecutive triplets in a list. // Topics: List Handling, Iteration // See Also: idx(), pair(), combinations(), permutations() // Usage: @@ -935,7 +935,7 @@ function triplet(list, wrap=false) = // Function: combinations() -// Synopsis: Returns a list of all item combinations in a list. +// Synopsis: Returns a list of all combinations of the list entries. // Topics: List Handling, Iteration // See Also: idx(), pair(), triplet(), permutations() // Usage: @@ -962,7 +962,7 @@ function combinations(l,n=2,_s=0) = // Function: permutations() -// Synopsis: Returns a list of all item permutations in a list. +// Synopsis: Returns a list of all permutations of the list entries. // Topics: List Handling, Iteration // See Also: idx(), pair(), triplet(), combinations() // Usage: From 295d4e3c580bf37f5cb2dfee09b3304fe97a2146 Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Tue, 4 Apr 2023 17:25:13 -0700 Subject: [PATCH 6/8] Synopses, etc for gears.scad --- gears.scad | 74 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 27 deletions(-) diff --git a/gears.scad b/gears.scad index c7bff6b..7eab166 100644 --- a/gears.scad +++ b/gears.scad @@ -26,14 +26,15 @@ // Section: Gears // Function&Module: spur_gear() +// Synopsis: Creates a spur gear shape. +// Topics: Gears, Parts +// See Also: rack(), spur_gear(), spur_gear2d(), bevel_gear() // Usage: As a Module // spur_gear(pitch, teeth, thickness, [shaft_diam], [hide=], [pressure_angle=], [clearance=], [backlash=], [helical=], [slices=], [interior=]) [ATTACHMENTS]; // spur_gear(mod=, teeth=, thickness=, [shaft_diam=], ...) [ATTACHMENTS]; // Usage: As a Function // vnf = spur_gear(pitch, teeth, thickness, [shaft_diam], ...); // vnf = spur_gear(mod=, teeth=, thickness=, [shaft_diam], ...); -// Topics: Gears -// See Also: rack() // Description: // Creates a (potentially helical) involute spur gear. The module `spur_gear()` gives an involute // spur gear, with reasonable defaults for all the parameters. Normally, you should just choose the @@ -191,14 +192,15 @@ module spur_gear( // Function&Module: spur_gear2d() +// Synopsis: Creates a 2D spur gear shape. +// Topics: Gears, Parts +// See Also: rack(), spur_gear(), spur_gear2d(), bevel_gear() // Usage: As Module // spur_gear2d(pitch, teeth, [hide=], [pressure_angle=], [clearance=], [backlash=], [interior=]) [ATTACHMENTS]; // spur_gear2d(mod=, teeth=, [hide=], [pressure_angle=], [clearance=], [backlash=], [interior=]) [ATTACHMENTS]; // Usage: As Function // poly = spur_gear2d(pitch, teeth, [hide=], [pressure_angle=], [clearance=], [backlash=], [interior=]); // poly = spur_gear2d(mod=, teeth=, [hide=], [pressure_angle=], [clearance=], [backlash=], [interior=]); -// Topics: Gears -// See Also: spur_gear() // Description: // When called as a module, creates a 2D involute spur gear. When called as a function, returns a // 2D path for the perimeter of a 2D involute spur gear. Normally, you should just specify the @@ -291,14 +293,15 @@ module spur_gear2d( // Function&Module: rack() +// Synopsis: Creates a gear rack shape. +// Topics: Gears, Parts +// See Also: rack2d(), spur_gear(), spur_gear2d(), bevel_gear() // Usage: As a Module // rack(pitch, teeth, thickness, height, [pressure_angle=], [backlash=]) [ATTACHMENTS]; // rack(mod=, teeth=, thickness=, height=, [pressure_angle=], [backlash]=) [ATTACHMENTS]; // Usage: As a Function // vnf = rack(pitch, teeth, thickness, height, [pressure_angle=], [backlash=]); // vnf = rack(mod=, teeth=, thickness=, height=, [pressure_angle=], [backlash=]); -// Topics: Gears -// See Also: spur_gear() // Description: // This is used to create a 3D rack, which is a linear bar with teeth that a gear can roll along. // A rack can mesh with any gear that has the same `pitch` and `pressure_angle`. @@ -439,14 +442,15 @@ function rack( // Function&Module: rack2d() +// Synopsis: Creates a 2D gear rack shape. +// Topics: Gears, Parts +// See Also: rack(), spur_gear(), spur_gear2d(), bevel_gear() // Usage: As a Module // path = rack2d(pitch, teeth, height, [pressure_angle=], [backlash=]) [ATTACHMENTS]; // path = rack2d(mod=, teeth=, height=, [pressure_angle=], [backlash=]) [ATTACHMENTS]; // Usage: As a Function // path = rack2d(pitch, teeth, height, [pressure_angle=], [backlash=]); // path = rack2d(mod=, teeth=, height=, [pressure_angle=], [backlash=]); -// Topics: Gears -// See Also: spur_gear2d() // Description: // This is used to create a 2D rack, which is a linear bar with teeth that a gear can roll along. // A rack can mesh with any gear that has the same `pitch` and `pressure_angle`. @@ -561,12 +565,13 @@ module rack2d( // Function&Module: bevel_gear() +// Synopsis: Creates a possibly spiral beveled gear shape. +// Topics: Gears, Parts +// See Also: rack(), rack2d(), spur_gear(), spur_gear2d(), bevel_pitch_angle(), bevel_gear() // Usage: As a Module // bevel_gear(pitch|mod, teeth, face_width, pitch_angle, [shaft_diam], [hide], [pressure_angle], [clearance], [backlash], [cutter_radius], [spiral_angle], [slices], [interior]); // Usage: As a Function // vnf = bevel_gear(pitch|mod, teeth, face_width, pitch_angle, [hide], [pressure_angle], [clearance], [backlash], [cutter_radius], [spiral_angle], [slices], [interior]); -// Topics: Gears -// See Also: bevel_pitch_angle() // Description: // Creates a (potentially spiral) bevel gear. The module `bevel_gear()` gives a bevel gear, with // reasonable defaults for all the parameters. Normally, you should just choose the first 4 @@ -817,12 +822,13 @@ module bevel_gear( // Function&Module: worm() +// Synopsis: Creates a worm shape that will mate with a worm gear. +// Topics: Gears, Parts +// See Also: worm(), worm_gear(), rack(), rack2d(), spur_gear(), spur_gear2d(), bevel_pitch_angle(), bevel_gear() // Usage: As a Module // worm(pitch|mod, d, l, [starts], [left_handed], [pressure_angle], [backlash], [clearance]); // Usage: As a Function // vnf = worm(pitch|mod, d, l, [starts], [left_handed], [pressure_angle], [backlash], [clearance]); -// Topics: Gears -// See Also: worm_gear() // Description: // Creates a worm shape that can be matched to a worm gear. // Arguments: @@ -934,12 +940,13 @@ module worm( // Function&Module: worm_gear() +// Synopsis: Creates a worm gear shape that will mate with a worm. +// Topics: Gears, Parts +// See Also: worm(), worm_gear(), rack(), rack2d(), spur_gear(), spur_gear2d(), bevel_pitch_angle(), bevel_gear() // Usage: As a Module // worm_gear(pitch|mod, teeth, worm_diam, [worm_starts], [crowning], [left_handed], [pressure_angle], [backlash], [slices], [clearance], [shaft_diam]); // Usage: As a Function // vnf = worm_gear(pitch|mod, teeth, worm_diam, [worm_starts], [crowning], [left_handed], [pressure_angle], [backlash], [slices], [clearance]); -// Topics: Gears -// See Also: worm() // Description: // Creates a worm gear to match with a worm. // Arguments: @@ -1227,9 +1234,11 @@ module _gear_tooth_profile( // Function: circular_pitch() +// Synopsis: Returns tooth density expressed as "circular pitch". +// Topics: Gears, Parts +// See Also: spur_gear(), diametral_pitch(), circular_pitch(), pitch_value() // Usage: // circp = circular_pitch(pitch|mod); -// Topics: Gears // Description: // Get tooth density expressed as "circular pitch". // Arguments: @@ -1244,9 +1253,11 @@ function circular_pitch(pitch=5, mod) = // Function: diametral_pitch() +// Synopsis: Returns tooth density expressed as "diametral pitch". +// Topics: Gears, Parts +// See Also: spur_gear(), diametral_pitch(), circular_pitch(), pitch_value() // Usage: // dp = diametral_pitch(pitch|mod); -// Topics: Gears // Description: // Get tooth density expressed as "diametral pitch". // Arguments: @@ -1261,9 +1272,11 @@ function diametral_pitch(pitch=5, mod) = // Function: pitch_value() +// Synopsis: Returns circular pitch in mm from module/modulus. +// Topics: Gears, Parts +// See Also: spur_gear(), diametral_pitch(), circular_pitch(), pitch_value(), module_value() // Usage: // pitch = pitch_value(mod); -// Topics: Gears // Description: // Get circular pitch in mm from module/modulus. The circular pitch of a gear is the number of // millimeters per tooth around the pitch radius circle. @@ -1273,9 +1286,11 @@ function pitch_value(mod) = mod * PI; // Function: module_value() +// Synopsis: Returns tooth density expressed as "module" or "modulus" in millimeters. +// Topics: Gears, Parts +// See Also: spur_gear(), diametral_pitch(), circular_pitch(), pitch_value(), module_value() // Usage: // mod = module_value(pitch); -// Topics: Gears // Description: // Get tooth density expressed as "module" or "modulus" in millimeters. The module is the pitch // diameter of the gear divided by the number of teeth on it. For example, a gear with a pitch @@ -1340,9 +1355,11 @@ function _dedendum(pitch=5, clearance, mod) = // Function: pitch_radius() +// Synopsis: Returns the pitch radius for a gear. +// Topics: Gears, Parts +// See Also: spur_gear(), diametral_pitch(), circular_pitch(), pitch_value(), module_value(), outer_radius() // Usage: // pr = pitch_radius(pitch|mod, teeth); -// Topics: Gears // Description: // Calculates the pitch radius for the gear. Two mated gears will have their centers spaced apart // by the sum of the two gear's pitch radii. @@ -1364,9 +1381,11 @@ function pitch_radius(pitch=5, teeth=11, mod) = // Function: outer_radius() +// Synopsis: Returns the outer radius for a gear. +// Topics: Gears, Parts +// See Also: spur_gear(), diametral_pitch(), circular_pitch(), pitch_value(), module_value(), pitch_radius(), outer_radius() // Usage: // or = outer_radius(pitch|mod, teeth, [clearance], [interior]); -// Topics: Gears // Description: // Calculates the outer radius for the gear. The gear fits entirely within a cylinder of this radius. // Arguments: @@ -1440,12 +1459,13 @@ function _base_radius(pitch=5, teeth=11, pressure_angle=28, mod) = // Function: bevel_pitch_angle() +// Synopsis: Returns the pitch cone angle for a bevel gear. +// Topics: Gears, Parts +// See Also: bevel_gear(), pitch_radius(), outer_radius() // Usage: // ang = bevel_pitch_angle(teeth, mate_teeth, [drive_angle]); -// Topics: Gears -// See Also: bevel_gear() // Description: -// Returns the correct pitch angle for a bevel gear with a given number of tooth, that is +// Returns the correct pitch cone angle for a bevel gear with a given number of teeth, that is // matched to another bevel gear with a (possibly different) number of teeth. // Arguments: // teeth = Number of teeth that this gear has. @@ -1471,10 +1491,11 @@ function bevel_pitch_angle(teeth, mate_teeth, drive_angle=90) = // Function: worm_gear_thickness() +// Synopsis: Returns the thickness for a worm gear. +// Topics: Gears, Parts +// See Also: worm(), worm_gear(), pitch_radius(), outer_radius() // Usage: // thick = worm_gear_thickness(pitch|mod, teeth, worm_diam, [worm_arc], [crowning], [clearance]); -// Topics: Gears -// See Also: worm(), worm_gear() // Description: // Calculate the thickness of the worm gear. // Arguments: @@ -1482,7 +1503,7 @@ function bevel_pitch_angle(teeth, mate_teeth, drive_angle=90) = // teeth = Total number of teeth along the rack. Default: 30 // worm_diam = The pitch diameter of the worm gear to match to. Default: 30 // worm_arc = The arc of the worm to mate with, in degrees. Default: 60 degrees -// crowning = The amount to oversize the virtual hobbing cutter used to make the teeth, to add a slight crowning to the teeth to make them fir the work easier. Default: 1 +// crowning = The amount to oversize the virtual hobbing cutter used to make the teeth, to add a slight crowning to the teeth to make them fit the work easier. Default: 1 // clearance = Clearance gap at the bottom of the inter-tooth valleys. // mod = The metric module/modulus of the gear. // Example: @@ -1521,5 +1542,4 @@ function _gear_q7(f,r,b,r2,t,s) = _gear_q6(b,s,t,(1-f)*max(b,r)+f*r2); // - // vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap From a1a178ea05be81b8e306a36596e4edd5dbd5422d Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Tue, 4 Apr 2023 20:29:21 -0700 Subject: [PATCH 7/8] Reviewed gears.scad and cubetruss.scad for Usage --- cubetruss.scad | 22 +++++++++---------- gears.scad | 58 ++++++++++++++++++++++++++++++-------------------- 2 files changed, 46 insertions(+), 34 deletions(-) diff --git a/cubetruss.scad b/cubetruss.scad index 7f01417..e0e16b9 100644 --- a/cubetruss.scad +++ b/cubetruss.scad @@ -21,15 +21,15 @@ $cubetruss_clip_thickness = 1.6; // Topics: Trusses, CubeTruss, FDM Optimized, Parts // See Also: cubetruss_segment(), cubetruss_support(), cubetruss(), cubetruss_corner() // Usage: -// cubetruss(extents, [clips], [bracing], [size], [strut], [clipthick]); +// cubetruss(extents, [clips=], [bracing=], [size=], [strut=], [clipthick=], ...) [ATTACHMENTS]; // Description: // Creates a cubetruss truss, assembled out of one or more cubical segments. // Arguments: // extents = The number of cubes in length to make the truss. If given as a [X,Y,Z] vector, specifies the number of cubes in each dimension. // clips = List of vectors pointing towards the sides to add clips to. +// bracing = If true, adds internal cross-braces. Default: `$cubetruss_bracing` (usually true) // size = The length of each side of the cubetruss cubes. Default: `$cubetruss_size` (usually 30) // strut = The width of the struts on the cubetruss cubes. Default: `$cubetruss_strut_size` (usually 3) -// bracing = If true, adds internal cross-braces. Default: `$cubetruss_bracing` (usually true) // clipthick = The thickness of the clips. Default: `$cubetruss_clip_thickness` (usually 1.6) // --- // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` @@ -94,15 +94,15 @@ module cubetruss(extents=6, clips=[], bracing, size, strut, clipthick, anchor=CE // Topics: Trusses, CubeTruss, FDM Optimized, Parts // See Also: cubetruss_segment(), cubetruss_support(), cubetruss(), cubetruss_corner() // Usage: -// cubetruss_corner(h, extents, [bracing], [size], [strut], [clipthick]); +// cubetruss_corner(h, extents, [bracing=], [size=], [strut=], [clipthick=]); // Description: // Creates a corner cubetruss with extents jutting out in one or more directions. // Arguments: // h = The number of cubes high to make the base and horizontal extents. // extents = The number of cubes to extend beyond the corner. If given as a vector of cube counts, gives the number of cubes to extend right, back, left, front, and up in order. If the vector is shorter than length 5 the extra cube counts are taken to be zero. +// bracing = If true, adds internal cross-braces. Default: `$cubetruss_bracing` (usually true) // size = The length of each side of the cubetruss cubes. Default: `$cubetruss_size` (usually 30) // strut = The width of the struts on the cubetruss cubes. Default: `$cubetruss_strut_size` (usually 3) -// bracing = If true, adds internal cross-braces. Default: `$cubetruss_bracing` (usually true) // clipthick = The thickness of the clips. Default: `$cubetruss_clip_thickness` (usually 1.6) // --- // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` @@ -170,7 +170,7 @@ module cubetruss_corner(h=1, extents=[1,1,0,0,1], bracing, size, strut, clipthic // Topics: Trusses, CubeTruss, FDM Optimized, Parts // See Also: cubetruss_segment(), cubetruss_support(), cubetruss(), cubetruss_corner() // Usage: -// cubetruss_support([size], [strut], [extents], [anchor], [spin], [orient]) [ATTACHMENTS]; +// cubetruss_support([size=], [strut=], [extents=]) [ATTACHMENTS]; // Description: // Creates a single cubetruss support. // Arguments: @@ -237,7 +237,7 @@ module cubetruss_support(size, strut, extents=1, anchor=CENTER, spin=0, orient=U // Topics: Trusses, CubeTruss, FDM Optimized, Parts // See Also: cubetruss_segment(), cubetruss_support(), cubetruss(), cubetruss_corner() // Usage: -// cubetruss_foot(w, [size], [strut], [clipthick], [$slop=], [anchor=], [spin=], [orient=]) [ATTACHMENTS]; +// cubetruss_foot(w, [size=], [strut=], [clipthick=]) [ATTACHMENTS]; // Description: // Creates a foot that can be clipped onto the bottom of a truss for support. // Arguments: @@ -317,7 +317,7 @@ module cubetruss_foot(w=1, size, strut, clipthick, anchor=CENTER, spin=0, orient // Topics: Trusses, CubeTruss, FDM Optimized, Parts // See Also: cubetruss_segment(), cubetruss_support(), cubetruss(), cubetruss_corner() // Usage: -// cubetruss_joiner([w], [vert], [size], [strut], [clipthick], [$slop=], [anchor=], [spin=], [orient=]) [ATTACHMENTS]; +// cubetruss_joiner([w=], [vert=], [size=], [strut=], [clipthick=]) [ATTACHMENTS]; // Description: // Creates a part to join two cubetruss trusses end-to-end. // Arguments: @@ -388,7 +388,7 @@ module cubetruss_joiner(w=1, vert=true, size, strut, clipthick, anchor=CENTER, s // Topics: Trusses, CubeTruss, FDM Optimized, Parts // See Also: cubetruss_segment(), cubetruss_support(), cubetruss(), cubetruss_corner() // Usage: -// cubetruss_uclip(dual, [size], [strut], [clipthick], [$slop=], [anchor=], [spin=], [orient=]) [ATTACHMENTS]; +// cubetruss_uclip(dual, [size=], [strut=], [clipthick=]) [ATTACHMENTS]; // Description: // Creates a small clip that can snap around one or two adjacent struts. // Arguments: @@ -440,7 +440,7 @@ module cubetruss_uclip(dual=true, size, strut, clipthick, anchor=CENTER, spin=0, // Topics: Trusses, CubeTruss, FDM Optimized, Parts // See Also: cubetruss_segment(), cubetruss_support(), cubetruss(), cubetruss_corner() // Usage: -// cubetruss_segment([size], [strut], [bracing]); +// cubetruss_segment([size=], [strut=], [bracing=]); // Description: // Creates a single cubetruss cube segment. // Arguments: @@ -512,7 +512,7 @@ module cubetruss_segment(size, strut, bracing, anchor=CENTER, spin=0, orient=UP) // Topics: Trusses, CubeTruss, FDM Optimized, Parts // See Also: cubetruss_segment(), cubetruss_support(), cubetruss(), cubetruss_corner() // Usage: -// cubetruss_clip(extents, [size], [strut], [clipthick], [$slop=], [anchor=], [spin=], [orient=]) [ATTACHMENTS]; +// cubetruss_clip(extents, [size=], [strut=], [clipthick=]) [ATTACHMENTS]; // Description: // Creates a pair of clips to add onto the end of a truss. // Arguments: @@ -580,7 +580,7 @@ module cubetruss_clip(extents=1, size, strut, clipthick, anchor=CENTER, spin=0, // Topics: Trusses, CubeTruss, FDM Optimized, Parts // See Also: cubetruss_segment(), cubetruss_support(), cubetruss(), cubetruss_corner() // Usage: -// cubetruss_dist(cubes, gaps, [size], [strut]); +// length = cubetruss_dist(cubes, [gaps], [size=], [strut=]); // Description: // Function to calculate the length of a cubetruss truss. // Arguments: diff --git a/gears.scad b/gears.scad index 7eab166..6461cd6 100644 --- a/gears.scad +++ b/gears.scad @@ -33,8 +33,8 @@ // spur_gear(pitch, teeth, thickness, [shaft_diam], [hide=], [pressure_angle=], [clearance=], [backlash=], [helical=], [slices=], [interior=]) [ATTACHMENTS]; // spur_gear(mod=, teeth=, thickness=, [shaft_diam=], ...) [ATTACHMENTS]; // Usage: As a Function -// vnf = spur_gear(pitch, teeth, thickness, [shaft_diam], ...); -// vnf = spur_gear(mod=, teeth=, thickness=, [shaft_diam], ...); +// vnf = spur_gear(pitch, teeth, thickness, [shaft_diam=], ...); +// vnf = spur_gear(mod=, teeth=, thickness=, [shaft_diam=], ...); // Description: // Creates a (potentially helical) involute spur gear. The module `spur_gear()` gives an involute // spur gear, with reasonable defaults for all the parameters. Normally, you should just choose the @@ -297,11 +297,11 @@ module spur_gear2d( // Topics: Gears, Parts // See Also: rack2d(), spur_gear(), spur_gear2d(), bevel_gear() // Usage: As a Module -// rack(pitch, teeth, thickness, height, [pressure_angle=], [backlash=]) [ATTACHMENTS]; -// rack(mod=, teeth=, thickness=, height=, [pressure_angle=], [backlash]=) [ATTACHMENTS]; +// rack(pitch, teeth, thickness, height, [pressure_angle=], [backlash=], [clearance=], [helical=]) [ATTACHMENTS]; +// rack(mod=, teeth=, thickness=, height=, [pressure_angle=], [backlash]=, [clearance=], [helical=]) [ATTACHMENTS]; // Usage: As a Function -// vnf = rack(pitch, teeth, thickness, height, [pressure_angle=], [backlash=]); -// vnf = rack(mod=, teeth=, thickness=, height=, [pressure_angle=], [backlash=]); +// vnf = rack(pitch, teeth, thickness, height, [pressure_angle=], [backlash=], [clearance=], [helical=]); +// vnf = rack(mod=, teeth=, thickness=, height=, [pressure_angle=], [backlash=], [clearance=], [helical=]); // Description: // This is used to create a 3D rack, which is a linear bar with teeth that a gear can roll along. // A rack can mesh with any gear that has the same `pitch` and `pressure_angle`. @@ -446,11 +446,11 @@ function rack( // Topics: Gears, Parts // See Also: rack(), spur_gear(), spur_gear2d(), bevel_gear() // Usage: As a Module -// path = rack2d(pitch, teeth, height, [pressure_angle=], [backlash=]) [ATTACHMENTS]; -// path = rack2d(mod=, teeth=, height=, [pressure_angle=], [backlash=]) [ATTACHMENTS]; +// rack2d(pitch, teeth, height, [pressure_angle=], [backlash=], [clearance=]) [ATTACHMENTS]; +// rack2d(mod=, teeth=, height=, [pressure_angle=], [backlash=], [clearance=]) [ATTACHMENTS]; // Usage: As a Function -// path = rack2d(pitch, teeth, height, [pressure_angle=], [backlash=]); -// path = rack2d(mod=, teeth=, height=, [pressure_angle=], [backlash=]); +// path = rack2d(pitch, teeth, height, [pressure_angle=], [backlash=], [clearance=]); +// path = rack2d(mod=, teeth=, height=, [pressure_angle=], [backlash=], [clearance=]); // Description: // This is used to create a 2D rack, which is a linear bar with teeth that a gear can roll along. // A rack can mesh with any gear that has the same `pitch` and `pressure_angle`. @@ -569,9 +569,11 @@ module rack2d( // Topics: Gears, Parts // See Also: rack(), rack2d(), spur_gear(), spur_gear2d(), bevel_pitch_angle(), bevel_gear() // Usage: As a Module -// bevel_gear(pitch|mod, teeth, face_width, pitch_angle, [shaft_diam], [hide], [pressure_angle], [clearance], [backlash], [cutter_radius], [spiral_angle], [slices], [interior]); +// bevel_gear(pitch, teeth, face_width, [pitch_angle=]|[mate_teeth=], [shaft_diam=], [hide=], [pressure_angle=], [clearance=], [backlash=], [cutter_radius=], [spiral_angle=], [left_handed=], [slices=], [interior=]); +// bevel_gear(mod=, teeth=, face_width=, [pitch_angle=]|[mate_teeth=], [shaft_diam=], [hide=], [pressure_angle=], [clearance=], [backlash=], [cutter_radius=], [spiral_angle=], [left_handed=], [slices=], [interior=]); // Usage: As a Function -// vnf = bevel_gear(pitch|mod, teeth, face_width, pitch_angle, [hide], [pressure_angle], [clearance], [backlash], [cutter_radius], [spiral_angle], [slices], [interior]); +// vnf = bevel_gear(pitch, teeth, face_width, [pitch_angle=]|[mate_teeth=], [hide=], [pressure_angle=], [clearance=], [backlash=], [cutter_radius=], [spiral_angle=], [left_handed=], [slices=], [interior=]); +// vnf = bevel_gear(mod=, teeth=, face_width=, [pitch_angle=]|[mate_teeth=], [hide=], [pressure_angle=], [clearance=], [backlash=], [cutter_radius=], [spiral_angle=], [left_handed=], [slices=], [interior=]); // Description: // Creates a (potentially spiral) bevel gear. The module `bevel_gear()` gives a bevel gear, with // reasonable defaults for all the parameters. Normally, you should just choose the first 4 @@ -599,6 +601,7 @@ module rack2d( // face_width = Width of the toothed surface in mm, from inside to outside. Default: 10 // pitch_angle = Angle of beveled gear face. Default: 45 // mate_teeth = The number of teeth in the gear that this gear will mate with. Overrides `pitch_angle` if given. +// --- // shaft_diam = Diameter of the hole in the center, in mm. Module use only. Default: 0 (no shaft hole) // hide = Number of teeth to delete to make this only a fraction of a circle. Default: 0 // pressure_angle = Controls how straight or bulged the tooth sides are. In degrees. Default: 28 @@ -826,9 +829,11 @@ module bevel_gear( // Topics: Gears, Parts // See Also: worm(), worm_gear(), rack(), rack2d(), spur_gear(), spur_gear2d(), bevel_pitch_angle(), bevel_gear() // Usage: As a Module -// worm(pitch|mod, d, l, [starts], [left_handed], [pressure_angle], [backlash], [clearance]); +// worm(pitch, d, l, [starts=], [left_handed=], [pressure_angle=], [backlash=], [clearance=]); +// worm(mod=, d=, l=, [starts=], [left_handed=], [pressure_angle=], [backlash=], [clearance=]); // Usage: As a Function -// vnf = worm(pitch|mod, d, l, [starts], [left_handed], [pressure_angle], [backlash], [clearance]); +// vnf = worm(pitch, d, l, [starts=], [left_handed=], [pressure_angle=], [backlash=], [clearance=]); +// vnf = worm(mod=, d=, l=, [starts=], [left_handed=], [pressure_angle=], [backlash=], [clearance=]); // Description: // Creates a worm shape that can be matched to a worm gear. // Arguments: @@ -944,9 +949,11 @@ module worm( // Topics: Gears, Parts // See Also: worm(), worm_gear(), rack(), rack2d(), spur_gear(), spur_gear2d(), bevel_pitch_angle(), bevel_gear() // Usage: As a Module -// worm_gear(pitch|mod, teeth, worm_diam, [worm_starts], [crowning], [left_handed], [pressure_angle], [backlash], [slices], [clearance], [shaft_diam]); +// worm_gear(pitch, teeth, worm_diam, [worm_starts=], [worm_arc=], [crowning=], [left_handed=], [pressure_angle=], [backlash=], [clearance=], [slices=], [shaft_diam=]) [ATTACHMENTS]; +// worm_gear(mod=, teeth=, worm_diam=, [worm_starts=], [worm_arc=], [crowning=], [left_handed=], [pressure_angle=], [backlash=], [clearance=], [slices=], [shaft_diam=]) [ATTACHMENTS]; // Usage: As a Function -// vnf = worm_gear(pitch|mod, teeth, worm_diam, [worm_starts], [crowning], [left_handed], [pressure_angle], [backlash], [slices], [clearance]); +// vnf = worm_gear(pitch, teeth, worm_diam, [worm_starts=], [worm_arc=], [crowning=], [left_handed=], [pressure_angle=], [backlash=], [clearance=], [slices=]); +// vnf = worm_gear(mod=, teeth=, worm_diam=, [worm_starts=], [worm_arc=], [crowning=], [left_handed=], [pressure_angle=], [backlash=], [clearance=], [slices=]); // Description: // Creates a worm gear to match with a worm. // Arguments: @@ -1007,8 +1014,8 @@ function worm_gear( pressure_angle = 20, backlash = 0, clearance, - mod, slices = 10, + mod, anchor = CENTER, spin = 0, orient = UP @@ -1238,7 +1245,8 @@ module _gear_tooth_profile( // Topics: Gears, Parts // See Also: spur_gear(), diametral_pitch(), circular_pitch(), pitch_value() // Usage: -// circp = circular_pitch(pitch|mod); +// circp = circular_pitch(pitch); +// circp = circular_pitch(mod=); // Description: // Get tooth density expressed as "circular pitch". // Arguments: @@ -1257,7 +1265,8 @@ function circular_pitch(pitch=5, mod) = // Topics: Gears, Parts // See Also: spur_gear(), diametral_pitch(), circular_pitch(), pitch_value() // Usage: -// dp = diametral_pitch(pitch|mod); +// dp = diametral_pitch(pitch); +// dp = diametral_pitch(mod=); // Description: // Get tooth density expressed as "diametral pitch". // Arguments: @@ -1359,7 +1368,8 @@ function _dedendum(pitch=5, clearance, mod) = // Topics: Gears, Parts // See Also: spur_gear(), diametral_pitch(), circular_pitch(), pitch_value(), module_value(), outer_radius() // Usage: -// pr = pitch_radius(pitch|mod, teeth); +// pr = pitch_radius(pitch, teeth); +// pr = pitch_radius(mod=, teeth=); // Description: // Calculates the pitch radius for the gear. Two mated gears will have their centers spaced apart // by the sum of the two gear's pitch radii. @@ -1385,7 +1395,8 @@ function pitch_radius(pitch=5, teeth=11, mod) = // Topics: Gears, Parts // See Also: spur_gear(), diametral_pitch(), circular_pitch(), pitch_value(), module_value(), pitch_radius(), outer_radius() // Usage: -// or = outer_radius(pitch|mod, teeth, [clearance], [interior]); +// or = outer_radius(pitch, teeth, [clearance=], [interior=]); +// or = outer_radius(mod=, teeth=, [clearance=], [interior=]); // Description: // Calculates the outer radius for the gear. The gear fits entirely within a cylinder of this radius. // Arguments: @@ -1463,7 +1474,7 @@ function _base_radius(pitch=5, teeth=11, pressure_angle=28, mod) = // Topics: Gears, Parts // See Also: bevel_gear(), pitch_radius(), outer_radius() // Usage: -// ang = bevel_pitch_angle(teeth, mate_teeth, [drive_angle]); +// ang = bevel_pitch_angle(teeth, mate_teeth, [drive_angle=]); // Description: // Returns the correct pitch cone angle for a bevel gear with a given number of teeth, that is // matched to another bevel gear with a (possibly different) number of teeth. @@ -1495,7 +1506,8 @@ function bevel_pitch_angle(teeth, mate_teeth, drive_angle=90) = // Topics: Gears, Parts // See Also: worm(), worm_gear(), pitch_radius(), outer_radius() // Usage: -// thick = worm_gear_thickness(pitch|mod, teeth, worm_diam, [worm_arc], [crowning], [clearance]); +// thick = worm_gear_thickness(pitch, teeth, worm_diam, [worm_arc=], [crowning=], [clearance=]); +// thick = worm_gear_thickness(mod=, teeth=, worm_diam=, [worm_arc=], [crowning=], [clearance=]); // Description: // Calculate the thickness of the worm gear. // Arguments: From c9b475efbc2b93283eedd3da7a5d6019628eee1c Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Tue, 4 Apr 2023 21:00:31 -0700 Subject: [PATCH 8/8] Review linear_bearings.scad and sliders.scad for Usage line syntax. --- linear_bearings.scad | 14 ++++++++++++++ sliders.scad | 12 ++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/linear_bearings.scad b/linear_bearings.scad index 7a3fd72..0ea9a72 100644 --- a/linear_bearings.scad +++ b/linear_bearings.scad @@ -18,6 +18,8 @@ include // Synopsis: Creates a generic linear bearing mount clamp. // Topics: Parts, Bearings // See Also: linear_bearing(), lmXuu_info(), ball_bearing() +// Usage: +// linear_bearing_housing(d, l, tab, gap, wall, tabwall, screwsize) [ATTACHMENTS]; // Description: // Creates a model of a clamp to hold a generic linear bearing cartridge. // Arguments: @@ -28,6 +30,7 @@ include // wall = Wall thickness of clamp housing. (Default: 3) // gap = Gap in clamp. (Default: 5) // screwsize = Size of screw to use to tighten clamp. (Default: 3) +// --- // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` @@ -81,12 +84,15 @@ module linear_bearing_housing(d=15, l=24, tab=7, gap=5, wall=3, tabwall=5, screw // Synopsis: Creates a generic linear bearing cartridge. // Topics: Parts, Bearings // See Also: linear_bearing_housing(), lmXuu_info(), ball_bearing() +// Usage: +// linear_bearing(l, od, id, length) [ATTACHMENTS]; // Description: // Creates a rough model of a generic linear ball bearing cartridge. // Arguments: // l/length = The length of the linear bearing cartridge. // od = The outer diameter of the linear bearing cartridge. // id = The inner diameter of the linear bearing cartridge. +// --- // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` @@ -112,6 +118,8 @@ module linear_bearing(l, od=15, id=8, length, anchor=CTR, spin=0, orient=UP) { // Synopsis: Creates a standardized LM*UU linear bearing mount clamp. // Topics: Parts, Bearings // See Also: linear_bearing(), linear_bearing_housing(), lmXuu_info(), lmXuu_bearing(), lmXuu_housing(), ball_bearing() +// Usage: +// lmXuu_housing(size, tab, gap, wall, tabwall, screwsize) [ATTACHMENTS]; // Description: // Creates a model of a clamp to hold a standard sized lmXuu linear bearing cartridge. // Arguments: @@ -121,6 +129,7 @@ module linear_bearing(l, od=15, id=8, length, anchor=CTR, spin=0, orient=UP) { // wall = Wall thickness of clamp housing. Default: 3 // gap = Gap in clamp. Default: 5 // screwsize = Size of screw to use to tighten clamp. Default: 3 +// --- // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` @@ -139,10 +148,13 @@ module lmXuu_housing(size=8, tab=7, gap=5, wall=3, tabwall=5, screwsize=3, ancho // Synopsis: Creates a standardized LM*UU linear bearing cartridge. // Topics: Parts, Bearings // See Also: linear_bearing(), linear_bearing_housing(), lmXuu_info(), lmXuu_bearing(), lmXuu_housing(), ball_bearing() +// Usage: +// lmXuu_bearing(size) [ATTACHMENTS]; // Description: // Creates a model of an lmXuu linear ball bearing cartridge. // Arguments: // size = Standard lmXuu inner size. +// --- // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` @@ -161,6 +173,8 @@ module lmXuu_bearing(size=8, anchor=CTR, spin=0, orient=UP) { // Synopsis: Returns the sizes of a standard LM*UU linear bearing cartridge. // Topics: Parts, Bearings // See Also: linear_bearing(), linear_bearing_housing(), lmXuu_info(), lmXuu_bearing(), lmXuu_housing(), ball_bearing() +// Usage: +// diam_len = lmXuu_info(size); // Description: // Get dimensional info for a standard metric lmXuu linear bearing cartridge. // Returns `[DIAM, LENGTH]` for the cylindrical cartridge. diff --git a/sliders.scad b/sliders.scad index 323d913..a9ec7bd 100644 --- a/sliders.scad +++ b/sliders.scad @@ -16,10 +16,10 @@ // Synopsis: Creates a V-groove slider. // Topics: Parts, Sliders // See Also: rail() -// Description: -// Creates a slider to match a V-groove rail. // Usage: // slider(l, w, h, [base=], [wall=], [ang=], [$slop=]) [ATTACHMENTS]; +// Description: +// Creates a slider to match a V-groove rail. // Arguments: // l = Length (long axis) of slider. // w = Width of slider. @@ -69,17 +69,17 @@ module slider(l=30, w=10, h=10, base=10, wall=5, ang=30, anchor=BOTTOM, spin=0, // Synopsis: Creates a V-groove rail. // Topics: Parts, Sliders // See Also: slider() -// Description: -// Creates a V-groove rail. // Usage: // rail(l, w, h, [chamfer=], [ang=]) [ATTACHMENTS]; +// Description: +// Creates a V-groove rail. // Arguments: // l = Length (long axis) of slider. // w = Width of slider. // h = Height of slider. -// --- // chamfer = Size of chamfer at end of rail. -// ang = Overhang angle for slider, to facilitate supportless printig. +// ang = Overhang angle for slider, to facilitate supportless printing. +// --- // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `BOTTOM` // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`