Merge branch 'revarbat:master' into master

This commit is contained in:
Richard Milewski 2023-04-13 12:42:48 -07:00 committed by GitHub
commit 542cc86a51
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 205 additions and 46 deletions

View file

@ -55,4 +55,9 @@ DefineHeader(Table;Headers=Anchor Name|Position): Extra Anchors
DefineHeader(Table;Headers=Anchor Type|What it is): Anchor Types
DefineHeader(Table;Headers=Name|Definition): Terminology
DefineHeader(BulletList): Requirements
DefineSynTags:
VNF = Returns a VNF when called as a function.
Path = Returns a Path when called as a function.
Region = Returns a Region when called as a function.
Geom = Returns Geometry when called as a module.

View file

@ -1573,7 +1573,7 @@ module screw_head(screw_info,details=false, counterbore=0,flat_height,teardrop=f
// nut("#8", thread="none");
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)
bevel,bevel1,bevel2,bevang=15,ibevel,ibevel1,ibevel2,blunt_start, blunt_start1, blunt_start2, 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,blunt_start, blunt_start1, blunt_start2, anchor=BOTTOM, spin=0, orient=UP, oversize=0)

View file

@ -18,7 +18,8 @@ use <builtins.scad>
// Section: Cuboids, Prismoids and Pyramids
// Function&Module: cube()
// Synopsis: Creates a cube with anchors for attaching children, or returns a vnf.
// Synopsis: Creates a cube with anchors for attaching children.
// SynTags: Geom, VNF
// Topics: Shapes (3D), Attachable, VNF Generators
// See Also: cuboid(), prismoid()
// Usage: As Module (as in native OpenSCAD)
@ -88,7 +89,8 @@ function cube(size=1, center, anchor, spin=0, orient=UP) =
// Module: cuboid()
// Synopsis: Creates a cube with chamfering and roundovers, or returns a vnf.
// Synopsis: Creates a cube with chamfering and roundovers.
// SynTags: Geom, VNF
// Topics: Shapes (3D), Attachable, VNF Generators
// See Also: prismoid(), rounded_prism()
// Usage: Standard Cubes
@ -566,7 +568,8 @@ function cuboid(
// Function&Module: prismoid()
// Synopsis: Creates a rectangular prismoid shape with optional roundovers and chamfering, or returns a vnf.
// Synopsis: Creates a rectangular prismoid shape with optional roundovers and chamfering.
// SynTags: Geom, VNF
// Topics: Shapes (3D), Attachable, VNF Generators
// See Also: cuboid(), rounded_prism(), trapezoid()
// Usage:
@ -770,7 +773,8 @@ function prismoid(
// Function&Module: octahedron()
// Synopsis: Creates an octahedron with axis-aligned points, or returns a vnf.
// Synopsis: Creates an octahedron with axis-aligned points.
// SynTags: Geom, VNF
// Topics: Shapes (3D), Attachable, VNF Generators
// See Also: prismoid()
// Usage: As Module
@ -811,7 +815,8 @@ function octahedron(size=1, anchor=CENTER, spin=0, orient=UP) =
// Module: rect_tube()
// Synopsis: Creates a rectangular tube, or returns a vnf.
// Synopsis: Creates a rectangular tube.
// SynTags: Geom, VNF
// Topics: Shapes (3D), Attachable, VNF Generators
// See Also: tube()
// Usage: Typical Rectangular Tubes
@ -1084,7 +1089,8 @@ function rect_tube(
// Function&Module: wedge()
// Synopsis: Creates a 3d triangular wedge, or returns a vnf.
// Synopsis: Creates a 3d triangular wedge.
// SynTags: Geom, VNF
// Topics: Shapes (3D), Attachable, VNF Generators
// See also: prismoid(), rounded_prism(), pie_slice()
// Usage: As Module
@ -1167,7 +1173,8 @@ function wedge(size=[1,1,1], center, anchor, spin=0, orient=UP) =
// Function&Module: cylinder()
// Synopsis: Creates an attachable cylinder, or returns a vnf.
// Synopsis: Creates an attachable cylinder.
// SynTags: Geom, VNF
// Topics: Shapes (3D), Attachable, VNF Generators
// See Also: cyl()
// Usage: As Module (as in native OpenSCAD)
@ -1252,7 +1259,8 @@ function cylinder(h, r1, r2, center, r, d, d1, d2, anchor, spin=0, orient=UP) =
// Function&Module: cyl()
// Synopsis: Creates an attachable cylinder with roundovers and chamfering, or returns a vnf.
// Synopsis: Creates an attachable cylinder with roundovers and chamfering.
// SynTags: Geom, VNF
// Topics: Cylinders, Textures, Rounding, Chamfers
// See Also: texture(), rotate_sweep(), cylinder()
// Usage: Normal Cylinders
@ -1648,7 +1656,8 @@ module cyl(
// Module: xcyl()
// Synopsis: creates a cylinder oriented along the X axis, or returns a vnf.
// Synopsis: creates a cylinder oriented along the X axis.
// SynTags: Geom, VNF
// Topics: Cylinders, Textures, Rounding, Chamfers
// See Also: texture(), rotate_sweep(), cyl()
// Description:
@ -1730,7 +1739,8 @@ module xcyl(
// Module: ycyl()
// Synopsis: creates a cylinder oriented along the y axis, or returns a vnf.
// Synopsis: Creates a cylinder oriented along the y axis.
// SynTags: Geom, VNF
// Topics: Cylinders, Textures, Rounding, Chamfers
// See Also: texture(), rotate_sweep(), cyl()
// Description:
@ -1814,7 +1824,8 @@ module ycyl(
// Module: zcyl()
// Synopsis: creates a cylinder oriented along the Z axis, or returns a vnf.
// Synopsis: Creates a cylinder oriented along the Z axis.
// SynTags: Geom, VNF
// Topics: Cylinders, Textures, Rounding, Chamfers
// See Also: texture(), rotate_sweep(), cyl()
// Description:
@ -1897,7 +1908,8 @@ module zcyl(
// Module: tube()
// Synopsis: Creates a cylindrical or conical tube, or returns a vnf.
// Synopsis: Creates a cylindrical or conical tube.
// SynTags: Geom, VNF
// Topics: Shapes (3D), Attachable, VNF Generators
// See Also: rect_tube()
// Description:
@ -1994,7 +2006,8 @@ module tube(
// Function&Module: pie_slice()
// Synopsis: Creates a pie slice shape, or returns a vnf.
// Synopsis: Creates a pie slice shape.
// SynTags: Geom, VNF
// Topics: Shapes (3D), Attachable, VNF Generators
// See Also: wedge()
// Description:
@ -2092,7 +2105,8 @@ function pie_slice(
// Function&Module: sphere()
// Synopsis: Creates an attachable spherical object, or returns a vnf.
// Synopsis: Creates an attachable spherical object.
// SynTags: Geom, VNF
// Topics: Shapes (3D), Attachable, VNF Generators
// See Also: spheroid()
// Usage: As Module (native OpenSCAD)
@ -2138,7 +2152,8 @@ function sphere(r, d, anchor=CENTER, spin=0, orient=UP) =
// Function&Module: spheroid()
// Synopsis: Creates an attachable spherical object with controllable triangulation, or returns a vnf.
// Synopsis: Creates an attachable spherical object with controllable triangulation.
// SynTags: Geom, VNF
// Topics: Shapes (3D), Attachable, VNF Generators
// See Also: sphere()
// Usage: Typical
@ -2468,7 +2483,8 @@ function spheroid(r, style="aligned", d, circum=false, anchor=CENTER, spin=0, or
// Function&Module: torus()
// Synopsis: Creates an attachable torus, or returns a vnf.
// Synopsis: Creates an attachable torus.
// SynTags: Geom, VNF
// Topics: Shapes (3D), Attachable, VNF Generators
// See Also: spheroid(), cyl()
//
@ -2611,7 +2627,8 @@ function torus(
// Function&Module: teardrop()
// Synopsis: Creates a teardrop shape, or returns a vnf.
// Synopsis: Creates a teardrop shape.
// SynTags: Geom, VNF
// Topics: Shapes (3D), Attachable, VNF Generators, FDM Optimized
// See Also: onion(), teardrop2d()
// Description:
@ -2752,7 +2769,8 @@ function teardrop(h, r, ang=45, cap_h, r1, r2, d, d1, d2, cap_h1, cap_h2, chamf
// Function&Module: onion()
// Synopsis: Creates an attachable onion-like shape, or returns a vnf.
// Synopsis: Creates an attachable onion-like shape.
// SynTags: Geom, VNF
// Topics: Shapes (3D), Attachable, VNF Generators, FDM Optimized
// See Also: teardrop(), teardrop2d()
// Description:
@ -2841,7 +2859,8 @@ function onion(r, ang=45, cap_h, d, anchor=CENTER, spin=0, orient=UP) =
// Section: Text
// Module: text3d()
// Synopsis: Creates an attachable 3d text block, or returns a vnf.
// Synopsis: Creates an attachable 3d text block.
// SynTags: Geom
// Topics: Attachments, Text
// See Also: path_text(), text()
// Usage:
@ -2948,7 +2967,8 @@ function _cut_interp(pathcut, path, data) =
// Module: path_text()
// Synopsis: Creates 2d or 3d text placed along a path, or returns a vnf.
// Synopsis: Creates 2d or 3d text placed along a path.
// SynTags: Geom
// Topics: Text, Paths, Paths (2D), Paths (3D), Path Generators, Path Generators (2D)
// See Also, text(), text2d()
// Usage:
@ -3193,7 +3213,8 @@ module path_text(path, text, font, size, thickness, lettersize, offset=0, revers
// Topics: Shapes (3D), Attachable
// Module: fillet()
// Synopsis: Creates a smooth fillet between two faces, or returns a vnf.
// Synopsis: Creates a smooth fillet between two faces.
// SynTags: Geom, VNF
// See Also: mask2d_roundover()
// Description:
// Creates a shape that can be unioned into a concave joint between two faces, to fillet them.
@ -3272,7 +3293,8 @@ module fillet(l=1.0, r, ang=90, overlap=0.01, d, length, h, height, anchor=CENTE
// Function&Module: heightfield()
// Synopsis: Generates a 3D surface from a 2D grid of values, or returns a vnf.
// Synopsis: Generates a 3D surface from a 2D grid of values.
// SynTags: Geom, VNF
// Topics: Textures, Heightfield
// See Also: cylindrical_heightfield()
// Usage: As Module
@ -3402,7 +3424,8 @@ function heightfield(data, size=[100,100], bottom=-20, maxz=100, xrange=[-1:0.04
// Function&Module: cylindrical_heightfield()
// Synopsis: Generates a cylindrical 3d surface from a 2D grid of values, or returns a vnf.
// Synopsis: Generates a cylindrical 3d surface from a 2D grid of values.
// SynTags: Geom, VNF
// Topics: Extrusion, Textures, Knurling, Heightfield
// See Also: heightfield()
// Usage: As Function
@ -3550,6 +3573,7 @@ module cylindrical_heightfield(
// Module: ruler()
// Synopsis: Creates a ruler.
// SynTags: Geom
// Topics: Distance
// Usage:
// ruler(length, width, [thickness=], [depth=], [labels=], [pipscale=], [maxscale=], [colors=], [alpha=], [unit=], [inch=]) [ATTACHMENTS];

View file

@ -22,6 +22,7 @@
// skin(profiles, slices, [z=], [refine=], [method=], [sampling=], [caps=], [closed=], [style=], [convexity=], [anchor=],[cp=],[spin=],[orient=],[atype=]) [ATTACHMENTS];
// Usage: As function:
// vnf = skin(profiles, slices, [z=], [refine=], [method=], [sampling=], [caps=], [closed=], [style=], [anchor=],[cp=],[spin=],[orient=],[atype=]);
// Synopsis: Connect a sequence of arbitrary polygons into a 3D object.
// Description:
// Given a list of two or more path `profiles` in 3d space, produces faces to skin a surface between
// the profiles. Optionally the first and last profiles can have endcaps, or the first and last profiles
@ -510,6 +511,7 @@ function skin(profiles, slices, refine=1, method="direct", sampling, caps, close
// linear_sweep(region, [height], [center=], [slices=], [twist=], [scale=], [style=], [caps=], [convexity=]) [ATTACHMENTS];
// Usage: With Texturing
// linear_sweep(region, [height], [center=], texture=, [tex_size=]|[tex_counts=], [tex_scale=], [style=], [tex_samples=], ...) [ATTACHMENTS];
// Synopsis: Create a linear extrusion from a path with optional texturing.
// Description:
// If called as a module, creates a polyhedron that is the linear extrusion of the given 2D region or polygon.
// If called as a function, returns a VNF that can be used to generate a polyhedron of the linear extrusion
@ -826,6 +828,7 @@ function linear_sweep(
// rotate_sweep(shape, [angle], ...) [ATTACHMENTS];
// Usage: With Texturing
// rotate_sweep(shape, texture=, [tex_size=]|[tex_counts=], [tex_scale=], [tex_samples=], [tex_rot=], [tex_inset=], ...) [ATTACHMENTS];
// Synopsis: Create a surface of revolution from a path with optional texturing.
// Topics: Extrusion, Sweep, Revolution
// Description:
// Takes a polygon or [region](regions.scad) and sweeps it in a rotation around the Z axis, with optional texturing.
@ -1048,6 +1051,7 @@ module rotate_sweep(
// Usage: As Function
// vnf = spiral_sweep(poly, h, r|d=, turns, ...);
// vnf = spiral_sweep(poly, h, r1=|d1=, r1=|d2=, turns, ...);
// Synopsis: Sweep a path along a helix.
// Topics: Extrusion, Sweep
// Description:
// Takes a closed 2D polygon path, centered on the XY plane, and sweeps/extrudes it along a 3D spiral path
@ -1273,6 +1277,7 @@ module spiral_sweep(poly, h, r, turns=1, taper, r1, r2, d, d1, d2, internal=fals
// path_sweep(shape, path, [method], [normal=], [closed=], [twist=], [twist_by_length=], [symmetry=], [scale=], [scale_by_length=], [last_normal=], [tangent=], [uniform=], [relaxed=], [caps=], [style=], [convexity=], [anchor=], [cp=], [spin=], [orient=], [atype=]) [ATTACHMENTS];
// Usage: As function
// vnf = path_sweep(shape, path, [method], [normal=], [closed=], [twist=], [twist_by_length=], [symmetry=], [scale=], [scale_by_length=], [last_normal=], [tangent=], [uniform=], [relaxed=], [caps=], [style=], [transforms=], [anchor=], [cp=], [spin=], [orient=], [atype=]);
// Synopsis: Sweep a 2d polygon path along a 2d or 3d path.
// Description:
// Takes as input `shape`, a 2D polygon path (list of points), and `path`, a 2d or 3d path (also a list of points)
// and constructs a polyhedron by sweeping the shape along the path. When run as a module returns the polyhedron geometry.
@ -1867,6 +1872,7 @@ function path_sweep(shape, path, method="incremental", normal, closed, twist=0,
// path_sweep2d(shape, path, [closed], [caps], [quality], [style], [convexity=], [anchor=], [spin=], [orient=], [atype=], [cp=]) [ATTACHMENTS];
// Usage: as function
// vnf = path_sweep2d(shape, path, [closed], [caps], [quality], [style], [anchor=], [spin=], [orient=], [atype=], [cp=]);
// Synopsis: Sweep a 2d polygon path along a 2d path allowing self-intersection.
// Description:
// Takes an input 2D polygon (the shape) and a 2d path, and constructs a polyhedron by sweeping the shape along the path.
// When run as a module returns the polyhedron geometry. When run as a function returns a VNF.
@ -1994,6 +2000,7 @@ function _ofs_face_edge(face,firstlen,second=false) =
// sweep(shape, transforms, [closed], [caps], [style], [convexity=], [anchor=], [spin=], [orient=], [atype=]) [ATTACHMENTS];
// Usage: As Function
// vnf = sweep(shape, transforms, [closed], [caps], [style], [anchor=], [spin=], [orient=], [atype=]);
// Synopsis: Construct a 3d object from arbitrary transformations of a 2d polygon path.
// Description:
// The input `shape` must be a non-self-intersecting 2D polygon or region, and `transforms`
// is a list of 4x4 transformation matrices. The sweep algorithm applies each transformation in sequence
@ -2098,6 +2105,7 @@ module sweep(shape, transforms, closed=false, caps, style="min_edge", convexity=
// Topics: Paths, Path Subdivision
// Usage:
// newprof = subdivide_and_slice(profiles, slices, [numpoints], [method], [closed]);
// Synopsis: Resample list of paths to have the same point count and interpolate additional paths.
// Description:
// Subdivides the input profiles to have length `numpoints` where `numpoints` must be at least as
// big as the largest input profile. By default `numpoints` is set equal to the length of the
@ -2182,6 +2190,7 @@ function _smooth(data,len,closed=false,angle=false) =
// Function: rot_resample()
// Usage:
// rlist = rot_resample(rotlist, n, [method=], [twist=], [scale=], [smoothlen=], [long=], [turns=], [closed=])
// Synopsis: Resample a list of rotation operators.
// Description:
// Takes as input a list of rotation matrices in 3d. Produces as output a resampled
// list of rotation operators (4x4 matrixes) suitable for use with sweep(). You can optionally apply twist to
@ -2583,6 +2592,7 @@ function _find_one_tangent(curve, edge, curve_offset=[0,0,0], closed=true) =
// Function: associate_vertices()
// Usage:
// newpoly = associate_vertices(polygons, split);
// Synopsis: Create vertex association to control how skin() links vertices.
// Description:
// Takes as input a list of polygons and duplicates specified vertices in each polygon in the list through the series so
// that the input can be passed to `skin()`. This allows you to decide how the vertices are linked up rather than accepting
@ -2756,6 +2766,7 @@ function associate_vertices(polygons, split, curpoly=0) =
// Usage:
// tx = texture(tex, [n=], [inset=], [gap=], [roughness=]);
// Topics: Textures, Knurling
// Synopsis: Produce a standard texture.
// Description:
// Given a texture name, returns a texture. Textures can come in two varieties:
// - Heightfield textures which are 2D arrays of scalars. These are usually faster to render, but can be less precise and prone to triangulation errors. The table below gives the recommended style for the best triangulation. If results are still incorrect, switch to the similar VNF tile by adding the "_vnf" suffix.

View file

@ -9,10 +9,129 @@
// FileSummary: Various types of threaded rods and nuts.
//////////////////////////////////////////////////////////////////////
// Section: Thread Ends and Options
// A standard process for making machine screws is to begin with round stock that has
// beveled ends. This stock is then rolled between flat, grooved plates to form the threads.
// The result is a bolt that looks like this at the end:
// Figure(3D,Med,NoAxes,VPR=[83.7,0,115.5],VPT=[1.37344,1.26411,-0.299415],VPD=35.5861):
// threaded_rod(d=13,pitch=2,l=10,blunt_start=false,$fn=80);
// Figure(2D,Med,NoAxes): A properly mated screw and bolt with beveled ends
// $fn=32;
// projection(cut=true)
// xrot(-90){
// down(2.5)difference(){
// cuboid([20,20,5]);
// zrot(20)
// threaded_rod(d=13.2, pitch=2,l=5.1,blunt_start=false,internal=true);
// }
// up(2.85-2)threaded_rod(d=13, pitch=2, l=10, blunt_start=false);
//
// }
// Continues:
// Cross threading occurs when the bolt is misaligned with the threads in the nut.
// It can destroy the threads, or cause the nut to jam. The standard beveled end process
// makes cross threading a possibility because the beveled partial threads can pass
// each other when the screw enters the nut.
// Figure(2D,Med,NoAxes):
// $fn=32;
// projection(cut=true)
// xrot(-90){
// down(2.5)difference(){
// cuboid([20,20,5]);
// zrot(20)
// threaded_rod(d=13.2, pitch=2,l=5.1,blunt_start=false,internal=true);
// }
// left(.6)up(2.99)yrot(-atan(2/13)-1)rot(180+30)threaded_rod(d=13, pitch=2, l=10, blunt_start=false);
// }
// Continues:
// In addition, those partial screw threads may be weak, and easily broken. They do
// not contribute to the strength of the assembly.
// In 1891 Clinton A. Higbee received a patent for a modification to screw threads
// https://patents.google.com/patent/US447775A meant to address these limitations.
// Instead of beveling the end of the screw, Higbee said to remove the partial thread.
// The resulting screw might look like this:
// Figure(3D,Med,NoAxes,VPR=[71.4,0,292.8],VPT=[2.47443,0.356302,-1.41819],VPD=43.9335):
// $fn=48;
// threaded_rod(d=13,pitch=2,l=10,blunt_start=true,lead_in_shape="cut",end_len=.2);
// Continues:
// Because the threads are complete everywhere, cross threading is unlikely to occur.
// This type of threading has been called "Higbee threads", but in recent machinist
// handbooks it is called "blunt start" threading.
// This style of thread is not commonly used in metal fasteners because it requires
// machining the threads, which is much more costly than the rolling procedure described
// above. However, plastic threads usually have some sort of gradual thread end.
// For models that will be 3D printed, there is no reason to choose the standard
// bevel end bolt, so in this library the blunt start threads are the default.
// If you need standard bevel-end threads, you can choose them with the `blunt_start` options.
// Note that blunt start threads are more efficient.
// .
// Various options exist for controlling the ends of threads. You can specify bevels on threaded rods.
// In conventional threading, bevels are needed on the ends to remove sharp, thin edges, and
// the bevel is sized to the full outer diameter of the threaded rod.
// With blunt start threading, the bevel appears on the unthreaded part of the rod.
// On a threaded rod, a bevel value of `true` or a positive bevel value cut off the corner.
// Figure(3D,Med,NoAxes,VPR=[73.2,0,53.7],VPT=[2.47443,0.356302,-1.41819],VPD=43.9335):
// threaded_rod(d=13,pitch=2,l=10,blunt_start=true,bevel=true,$fn=80);
// Continues:
// A negative bevel value produces a flaring bevel, that might be useful if the rod needs to mate with another part.
// You can also set `bevel="reverse"` to get a flaring bevel of the default size.
// Figure(3D,Med,NoAxes,VPR=[73.2,0,53.7],VPT=[2.47443,0.356302,-1.41819],VPD=43.9335): Negative bevel on a regular threaded rod.
// threaded_rod(d=13,pitch=2,l=10,blunt_start=true,bevel=-2,$fn=80);
// Continues:
// If you set `internal=true` then bevels are reversed: positive bevels flare outward so that when you subtract
// the threaded rod it gives a beveled edge to the hole. In this case, negative bevels go inward, which might be useful to
// create a bevel at the bottom of a threaded hole.
// Figure(3D,Med,NoAxes,VPR=[73.2,0,53.7],VPT=[2.47443,0.356302,-1.41819],VPD=43.9335): Threaded rod mask produced using `internal=true` with regular bevel at the top and reversed bevel at the bottom.
// threaded_rod(d=13,pitch=2,l=10,blunt_start=true,bevel2=true,bevel1="reverse",internal=true,$fn=80);
// Continues:
// You can also extend the unthreaded section using the `end_len` parameters. A long unthreaded section will make
// it impossible to tilt the bolt and produce misaligned threads, so it could make assembly easier.
// Figure(3D,Med,NoAxes,VPR=[73.2,0,53.7],VPT=[2.47443,0.356302,-1.41819],VPD=43.9335):
// threaded_rod(d=13,pitch=2,l=15,end_len2=5,blunt_start=true,bevel=true,$fn=80);
// Continues:
// It is also possible to adjust the length of the lead-in section of threads, or the
// shape of that lead-in section. The lead-in length can be set using the `lead_in` arguments
// to specify a length or the `lead_in_ang` arguments to specify an angle. For general
// threading applications, making the lead in long creates a smaller thread that could
// be more fragile and more prone to cross threading.
// Figure(3D,Med,NoAxes,VPR=[51.5,0,303.4],VPT=[4.98906,1.63966,-0.141486],VPD=35.5861):
// threaded_rod(d=13,pitch=2,l=10,lead_in=6,blunt_start=true,bevel=false,$fn=80);
// Continues:
// To change the form of the thread end you use the `lead_in_shape` argument.
// You can specify "sqrt", "cut" or "smooth" shapes. The "sqrt" shape is the historical
// shape used in the library. The "cut" shape is available to model Higbee pattern threads, but
// is not as good as the others in practice, because the flat faces on the threads can hit each other.
// The lead-in shape is produced by applying a scale factor to the thread cross section that varies along the lead-in length.
// You can also specify a custom shape
// by giving a function literal, `f(x,L)` where `L` will be the total linear
// length of the lead-in section and `x` will be a value between 0 and 1 giving
// the position in the lead in, with 0 being the tip and 1 being the full height thread.
// The return value must be a 2-vector giving the thread width scale and thread height
// scale at that location. If `x<0` the function must return a thread height scale
// of zero, but it is usually best if the thread width scale does not go to zero,
// because that will give a sharply pointed thread end. If `x>1` the function must
// return `[1,1]`.
// Figure(3D,Med,NoAxes,VPR=[74.6,0,338.4],VPT=[-0.829811,-2.56647,2.54868],VPD=28.8248): The standard lead in shapes
// left_half()zrot(0){
// up(2) threaded_rod(d=13,pitch=2,l=2,blunt_start=true,bevel=false,$fn=128,anchor=BOT);
// up(4) threaded_rod(d=13,pitch=2,l=2.5,blunt_start=true,bevel=false,$fn=128,lead_in_shape="cut",end_len2=.5,anchor=BOT);
// threaded_rod(d=13,pitch=2,l=2,blunt_start=true,bevel=false,$fn=128,lead_in_shape="smooth",anchor=BOT);
// }
// $fn=64;
// s=.85;
// color("black")
// up(3.5)left(4.5)fwd(6)rot($vpr){
// back(1.9)text3d("cut",size=s);
// text3d("sqrt",size=s);
// fwd(1.9)text3d("smooth",size=s);
// }
// Section: Standard (UTS/ISO) Threading
// Module: threaded_rod()
// Synopsis: Creates an ISO threaded rod.
// Synopsis: Creates an UTS/ISO triangular threaded rod.
// Topics: Threading, Screws
// See Also: threaded_nut()
// Usage:
@ -151,7 +270,7 @@ module threaded_rod(
// Module: threaded_nut()
// Synopsis: Creates an ISO threaded nut.
// Synopsis: Creates an UTS/ISO triangular threaded nut.
// Topics: Threading, Screws
// See Also: threaded_rod()
// Usage:
@ -1362,29 +1481,28 @@ module ball_screw_rod(
// Usage:
// generic_threaded_rod(d, l|length, pitch, profile, [internal=], ...) [ATTACHMENTS];
// Description:
// Constructs a generic threaded rod using an arbitrary thread profile that you supply. The rod can be tapered (e.g. for pipe threads).
// For specific thread types use other modules that supply the appropriate profile.
// Constructs a generic threaded rod using an arbitrary thread profile that you supply. The rod can be tapered
// (e.g. for pipe threads). For specific thread types use other modules that supply the appropriate profile.
// .
// You give the profile as a 2D path that will be scaled by the pitch to produce the final thread shape. The profile X values
// 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).
// Generally you should center the profile horizontally in the interval [-1/2, 1/2].
// You give the profile as a 2D path that will be scaled by the pitch to produce the final thread shape. The profile
// X values 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 first
// and last points should generally have the same Y value, but it is not necessary to give values at X=1/2 or X=-1/2
// if unless the Y values differ from the interior points in the profile. 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.
// When internal is true the rod diameter is enlarged to correct for the polygonal nature of circles to ensure that the internal diameter is the specified size.
// The diameter is also increased by `4 * $slop` to create clearance for threading by allowing a `2 * $slop` gap on each side.
// If bevel is set to true and internal is false then the ends of the rod will be beveled. When bevel is true and internal is true the ends of the rod will
// be filled in so that the rod mask will create a bevel when subtracted from an object. The bevel is at 45 deg and is the depth of the threads.
// If internal is true then produce a thread mask to difference from an object. When internal is true the rod
// diameter is enlarged to correct for the polygonal nature of circles to ensure that the internal diameter is the
// specified size. The diameter is also increased by `4 * $slop` to create clearance for threading by allowing a `2 *
// $slop` gap on each side. If bevel is set to true and internal is false then the ends of the rod will be beveled.
// When bevel is true and internal is true the ends of the rod will be filled in so that the rod mask will create a
// bevel when subtracted from an object. The bevel is at 45 deg and is the depth of the threads.
// .
// Higbee or blunt start threading specifies that the thread ends abruptly at its full width instead of running off the end of the shaft and leaving a sharp edged partial
// thread at the end of the screw. This makes screws easier to start and
// prevents cross threading. If you set `higbee=true` then the blunt start applies to both ends. The blunt start cuts the thread end in a single facet,
// so if you use lots of facets it will be close to perpendicular to the screw surface, but if you use fewer facets, it will be a more sloped cut.
// The place to cut the threads is calculated to try to leave a 1/4 thread gap from the end of the screw, but depending on your profile, you may
// wish to adjust this. If you set higbee to a numerical value it will be added to the computed higbee angle, so a positive value will cut the thread back farther
// giving more space at the end. Higbee works on both internal and external threads.
// Blunt start threading, which is the default, specifies that the thread ends abruptly at its full width instead of
// running off the end of the shaft and leaving a sharp edged partial thread at the end of the screw. This makes
// screws easier to start and prevents cross threading. Blunt start threads should always be superior, and they are
// faster to model, but if you really need standard threads that run off the end you can set `blunt_start=false`.
// Arguments:
// d = Outer diameter of threaded rod.
// l / length / h / height = Length of threaded rod.
@ -1942,6 +2060,7 @@ module thread_helix(
) {
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(pitch), "pitch 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);