Skip to content

Commit af86c0f

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 2f95b3b + e4822cf commit af86c0f

15 files changed

Lines changed: 409 additions & 178 deletions

attachments.scad

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,21 @@ module orient(anchor, spin) {
612612
// Several options can adjust how the child is positioned. You can specify `inset=` to inset the
613613
// aligned object from its alignment location. If you set `inside=true` then the
614614
// child appears inside the parent instead of on its surface so that you can use {{diff()}} to subract it.
615-
// In this case the child recieved a default "remove" tag. The `shiftout=` option works with `inside=true` to
616-
// shift the child out by the specified distance so that the child doesn't exactly align with the parent.
615+
// In this case the child receives a default "remove" tag.
616+
// .
617+
// The overlap option and shiftout option both move the object away from its aligned position. They
618+
// can be used to prevent coincident faces from creating issues in OpenSCAD by ensuring that the child
619+
// fully overlaps the parent's face(s). The `overlap` parameter defaults to the value of `$overlap`, or
620+
// 0 if `$overlap` is not set. It moves the child object in the direction of the `anchor` face when
621+
// `inside=false` (sinking the child into the parent) and it moves the child in the opposite direction
622+
// if `inside=true`, shifting the child outward away from the `anchor` face. The child will remain exactly flush
623+
// with edges it was aligned to using `align`. The `overlap` parameter is best suited to externally aligned objects (`inside=false`)
624+
// where the aligned edges should remain perfectly aligned. The `shiftout` parameter shifts the child outward relative to
625+
// the `anchor` face and also any aligned edges. The direction of movement does not depend on the `inside` parameter.
626+
// For an inside child this is equivalent to giving a positive overlap and negative inset value.
627+
// For a child with `inside=false` it is equivalent to a negative overlap and negative inset. The `shiftout` parameter
628+
// is well suited to internal objects where `inside=true` because it shifts to overlap all coincident faces, including
629+
// faces at aligned edges.
617630
// .
618631
// In the description above, the anchor was said to define a "face". You can also use this module
619632
// with an edge anchor, in which case a corner of the child is placed in contact with the specified
@@ -630,7 +643,7 @@ module orient(anchor, spin) {
630643
// inside = if true, place object inside the parent instead of outside. Default: false
631644
// inset = shift the child away from the alignment edge/corner by this amount. Default: 0
632645
// shiftout = Shift an inside object outward so that it overlaps all the aligned faces. Default: 0
633-
// overlap = Amount to sink the child into the parent. Defaults to `$overlap`, which is zero by default.
646+
// overlap = Amount to sink the child into the parent (or raise child out of parent if `inside=true`). Defaults to `$overlap`, which is zero by default.
634647
// Side Effects:
635648
// `$anchor` set to the anchor value used for the child.
636649
// `$align` set to the align value used for the child.
@@ -706,9 +719,13 @@ module orient(anchor, spin) {
706719
module align(anchor,align=CENTER,inside=false,inset=0,shiftout=0,overlap)
707720
{
708721
req_children($children);
709-
overlap = (overlap!=undef)? overlap : $overlap;
722+
overlap = (inside?-1:1)*((overlap!=undef)? overlap : $overlap);
710723
dummy1=assert($parent_geom != undef, "\nNo object to align to.")
711-
assert(is_undef($attach_to), "\nCannot use align() as a child of attach().");
724+
assert(is_undef($attach_to), "\nCannot use align() as a child of attach().")
725+
assert(is_finite(overlap), str("\noverlap must be a finite number but is ",overlap));
726+
if (_is_shown() && inside && overlap!=0 && (is_undef($align_msg) || $align_msg))
727+
echo("WARNING: overlap passed to align() with inside=true; handling has changed (May 2026): positive overlap moves child outward (change in sign). Set $align_msg=false to hide this message");
728+
712729
anchor = is_vector(anchor) ? [anchor] : anchor;
713730
align = is_vector(align) ? [align] : align;
714731
two_d = _attach_geom_2d($parent_geom);
@@ -795,40 +812,42 @@ function _make_anchor_legal(anchor,geom) =
795812
// spinning the object around the Z axis would change the child orientation so that the anchors are no longer parallel.
796813
// .
797814
// As with {{align()}} you can use the `align=` parameter to align the child to an edge or corner of the
798-
// face where that child is attached. For example, `attach(TOP,BOT,align=RIGHT)` would stand the child
799-
// up on the top while aligning it with the right edge of the top face, and `attach(RIGHT,BOT,align=TOP)`, which
800-
// stand the object on the right face while aligning with the top edge. If you apply spin using the
815+
// face where that child is attached. For example, `attach(TOP,BOT,align=RIGHT)` stands the child
816+
// up on the top while aligning it with the right edge of the top face, and `attach(RIGHT,BOT,align=TOP)`
817+
// stands the object on the right face while aligning with the top edge. If you apply spin using the
801818
// argument to `attach()`, then it is taken into account for the alignment. However, if you apply spin as
802819
// a parameter to the child, it is **not** taken into account. The special spin value "align"
803820
// spins the child so that the child's BACK direction is pointed toward the aligned edge on the parent.
804821
// When you use `align=` you can also adjust the position using `inset=`, which shifts the child
805-
// away from the edge or corner it is aligned to.
822+
// inward away from the edge or corner it is aligned to. The `inset=` parameter is not permitted without `align=`.
806823
// .
807824
// The concept of alignment doesn't always make sense for objects without corners, such as spheres or cylinders.
808825
// In same cases, the alignments using such children may look odd because the alignment computation tries to
809826
// place a non-existent corner somewhere. Because attach() doesn't have in formation about the child when
810827
// it runs, it cannot handle curved shapes differently from cubes, so this behavior cannot be changed.
811828
// .
812-
// If you give `inside=true` then the anchor arrows are lined up so they point the same direction and
813-
// the child object is located inside the parent. In this case a default "remove" tag is applied to
814-
// the children.
815-
// .
816829
// Because the attachment process forces an orientation and anchor point for the child, it overrides
817830
// any such specifications you give to the child: **both `anchor=` and `orient=` given to the child are
818831
// ignored** with the **double argument** version of `attach()`. As noted above, you can give `spin=` to the
819832
// child but using the `spin=` parameter to `attach()` is more likely to be useful.
820833
// .
821-
// You can overlap attached children into the parent by giving the `$overlap` value,
822-
// which is 0 by default, or by the `overlap=` argument. This is to prevent OpenSCAD
823-
// from making non-manifold objects. You can define `$overlap=` as an argument in a parent
824-
// module to set the default for all attachments to it. When you give `inside=true`, a positive overlap
825-
// value shifts the child object outward.
834+
// If you give `inside=true` then the anchor arrows are lined up so they point the same direction and
835+
// the child object is located inside the parent. In this case a default "remove" tag is applied to
836+
// the children.
826837
// .
827-
// If you specify an `inset=` value then the child is shifted away from any edges it is aligned to, toward the middle
828-
// of the parent. The `shiftout=` parameter is intended to simplify differences with aligned objects
829-
// placed inside the parent. It shifts the child outward along every direction where it is aligned with
830-
// the parent. For an inside child this is equivalent to giving a positive overlap and negative inset value.
831-
// For a child with `inside=false` it is equivalent to a negative overlap and negative inset.
838+
// The overlap option and shiftout option both move the object away from its aligned position. They
839+
// can be used to prevent coincident faces from creating issues in OpenSCAD by ensuring that the child
840+
// fully overlaps the parent's face(s). The `overlap` parameter defaults to the value of `$overlap`, or
841+
// 0 if `$overlap` is not set. It moves the child object in the direction of the `parent` face when
842+
// `inside=false` (sinking the child into the parent) and it moves the child in the opposite direction
843+
// if `inside=true`, shifting the child outward away from the `parent` face. The child will remain exactly flush
844+
// with edges it was aligned to using `align=`. The `overlap` parameter is best suited to externally attached objects (`inside=false`)
845+
// where the aligned edges should remain perfectly aligned. The `shiftout` parameter shifts the child outward relative to
846+
// the `parent` face and also any aligned edges. The direction of movement does not depend on the `inside` parameter.
847+
// For an inside child this is equivalent to giving a positive overlap and negative inset value.
848+
// For a child with `inside=false` it is equivalent to a negative overlap and negative inset. The `shiftout` parameter
849+
// is well suited to internal objects where `inside=true` because it shifts to overlap all coincident faces, including
850+
// faces at aligned edges.
832851
// .
833852
// The single parameter version of `attach()` is rarely needed; to use it, you give only the `parent` anchor. The `align` direction
834853
// is not permitted. In this case the child is placed at the specified parent anchor point
@@ -848,7 +867,7 @@ function _make_anchor_legal(anchor,geom) =
848867
// ---
849868
// align = If `child` is given you can specify alignment or list of alistnments to shift the child to an edge or corner of the parent.
850869
// inset = Shift aligned children away from their alignment edge/corner by this amount. Default: 0
851-
// overlap = Amount to sink child into the parent. Equivalent to `down(X)` after the attach. This defaults to the value in `$overlap`, which is `0` by default.
870+
// overlap = Amount to sink child into the parent (or raise child out of parent if `inside=true`). Equivalent to `down(X)` after the attach (or `up(X)` if `inside=true`). This defaults to the value in `$overlap`, which is `0` by default.
852871
// inside = If `child` is given you can set `inside=true` to attach the child to the inside of the parent for diff() operations. Default: false
853872
// shiftout = Shift an inside object outward so that it overlaps all the aligned faces. Default: 0
854873
// spin = Angle to rotate the child around the axis of the parent anchor. Can set to "align" to align the child's BACK with the parent aligned edge. (Permitted only in 3D.)

ball_bearings.scad

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ _BOSL2_BALL_BEARINGS = is_undef(_BOSL2_STD) && (is_undef(BOSL2_NO_STD_WARNING) |
1919
// SynTags: Geom
2020
// Topics: Parts, Bearings
2121
// See Also: linear_bearing(), lmXuu_bearing(), lmXuu_housing()
22+
// Usage:
23+
// ball_bearing(trade_size, [id=], [od=], [width=], [shield=], [flange=], [fd=], [fw=], [rounding=], [anchor=], [spin=], [orient=]) [ATTACHMENTS];
2224
// Description:
2325
// Creates a model of a ball bearing assembly.
2426
// Arguments:
@@ -103,6 +105,8 @@ module ball_bearing(trade_size, id, od, width, shield=true, flange=false, fd, fw
103105
// Synopsis: Returns size info for a standardized ball bearing assembly.
104106
// Topics: Parts, Bearings
105107
// See Also: ball_bearing(), linear_bearing(), lmXuu_info()
108+
// Usage:
109+
// info = ball_bearing_info(trade_size);
106110
// Description:
107111
// Get dimensional info for a standard metric ball bearing cartridge.
108112
// Returns `[SHAFT_DIAM, OUTER_DIAM, WIDTH, SHIELDED, FLANGED, FLANGE_DIAM, FLANGE_WIDTH]` for the cylindrical cartridge.

gears.scad

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2798,7 +2798,6 @@ function worm(
27982798
helical=helical,
27992799
profile_shift=0
28002800
), 1, -2),
2801-
// ff=echo(tooth=tooth, rack_profile=rack_profile,nrp=nrp),
28022801
steps = max(36, segs(d/2)),
28032802
step = 360 / steps,
28042803
zsteps = ceil(l / trans_pitch / starts * steps),
@@ -3003,7 +3002,7 @@ function enveloping_worm(
30033002
vnf1 = vnf_vertex_array(transpose(rows), col_wrap=true, caps=true),
30043003
m = product([
30053004
zrot(gear_spin),
3006-
if (!left_handed) xflip(),
3005+
if (left_handed) xflip(),
30073006
zrot(90),
30083007
]),
30093008
vnf = apply(m, vnf1)
@@ -3070,7 +3069,7 @@ module enveloping_worm(
30703069
// worm_diam = The pitch diameter of the worm gear to match to. Default: 30
30713070
// worm_starts = The number of lead starts on the worm gear to match to. Default: 1
30723071
// worm_arc = The arc of the worm to mate with, in degrees. Default: 45 degrees
3073-
// 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
3072+
// 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: 0.1
30743073
// left_handed = If true, the gear returned will have a left-handed spiral. Default: false
30753074
// pressure_angle = Controls how straight or bulged the tooth sides are. In degrees. Default: 20
30763075
// backlash = Gap between two meshing teeth, in the direction along the circumference of the pitch circle. Default: 0
@@ -3152,7 +3151,7 @@ function worm_gear(
31523151
)
31533152
assert(is_finite(worm_diam) && worm_diam>0)
31543153
assert(is_integer(teeth) && teeth>7)
3155-
// assert(is_finite(worm_arc) && worm_arc>0 && worm_arc <= 60)
3154+
assert(is_finite(worm_arc) && worm_arc>0 && worm_arc<=90, "worm_arc must be between 0 and 90 degrees")
31563155
assert(is_integer(worm_starts) && worm_starts>0)
31573156
assert(is_bool(left_handed))
31583157
assert(is_finite(backlash))
@@ -3162,7 +3161,6 @@ function worm_gear(
31623161
let(
31633162
gear_arc = 2 * PA,
31643163
helical = asin(worm_starts * circ_pitch / PI / worm_diam),
3165-
//fee=echo(helical=helical),
31663164
full_tooth = path3d(reverse(zrot(90, _gear_tooth_profile(
31673165
circ_pitch, teeth=teeth,
31683166
pressure_angle=PA,
@@ -3172,13 +3170,10 @@ function worm_gear(
31723170
helical=helical, internal=false,
31733171
center=true)))),
31743172
bnd = pointlist_bounds(full_tooth),
3175-
fdeewqqq= echo(toothbounds = bnd)echo(toothlength = bnd[1].x-bnd[0].x),
31763173
tooth_bot = pointlist_bounds(full_tooth)[1].x,
31773174
ftl = len(full_tooth),
31783175
tooth_half1 = select(full_tooth, 0, ftl/2-1),
31793176
tooth_half2 = select(full_tooth, ftl/2, -1),
3180-
//eer= echo(full_tooth=full_tooth),
3181-
//fdewq= echo(tooth_half1=tooth_half1)echo(tooth_half2=tooth_half2),
31823177
tang = 360 / teeth,
31833178

31843179
pr = pitch_radius(circ_pitch, teeth, helical=helical),
@@ -3187,7 +3182,6 @@ fdeewqqq= echo(toothbounds = bnd)echo(toothlength = bnd[1].x-bnd[0].x),
31873182
half_thickness = sin(worm_arc/2)*(worm_diam/2+tooth_bot),
31883183
// Update worm_arc to account for crowning and produce same thickness
31893184
worm_arc = 2*asin(half_thickness / (worm_diam/2 + crowning + tooth_bot)),
3190-
feee=echo(pr_worm = pr, teeth=teeth ,helical= helical),
31913185

31923186
// When multiplied by z this gives the spin required to rotationally shear
31933187
// a straight tooth so that it follows the specified helical angle.
@@ -3250,7 +3244,6 @@ fdeewqqq= echo(toothbounds = bnd)echo(toothlength = bnd[1].x-bnd[0].x),
32503244
)
32513245
get_thickness? zmax*2 :
32523246
let(
3253-
feef=echo(actual_thick=zmax*2, est=half_thickness*2),
32543247
gear_rows = [
32553248
for (i = [0:1:teeth-1])
32563249
let(
@@ -3296,7 +3289,7 @@ module worm_gear(
32963289
assert(is_integer(teeth) && teeth>10)
32973290
assert(is_finite(worm_diam) && worm_diam>0)
32983291
assert(is_integer(worm_starts) && worm_starts>0)
3299-
// assert(is_finite(worm_arc) && worm_arc>0 && worm_arc<90)
3292+
assert(is_finite(worm_arc) && worm_arc>0 && worm_arc<=90, "worm_arc must be between 0 and 90 degrees")
33003293
assert(is_finite(crowning) && crowning>=0)
33013294
assert(is_bool(left_handed))
33023295
assert(is_finite(PA) && PA>=0 && PA<90, "Bad pressure_angle value.")
@@ -4166,7 +4159,7 @@ function bevel_pitch_angle(teeth, mate_teeth, drive_angle=90) =
41664159
// ---
41674160
// worm_arc = The arc of the worm to mate with, in degrees. Default: 45 degrees
41684161
// pressure_angle = Pressure angle in degrees. Controls how straight or bulged the tooth sides are. Default: 20º
4169-
// 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
4162+
// 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: 0.1
41704163
// clearance = Clearance gap at the bottom of the inter-tooth valleys. Default: module/4
41714164
// mod = The module of the gear (pitch diameter / teeth)
41724165
// diam_pitch = The diametral pitch, or number of teeth per inch of pitch diameter. The diametral pitch is a completely different thing than the pitch diameter.

0 commit comments

Comments
 (0)