Merge pull request #1134 from adrianVmariano/master

Add threading doc section and other doc tweaks
This commit is contained in:
Revar Desmera 2023-04-12 17:22:14 -07:00 committed by GitHub
commit 0f89fb0465
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 141 additions and 23 deletions

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

@ -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,117 @@
// FileSummary: Various types of threaded rods and nuts.
//////////////////////////////////////////////////////////////////////
// Section: Thread Ends and Options
// A standard process for making machine screws is to begin with wire stock that has
// pbeveled 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,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);
// Continues:
// A properly mated screw and bolt with beveled ends look like this:
// Figure(2D,Med):
// $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):
// $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,VPR=[71.4,0,292.8],VPT=[2.47443,0.356302,-1.41819],VPD=43.9335):
// $fn=32;
// 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 for controlling the ends of threads You can specify bevels on thread.
// With blunt start the bevel appears on the unthreaded part of the rod:
// Figure(3D,Med,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=32);
// Continues:
// You can also extend the unthreaded section using the `end_len` parameters. A long unthreaded section will make
// it very easy to correctly align the threads.
// Figure(3D,Med,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=32);
// 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,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=64);
// 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 threads across 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,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 +258,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 +1469,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 +2048,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);