Threads: a 12 mm hole now takes an M12 thread, and a modelled M12 builds in it (#11651)

* Threads: a 12 mm hole takes M12, and a modelled thread narrows a bore that is too wide (#11609)

Automatic sizing of a hole now takes the size whose nominal diameter the hole has (a 12 mm hole
is M12, not M14, the size whose tap drill is 12 mm); a hole near no nominal diameter is still
matched by tap drill. A modelled internal thread in a hole as wide as the thread or wider no
longer refuses with "too wide": the bore is filled in to the thread's minor diameter over the
threaded length and the groove cut there, and the feature's warning says so. A size that does
not fit the hole names the size that does.

A saved thread with no designation keeps the old rule through a pending format step, so an
existing design rebuilds with the size it had.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Threads: keep an old automatic size through edits; kernel-rig cases expect the narrowed bore (#11609)

Editing a saved automatic thread keeps `old_auto_size`, so it does not change size. The five
kernel-rig cases that expected a modelled thread in a hole as wide as the thread to be refused
now expect the narrowed bore, with the volume worked out analytically in each case. The thread
dialog's reopen pattern names the new field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Thread dialog test: a 5 mm hole is suggested M5, its nominal size (#11609)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bherbruck
2026-11-03 17:09:27 +00:00
committed by GitHub
parent 2741df3629
commit c019e2555c
16 changed files with 403 additions and 63 deletions
+4
View File
@@ -959,6 +959,10 @@ pub enum FeatureKind {
/// Buttress forms: which way the steep flank of the screw's teeth faces.
#[serde(default, skip_serializing_if = "crate::thread_forms::is_default")]
steep_flank: crate::thread_forms::SteepFlank,
/// Set on threads saved before holes were sized by their nominal diameter, whose size
/// was left to the tap drill: a 12 mm hole stays M14 there. New threads leave it off.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
old_auto_size: bool,
},
/// Ruled loft through profiles of several sketches, in order.
Loft {
+1 -1
View File
@@ -7018,7 +7018,7 @@ fn eval_feature(
}
Ok(())
}
FeatureKind::Thread { .. } => thread::eval(doc, vals, f, st),
FeatureKind::Thread { .. } => thread::eval(doc, vals, f, st, warning),
FeatureKind::Shell { faces, thickness, body, direction, tangent_chain } => {
let t = val(vals, thickness, Kind::Length)?;
// No face opened (a closed hollow body) picks no body: the one there is, or the named one.
+1
View File
@@ -1279,6 +1279,7 @@ fn marking(p: Vec3) -> FeatureKind {
chamfer_angle: None,
chamfer_depth: None,
steep_flank: Default::default(),
old_auto_size: false,
}
}
+64 -8
View File
@@ -89,6 +89,9 @@ pub(super) struct ThreadAsk<'a> {
/// A tapped hole's thread: `designation` is a catalogue size (ISO metric, or a catalogued
/// UNC/UNF, G, Rp, Rc or NPT size), and a size that is not metric fits the hole drilled for it.
pub tapped: bool,
/// A design saved before holes were sized by their nominal diameter: with no designation, a
/// hole is matched by its tap drill alone ([`ThreadForm::fit_with`]), so it keeps its size.
pub old_auto_size: bool,
}
/// How one end of a thread's length meets its face.
@@ -115,6 +118,9 @@ pub(super) struct ThreadOn {
ease: [f64; 2],
/// The end of the axis (0: its start, 1: its end) the thread starts from.
from: usize,
/// A modelled internal thread in a hole wider than it needs: the radius the bore is narrowed
/// to (the thread's minor radius) before the groove is cut, with the hole's own radius.
narrow: Option<f64>,
}
/// The free-end test of a face's two ends (`side` 0 at its start, 1 at its end), each made
@@ -197,7 +203,7 @@ pub(super) fn thread_on(st: &ModelState, feature: u64, p: Vec3, ask: &ThreadAsk)
(Some(t), _) => crate::thread_forms::ThreadSize { form, major: t.major_diameter, pitch: t.pitch, lead: t.pitch },
(None, Some(s)) => form.parse(s, starts).map_err(DocError::Invalid)?,
(None, None) => {
let (d, p) = form.fit(dia, cyl.internal).ok_or_else(|| {
let (d, p) = form.fit_with(dia, cyl.internal, ask.old_auto_size).ok_or_else(|| {
DocError::Invalid(if form.sizes().is_empty() {
format!("{} threads have no size table: give the designation ({})", form.name(), form.format(50.8, 25.4 / 8.0, 25.4 / 8.0))
} else {
@@ -243,12 +249,19 @@ pub(super) fn thread_on(st: &ModelState, feature: u64, p: Vec3, ask: &ThreadAsk)
// The hole drilled for it, without borrowing an ISO minor-diameter rule.
cyl.internal && (t.tap_drill - dia).abs() < 0.15 * major
} else if cyl.internal {
(minor - dia).abs() < 0.2 * major || (form.drill(major, pitch) - dia).abs() < 0.15 * major
(minor - dia).abs() < 0.2 * major || (form.drill(major, pitch) - dia).abs() < 0.15 * major || (major - dia).abs() < 0.15 * major
} else {
(major - dia).abs() < 0.15 * major
};
if !fits {
return Err(DocError::Invalid(format!("an {designation} thread does not fit a {dia:.2} mm {}", if cyl.internal { "hole" } else { "shaft" })));
let kind = if cyl.internal { "hole" } else { "shaft" };
let try_instead = form
.fit(dia, cyl.internal)
.map(|(n, q)| form.format(n, q, q))
.filter(|a| *a != designation)
.map(|a| format!("; this {kind} takes {a}"))
.unwrap_or_default();
return Err(DocError::Invalid(format!("an {designation} thread does not fit a {dia:.2} mm {kind}{try_instead}")));
}
// The radii the groove cuts: from the external thread's minor diameter (a nut's: its minor)
// to the major (a nut's root), and to the face itself where it lies outside that.
@@ -354,7 +367,13 @@ pub(super) fn thread_on(st: &ModelState, feature: u64, p: Vec3, ask: &ThreadAsk)
hand: ask.hand,
starts,
};
Ok(ThreadOn { info, cyl, ends, steep: ask.steep, ease, from: side })
// A hole already as wide as the thread's major diameter (a 12 mm hole for M12) has no wall to
// cut a groove into: the bore is narrowed to the thread's minor diameter first.
let narrow = (ask.modeled && cyl.internal && tapped.is_none() && !form.is_taper())
.then(|| form.groove(major, pitch, true))
.filter(|g| !(g.root_r - cyl.radius >= g.basic_depth / 4.0))
.map(|g| g.crest_r);
Ok(ThreadOn { info, cyl, ends, steep: ask.steep, ease, from: side, narrow })
}
/// The end of the face (0: its start, 1: its end) a thread of limited length starts at: the end
@@ -681,7 +700,7 @@ fn taper_envelope(t: &ThreadInfo, radius: f64, ends: [End; 2], (d0, from): (f64,
/// Evaluate a thread feature: a cosmetic thread is listed in the model's threads, a modelled
/// one cut into its body.
pub(super) fn eval(doc: &Document, vals: &BTreeMap<String, Value>, f: &Feature, st: &mut ModelState) -> Result<()> {
pub(super) fn eval(doc: &Document, vals: &BTreeMap<String, Value>, f: &Feature, st: &mut ModelState, warning: &mut Option<String>) -> Result<()> {
let FeatureKind::Thread {
face,
designation,
@@ -697,6 +716,7 @@ pub(super) fn eval(doc: &Document, vals: &BTreeMap<String, Value>, f: &Feature,
chamfer_angle,
chamfer_depth,
steep_flank,
old_auto_size,
} = &f.kind
else {
return Err(DocError::Invalid("not a thread".into()));
@@ -723,6 +743,7 @@ pub(super) fn eval(doc: &Document, vals: &BTreeMap<String, Value>, f: &Feature,
modeled: *modeled,
ease_out: (0.0, 0.0),
tapped: false,
old_auto_size: *old_auto_size,
};
if ease_out.is_some() && !*modeled {
return Err(DocError::Invalid("a runout is cut only on a modelled thread".into()));
@@ -735,6 +756,18 @@ pub(super) fn eval(doc: &Document, vals: &BTreeMap<String, Value>, f: &Feature,
}
let angle = chamfer_angle.as_deref().map(|e| val(vals, e, Kind::Angle)).transpose()?;
let depth = chamfer_depth.as_deref().map(|e| val(vals, e, Kind::Length)).transpose()?;
if let Some(r) = on.narrow {
let note = format!(
"narrowed the {} mm hole to {} mm (the {} thread's minor diameter) so the thread has material to cut into",
show_mm(2.0 * on.cyl.radius),
show_mm(2.0 * r),
on.info.designation
);
*warning = Some(match warning.take() {
Some(w) => format!("{w}; {note}"),
None => note,
});
}
cut(st, on, (*tip, angle, depth))
}
@@ -752,10 +785,33 @@ pub(super) fn runout(vals: &BTreeMap<String, Value>, e: &Option<crate::ThreadRun
/// sweeps, a taper's crests by its envelope) by one B-rep boolean, then the chamfered tip
/// (`tip`, with its angle and depth when given).
pub(super) fn cut(st: &mut ModelState, on: ThreadOn, (tip, angle, depth): (ThreadTip, Option<f64>, Option<f64>)) -> Result<()> {
let ThreadOn { info: t, cyl, ends, steep, ease, from: from_side } = on;
let ThreadOn { info: t, cyl, ends, steep, ease, from: from_side, narrow } = on;
let i = st.bodies.iter().position(|b| b.name == t.body).ok_or_else(|| DocError::Invalid("threaded body".into()))?;
let Some(mb) = st.bodies.get(i).cloned() else { return Err(DocError::Invalid("body".into())) };
let (input, radius) = (mb.traced(), cyl.radius);
let (mut input, radius) = (mb.traced(), cyl.radius);
// A hole wider than the thread needs is filled in to the thread's minor radius over the
// threaded length first, so the groove has the wall to cut into.
let mut groove_radius = radius;
if let Some(r_min) = narrow {
let (lo, hi) = ((t.start - ease[0]).max(cyl.start), (t.end + ease[1]).min(cyl.end));
let k = *t.axis;
let u = k.cross(if k.x.abs() < 0.9 { Vec3::new(1.0, 0.0, 0.0) } else { Vec3::new(0.0, 1.0, 0.0) });
let u = u.normalized().ok_or_else(|| DocError::Invalid("thread axis".into()))?;
let plane = Plane { origin: t.axis_point + k * lo, x: u, y: k };
let r_out = radius + 0.1 * t.pitch;
let pts = [Vec2::new(r_min, 0.0), Vec2::new(r_out, 0.0), Vec2::new(r_out, hi - lo), Vec2::new(r_min, hi - lo)];
let region = Region2 { outer: solidcore_record::Loop2::polygon(&pts), holes: Vec::new() };
let sleeve = kernel::revolve(&plane, &[region], Vec2::new(0.0, 0.0), Vec2::new(0.0, 1.0), std::f64::consts::TAU)?
.pop()
.ok_or_else(|| DocError::Invalid("the narrowed bore".into()))?;
let faces = sleeve.face_count();
let filled =
kernel::boolean(&input.body, &sleeve, BoolOp::Union)?.ok_or_else(|| DocError::Invalid("narrowing the hole removed everything".into()))?;
let unnamed = crate::lineage::Lineage::unnamed_faces(faces);
let lineage = input.lineage.and_then(|l| crate::lineage::Lineage::step(&filled, &[&l, &unnamed]));
input = Traced { body: filled, lineage };
groove_radius = r_min;
}
// The exact grooves: SMLib's screw sweeps, cut by one B-rep boolean.
// A taper thread starts at its free end at the major diameter its standard puts there: an
// internal one's gauge (reference) plane at its face, an external one's that far in.
@@ -767,7 +823,7 @@ pub(super) fn cut(st: &mut ModelState, on: ThreadOn, (tip, angle, depth): (Threa
false => None,
};
let mut grooves = Vec::new();
for g in thread_grooves(&t, radius, (cyl.start, cyl.end), ends, steep, ease, taper)? {
for g in thread_grooves(&t, groove_radius, (cyl.start, cyl.end), ends, steep, ease, taper)? {
let section = Region2 { outer: solidcore_record::Loop2::polygon(&g.section), holes: Vec::new() };
grooves.push(kernel::sweep_helix_radial(&g.plane, &section, g.base, g.axis, g.pitch, g.turns, &g.law)?);
}
@@ -0,0 +1,45 @@
//! A thread with no `designation` (its size left automatic) now takes, for a hole, the size
//! whose nominal diameter the hole has (a 12 mm hole is M12); before, it took the size whose tap
//! drill the hole matches (a 12 mm hole was M14, the drill M14 is tapped at). A design saved
//! before keeps its size: each such thread is saved with `old_auto_size`, which an automatic
//! thread made now does not have. A modelled thread in a hole wider than it needs also narrows
//! the bore now, rather than being refused. The last release refuses a design saved with this
//! (the newer format number).
use serde_json::Value;
pub fn step(v: &mut Value) -> crate::Result<()> {
let Some(Value::Array(features)) = v.get_mut("features") else {
return Ok(());
};
for feature in features {
let Some(object) = feature.as_object_mut() else { continue };
if object.get("type").and_then(Value::as_str) != Some("thread") {
continue;
}
if object.get("designation").is_none_or(Value::is_null) {
object.insert("old_auto_size".into(), Value::Bool(true));
}
}
Ok(())
}
#[cfg(test)]
mod tests {
use serde_json::json;
#[test]
fn an_automatic_thread_keeps_the_old_rule_and_a_named_one_is_left_alone() {
let mut v = json!({"features": [
{"type": "thread", "face": [6, 0, 5]},
{"type": "thread", "designation": "M12"},
{"type": "hole", "thread": "M12"}
]});
super::step(&mut v).unwrap();
assert_eq!(v["features"][0]["old_auto_size"], json!(true));
assert!(v["features"][1].get("old_auto_size").is_none());
assert!(v["features"][2].get("old_auto_size").is_none());
let mut empty = json!({"name": "Untitled"});
super::step(&mut empty).unwrap();
assert_eq!(empty, json!({"name": "Untitled"}));
}
}
+15 -1
View File
@@ -554,8 +554,22 @@ impl ThreadForm {
}
/// The standard size a cylinder of this diameter takes: a shaft is the major diameter, a hole
/// the drill. None when no size is within 15% (or the form has no size table).
/// its nominal diameter, else the drill ([`fit_with`](Self::fit_with)). None when no size is within 15% (or the form has no size table).
pub fn fit(self, diameter: f64, internal: bool) -> Option<(f64, f64)> {
self.fit_with(diameter, internal, false)
}
/// [`fit`](Self::fit) as designs saved before the nominal rule had it (`old_rule`: a hole is
/// matched by the tap drill alone, so a 12 mm hole is M14's) or as it is now: a hole as wide
/// as a size's nominal diameter (within 1% and 0.03 mm) is that size, a 12 mm hole is M12,
/// and only a hole near no nominal diameter is matched by tap drill.
pub fn fit_with(self, diameter: f64, internal: bool, old_rule: bool) -> Option<(f64, f64)> {
if internal && !old_rule {
let near = |n: f64| (n - diameter).abs() <= 0.01 * diameter + 0.03;
if let Some((n, p)) = self.sizes().into_iter().find(|(n, _)| near(*n)) {
return Some((n, p));
}
}
self.sizes()
.into_iter()
.map(|(n, p)| (n, p, if internal { self.drill(n, p) } else { n }))
+9
View File
@@ -1750,6 +1750,15 @@ fn redefine(s: &mut Session, p: &Value) -> Result<Value> {
{
parameters.entry("convention").or_insert_with(|| json!(convention));
}
// A thread saved before holes were sized by their nominal diameter keeps the size it had
// when it is edited without naming one.
if let FeatureKind::Thread { old_auto_size: true, .. } = &old.kind
&& cid == "solid.thread"
&& let Some(parameters) = params.as_object_mut()
&& parameters.get("designation").is_none_or(|d| d.is_null() || d.as_str().is_some_and(|d| d.trim().is_empty()))
{
parameters.entry("old_auto_size").or_insert_with(|| json!(true));
}
// Members keep their names through an edit, unless it gives them another name.
if let FeatureKind::FrameMember { names, body_name, .. } = &old.kind
&& cid == "frame.member"
+10 -2
View File
@@ -132,7 +132,7 @@ pub static COMMANDS: &[CommandSpec] = &[
CommandSpec::new("solid.thread", "Thread", thread)
.at("SOLID", "CREATE")
.icon("thread")
.params("face: [x,y,z] on a cylindrical face; form?: metric|trapezoidal|acme|buttress|buttress_asme|bspp|rp|bspt|npt (default: the one `designation` names, else metric; square is refused: no current standard defines it); designation?: the size, as its standard writes it: metric \"M8\", \"M8x1\", \"M16xPh3P1.5\" (ISO 68-1, ISO 261, ISO 965-1); trapezoidal \"Tr20x4\", \"Tr40x14(P7)\" (ISO 2904, ISO 2903); buttress \"S20x4\", \"S40x14(P7)\" (DIN 513, 3°/30°); acme \"1/2-10 ACME\" (ASME B1.5); buttress_asme \"2.5-8 BUTT\" (ASME B1.9, 7°/45°, basic profile; no size table); bspp \"G 1/2\" (ISO 228-1, 55° parallel); rp \"Rp 1/2\" (ISO 7-1's parallel internal thread, 55°, an R screws into it; internal only); bspt \"R 1/2\" external, \"Rc 1/2\" internal (ISO 7-1, 55°, taper 1 in 16); npt \"1/2-14 NPT\" (ASME B1.20.1, 60°, taper 1 in 16) — a taper thread starts at a free end (the pipe end or the hole mouth) with its standard diameter there, and an external one runs its standard length unless `length` or `up_to` says otherwise (default: the standard size that fits the face, a shaft its major diameter, a hole its drill); hand?: right|left|both (default right; both: a right- and a left-handed groove crossing); steep_flank?: start|end (buttress only, default end: the steep flank of the screw's teeth faces the thread's end, the way its axis points); starts?: 1..8 (lead = starts x pitch: that many grooves, each a turn's starts-th further round; a designation that gives the lead gives the starts); ease_out?: expr|standard|short (modelled threads: the inner end, away from where the thread starts, fades out over this length (shorter than a turn too), its section moving out of the material as it turns; standard 2.5 P, short 1.25 P per ISO 3508; it lies past the full-form length, up to a shoulder's clearance; at a free end, inside the face; without it the groove stops square there, ending in its own profile; the start never fades: it runs off its free end, plain or chamfered (`tip`)); tip?: none|start|both (modelled external threads: start chamfers the end the thread starts from, which must be free, both each free end the thread reaches, after the groove is cut, ISO 4753's chamfered end, the last teeth tapering into the cone; chamfer_angle?: angle expr to the axis, default 45 deg; chamfer_depth?: expr, radial from the major diameter, default for a metric thread down to the external minor diameter d3 = d - 1.226869 P (ISO 724), the largest ISO 4753 allows; other forms give it); extent?: full|length|up_to (default: length when `length` is given, up_to when `up_to` is, else full: the whole face); length?: expr (from the end the thread starts at); up_to?: [x,y,z] (a point, such as on a shoulder face: the thread runs to its place along the axis) | plane name or {origin, normal} (to where the plane crosses the axis); from?: [x,y,z] near the end of the face the thread starts at (default: the face's only free end, the one with no material past it; else the end the `face` point lies within a third of the face of; a pick in the middle of a face whose ends are alike is refused); modeled?: bool (default false). Cosmetic: the model is unchanged, model.threads lists it. Modeled: cuts the thread profile into the body: past a free end the groove runs out a pitch into the air (or through a chamfer); at a shoulder, a head or a blind hole's bottom it stops with its section clear of it, never cutting into it; a shaft thicker than the thread is refused with the size to make it, never turned down"),
.params("face: [x,y,z] on a cylindrical face; form?: metric|trapezoidal|acme|buttress|buttress_asme|bspp|rp|bspt|npt (default: the one `designation` names, else metric; square is refused: no current standard defines it); designation?: the size, as its standard writes it: metric \"M8\", \"M8x1\", \"M16xPh3P1.5\" (ISO 68-1, ISO 261, ISO 965-1); trapezoidal \"Tr20x4\", \"Tr40x14(P7)\" (ISO 2904, ISO 2903); buttress \"S20x4\", \"S40x14(P7)\" (DIN 513, 3°/30°); acme \"1/2-10 ACME\" (ASME B1.5); buttress_asme \"2.5-8 BUTT\" (ASME B1.9, 7°/45°, basic profile; no size table); bspp \"G 1/2\" (ISO 228-1, 55° parallel); rp \"Rp 1/2\" (ISO 7-1's parallel internal thread, 55°, an R screws into it; internal only); bspt \"R 1/2\" external, \"Rc 1/2\" internal (ISO 7-1, 55°, taper 1 in 16); npt \"1/2-14 NPT\" (ASME B1.20.1, 60°, taper 1 in 16) — a taper thread starts at a free end (the pipe end or the hole mouth) with its standard diameter there, and an external one runs its standard length unless `length` or `up_to` says otherwise (default: the standard size that fits the face, a shaft its major diameter, a hole its nominal diameter (a 12 mm hole is M12) or else the size whose tap drill it is); hand?: right|left|both (default right; both: a right- and a left-handed groove crossing); old_auto_size?: bool (an automatic size keeps the rule of designs saved before a hole was sized by its nominal diameter: a 12 mm hole is M14; set on those threads, keeps them as they were when edited); steep_flank?: start|end (buttress only, default end: the steep flank of the screw's teeth faces the thread's end, the way its axis points); starts?: 1..8 (lead = starts x pitch: that many grooves, each a turn's starts-th further round; a designation that gives the lead gives the starts); ease_out?: expr|standard|short (modelled threads: the inner end, away from where the thread starts, fades out over this length (shorter than a turn too), its section moving out of the material as it turns; standard 2.5 P, short 1.25 P per ISO 3508; it lies past the full-form length, up to a shoulder's clearance; at a free end, inside the face; without it the groove stops square there, ending in its own profile; the start never fades: it runs off its free end, plain or chamfered (`tip`)); tip?: none|start|both (modelled external threads: start chamfers the end the thread starts from, which must be free, both each free end the thread reaches, after the groove is cut, ISO 4753's chamfered end, the last teeth tapering into the cone; chamfer_angle?: angle expr to the axis, default 45 deg; chamfer_depth?: expr, radial from the major diameter, default for a metric thread down to the external minor diameter d3 = d - 1.226869 P (ISO 724), the largest ISO 4753 allows; other forms give it); extent?: full|length|up_to (default: length when `length` is given, up_to when `up_to` is, else full: the whole face); length?: expr (from the end the thread starts at); up_to?: [x,y,z] (a point, such as on a shoulder face: the thread runs to its place along the axis) | plane name or {origin, normal} (to where the plane crosses the axis); from?: [x,y,z] near the end of the face the thread starts at (default: the face's only free end, the one with no material past it; else the end the `face` point lies within a third of the face of; a pick in the middle of a face whose ends are alike is refused); modeled?: bool (default false). Cosmetic: the model is unchanged, model.threads lists it. Modeled: cuts the thread profile into the body: past a free end the groove runs out a pitch into the air (or through a chamfer); at a shoulder, a head or a blind hole's bottom it stops with its section clear of it, never cutting into it; a hole as wide as the thread or wider is narrowed to the thread's minor diameter first, and the reply's warning says so; a shaft thicker than the thread is refused with the size to make it, never turned down"),
CommandSpec::new("solid.shell", "Shell", shell)
.at("SOLID", "MODIFY")
.icon("shell")
@@ -3316,6 +3316,7 @@ fn thread(s: &mut Session, p: &Value) -> Result<Value> {
{
return Err(bad(cmd, msg));
}
let designation_is_none = designation.is_none();
let kind = FeatureKind::Thread {
face: FacePick(face),
designation,
@@ -3331,11 +3332,18 @@ fn thread(s: &mut Session, p: &Value) -> Result<Value> {
chamfer_angle,
chamfer_depth,
steep_flank,
// Only a thread saved before holes were sized by nominal diameter, edited by `timeline.redefine`.
old_auto_size: designation_is_none && bool_(p, "old_auto_size").unwrap_or(false),
};
let v = add_feature(s, p, kind)?;
let st = s.model.state();
let t = v.get("feature").and_then(Value::as_u64).and_then(|id| st.threads.iter().find(|t| t.feature == id).cloned());
Ok(json!({"feature": v.get("feature"), "name": v.get("name"), "thread": t}))
let mut reply = json!({"feature": v.get("feature"), "name": v.get("name"), "thread": t});
// A hole narrowed to the thread's minor diameter says so.
if let Some(w) = v.get("warning").filter(|w| !w.is_null()) {
reply["warning"] = w.clone();
}
Ok(reply)
}
fn pipe(s: &mut Session, p: &Value) -> Result<Value> {
+121 -18
View File
@@ -348,7 +348,7 @@ fn modelled_internal_threads_m3_to_m20() {
run(&mut s, "solid.cylinder", json!({"base": [0, 0, -1], "radius": d1 / 2.0, "height": len + 2.0, "body_name": "Bore"}));
run(&mut s, "solid.combine", json!({"target": "Nut", "tools": ["Bore"], "operation": "cut"}));
let before = volume(&mut s, "Nut");
let th = run(&mut s, "solid.thread", json!({"face": [d1 / 2.0, 0, len / 2.0], "modeled": true}));
let th = run(&mut s, "solid.thread", json!({"face": [d1 / 2.0, 0, len / 2.0], "designation": format!("M{d}"), "modeled": true}));
assert!(th["thread"].is_null(), "{th}");
// Bolt-shaped space: P/8 flat at the major diameter, widening towards the bore.
let want = per_turn(d1 / 2.0, d / 2.0, |r| p / 8.0 + 2.0 * (d / 2.0 - r) * slope) * len / p;
@@ -362,14 +362,16 @@ fn modelled_internal_threads_m3_to_m20() {
/// that would cut next to nothing is refused, with the drill to use and the size that fits;
/// a cosmetic one is still only a note.
#[test]
fn a_modelled_thread_that_would_cut_nothing_is_refused() {
fn a_modelled_thread_that_would_cut_nothing_narrows_the_hole_instead() {
// #11609: the hole is narrowed to the thread's minor diameter, and the reply says so.
let mut s = hex_nut(5.0);
let before = volume(&mut s, "Nut");
let e = s.execute("solid.thread", &json!({"face": [2.5, 0, 2], "designation": "M5", "modeled": true})).err().map(|e| e.to_string());
let e = e.unwrap_or_default();
assert!(e.contains("this 5 mm hole") && e.contains("drill 4.2 mm for M5") && e.contains("thread this hole M6"), "{e}");
assert!((volume(&mut s, "Nut") - before).abs() < 1e-9);
run(&mut s, "solid.thread", json!({"face": [2.5, 0, 2], "designation": "M5"}));
let before = volume(&mut s, "Nut");
let made = run(&mut s, "solid.thread", json!({"face": [2.5, 0, 2], "designation": "M5", "modeled": true}));
let warning = s.model.result(made["feature"].as_u64().unwrap()).and_then(|r| r.warning.clone()).unwrap_or_default();
assert!(warning.contains("narrowed the 5 mm hole to 4.1") && warning.contains("M5"), "{warning}");
assert_eq!(made["warning"], json!(warning), "the reply says so too");
assert!(volume(&mut s, "Nut") > before + 1.0);
// A shaft no thicker than the thread's root (17.29 mm for M20) is refused the same way.
let mut s = Session::default();
@@ -401,30 +403,30 @@ fn a_hole_too_narrow_or_a_shaft_too_thick_says_which_and_what_fits() {
}
/// The limit is a quarter of the basic depth 5H/8: a hole up to 4.78 mm for M5 (4.86 mm for
/// M5x0.5) still takes a modelled thread, a wider one is refused with that pitch's drill.
/// M5x0.5) is cut as drilled, a wider one is narrowed to the thread's minor diameter first.
#[test]
fn the_cut_nothing_limit_holds_for_coarse_and_fine_pitch() {
for (m, hole, refused) in [
("M5", 4.5, None),
("M5", 4.75, None),
("M5", 4.8, Some("drill 4.2 mm for M5, or thread this hole M6")),
("M5", 4.8, Some("narrowed the 4.8 mm hole")),
("M5x0.5", 4.5, None),
("M5x0.5", 4.85, None),
("M5x0.5", 4.9, Some("drill 4.5 mm for M5x0.5, or thread this hole M6")),
("M5x0.5", 5.0, Some("drill 4.5 mm for M5x0.5, or thread this hole M6")),
("M5x0.5", 4.9, Some("narrowed the 4.9 mm hole")),
("M5x0.5", 5.0, Some("narrowed the 5 mm hole")),
] {
let mut s = hex_nut(hole);
let before = volume(&mut s, "Nut");
let made = s.execute("solid.thread", &json!({"face": [hole / 2.0, 0, 2], "designation": m, "modeled": true}));
let cut = before - volume(&mut s, "Nut");
match (refused, made) {
(None, Ok(_)) => assert!(cut > 0.05, "{m} in {hole} mm: removed {cut}"),
(Some(want), Err(e)) => {
let e = e.to_string();
assert!(e.contains(&format!("this {hole} mm hole")) && e.contains(want), "{m} in {hole} mm: {e}");
assert!(cut.abs() < 1e-9, "{m} in {hole} mm: removed {cut}");
let warning = made.ok().and_then(|v| v["feature"].as_u64()).and_then(|f| s.model.result(f)).and_then(|r| r.warning.clone());
match (refused, warning) {
(None, None) => assert!(cut > 0.05, "{m} in {hole} mm: removed {cut}"),
(Some(want), Some(w)) => {
assert!(w.contains(want) && w.contains(m), "{m} in {hole} mm: {w}");
assert!(cut < -0.05, "{m} in {hole} mm: the bore was filled in, removed {cut}");
}
(want, got) => panic!("{m} in {hole} mm: want refused {want:?}, got {:?}", got.map(|_| ())),
(want, got) => panic!("{m} in {hole} mm: want narrowed {want:?}, got {got:?}"),
}
}
}
@@ -1291,3 +1293,104 @@ fn a_tapped_hole_given_no_diameter_drills_the_tap_makers_drill() {
assert_eq!(drilled(json!({"position":[25,10,10],"thread":"1/4-20 UNC"})), "5.1054 mm");
assert_eq!(drilled(json!({"position":[33,10,10],"thread":"M8","diameter":"6.9 mm"})), "6.9 mm");
}
/// A block with a bore of `dia` cut through it by a sketch circle.
fn block_with_bore(dia: f64) -> Session {
let mut s = Session::default();
run(&mut s, "solid.box", json!({"corner": [-20, -20, 0], "length": 40, "width": 40, "height": 20, "body_name": "Blk"}));
run(&mut s, "sketch.create", json!({"plane": "XY", "name": "H"}));
run(&mut s, "sketch.circle.center", json!({"center": [0, 0], "diameter": dia}));
run(&mut s, "sketch.finish", json!({}));
run(&mut s, "solid.extrude", json!({"sketch": "H", "through_all": true, "direction": "positive", "operation": "cut"}));
s
}
/// #11609: a 12 mm hole took M14 (the size whose tap drill is 12 mm) and a modelled M12 in it was
/// refused. Automatic sizing now takes the size with the hole's nominal diameter first; a hole
/// near no nominal diameter is still matched by tap drill.
#[test]
fn a_hole_takes_the_size_of_its_nominal_diameter_first() {
for (dia, want) in [(12.0, "M12"), (12.1, "M12"), (10.0, "M10"), (8.0, "M8"), (14.0, "M14"), (10.2, "M12"), (13.0, "M14"), (11.0, "M12")] {
let mut s = block_with_bore(dia);
let th = run(&mut s, "solid.thread", json!({"face": [dia / 2.0, 0, 10]}));
assert_eq!(th["thread"]["designation"], json!(want), "a {dia} mm hole");
}
// A shaft is still its major diameter.
let mut s = Session::default();
run(&mut s, "solid.cylinder", json!({"radius": 6, "height": 30, "body_name": "Sh"}));
let th = run(&mut s, "solid.thread", json!({"face": [6, 0, 15]}));
assert_eq!(th["thread"]["designation"], json!("M12"));
}
/// #11609: M12 modelled in a 12 mm hole narrows the bore to the thread's minor diameter and cuts
/// the thread there, and says so; the cosmetic M12 is the same size on the same bore.
#[test]
fn a_modelled_thread_in_a_hole_as_wide_as_it_narrows_the_bore() {
for (dia, d, p) in [(12.0, 12.0, 1.75), (14.0, 14.0, 2.0), (12.2, 12.0, 1.75), (13.0, 12.0, 1.75)] {
let mut s = block_with_bore(dia);
let before = volume(&mut s, "Blk");
let made = run(&mut s, "solid.thread", json!({"face": [dia / 2.0, 0, 10], "designation": format!("M{d}"), "modeled": true}));
let warning = s.model.result(made["feature"].as_u64().unwrap()).and_then(|r| r.warning.clone()).unwrap_or_default();
assert!(warning.contains("narrowed the") && warning.contains(&format!("M{d}")), "{warning}");
// The bore is now the minor diameter's, so there is material where there was air, but
// less than a full sleeve (the groove cut into it).
let h = p * 3f64.sqrt() / 2.0;
let minor = d - 2.0 * 5.0 * h / 8.0;
let sleeve = PI * ((dia / 2.0).powi(2) - (minor / 2.0).powi(2)) * 20.0;
let added = volume(&mut s, "Blk") - before;
assert!(added > 0.2 * sleeve && added < sleeve, "M{d} in {dia}: added {added}, a full sleeve is {sleeve}");
}
// Automatic and modelled, and cosmetic, on the 12 mm bore.
let mut s = block_with_bore(12.0);
let th = run(&mut s, "solid.thread", json!({"face": [6, 0, 10], "designation": "M12"}));
assert_eq!(th["thread"]["designation"], json!("M12"));
let mut s = block_with_bore(12.0);
let made = run(&mut s, "solid.thread", json!({"face": [6, 0, 10], "modeled": true}));
assert!(s.model.result(made["feature"].as_u64().unwrap()).and_then(|r| r.warning.clone()).unwrap_or_default().contains("M12"));
}
/// A hole that already has the wall for the groove is not narrowed, and a size nowhere near the
/// hole is refused with the size it does take.
#[test]
fn a_hole_with_wall_for_the_groove_is_left_as_drilled() {
let mut s = block_with_bore(10.2);
let made = run(&mut s, "solid.thread", json!({"face": [5.1, 0, 10], "designation": "M12", "modeled": true}));
assert!(s.model.result(made["feature"].as_u64().unwrap()).and_then(|r| r.warning.clone()).is_none());
let mut s = block_with_bore(20.0);
let e = s.execute("solid.thread", &json!({"face": [10, 0, 10], "designation": "M12", "modeled": true})).unwrap_err().to_string();
assert!(e.contains("does not fit a 20.00 mm hole") && e.contains("takes M20"), "{e}");
}
/// #11609: a design saved with an automatic thread keeps the size it had (a 12 mm hole stays
/// M14), while the same thread made now takes M12.
#[test]
fn a_saved_automatic_thread_keeps_its_old_size() {
let mut s = block_with_bore(12.0);
run(&mut s, "solid.thread", json!({"face": [6, 0, 10]}));
let designations = |s: &Session| -> Vec<String> { s.model.state().threads.iter().map(|t| t.designation.clone()).collect() };
assert_eq!(designations(&s), ["M12"]);
// As the release before saved it: the last folded format, none of today's pending changes.
let mut v: Value = serde_json::from_str(&s.doc.to_json()).unwrap();
v["format"] = json!("solidcraft/49");
v.as_object_mut().unwrap().remove("format_pending");
let reopened = Session::new(solidcraft_doc::Document::from_json(&v.to_string()).unwrap());
assert_eq!(designations(&reopened), ["M14"]);
let saved: Value = serde_json::from_str(&reopened.doc.to_json()).unwrap();
let thread = saved["features"].as_array().unwrap().iter().find(|f| f["type"] == json!("thread")).unwrap();
assert_eq!(thread["old_auto_size"], json!(true));
}
/// Editing a saved automatic thread (which keeps its old size) does not change its size.
#[test]
fn editing_a_saved_automatic_thread_keeps_its_old_size() {
let mut s = block_with_bore(12.0);
let made = run(&mut s, "solid.thread", json!({"face": [6, 0, 10]}));
let mut v: Value = serde_json::from_str(&s.doc.to_json()).unwrap();
v["format"] = json!("solidcraft/49");
v.as_object_mut().unwrap().remove("format_pending");
let mut s = Session::new(solidcraft_doc::Document::from_json(&v.to_string()).unwrap());
let designations = |s: &Session| -> Vec<String> { s.model.state().threads.iter().map(|t| t.designation.clone()).collect() };
assert_eq!(designations(&s), ["M14"]);
run(&mut s, "timeline.redefine", json!({"feature": made["feature"], "command": "solid.thread", "params": {"face": [6, 0, 10], "hand": "left"}}));
assert_eq!(designations(&s), ["M14"]);
}
+2
View File
@@ -653,6 +653,8 @@ pub(crate) fn reopen(d: &mut Dialog, s: &Session, kind: &FeatureKind) {
chamfer_angle,
chamfer_depth,
steep_flank,
// Kept by the edit itself (`timeline.redefine`), not a dialog option.
old_auto_size: _,
} = kind
else {
return;
+1 -1
View File
@@ -1518,7 +1518,7 @@ pub(crate) fn thread_face(app: &SolveApp, body: &str) -> Sel {
#[test]
fn thread_size_suggestion_matches_the_feature_for_shafts_and_holes() {
for (diameter, internal, expected) in [(8.0, false, "M8"), (20.0, false, "M20"), (5.0, true, "M6")] {
for (diameter, internal, expected) in [(8.0, false, "M8"), (20.0, false, "M20"), (5.0, true, "M5")] {
let mut app = app_with(json!([]));
if internal {
app.run("solid.box", json!({"corner":[-10,-10,0],"length":20,"width":20,"height":10})).unwrap();
@@ -1,13 +1,32 @@
{
"sources": [
"tangency-labs/solidcraft#1443",
"tangency-labs/solidcraft#3060",
"tangency-labs/solidcraft#1018",
"tangency-labs/solidcraft#2853"
"tangency-labs/solidcraft#11609"
],
"what": "a modelled thread on a hole that isn't the thread's size: refused with the size to use, never a silent change of the hole",
"what": "a modelled M5x0.7 thread in a 5 mm hole, the hole as wide as the thread: the bore is narrowed to the thread's minor diameter and the thread cut into it",
"source": "analytic",
"method": "Decision (#1018, #2853): a modelled thread never changes the size of the hole it is on; one that isn't the thread's size is refused, naming the size to use. A fill-to-tap-drill or turn-down option would be opt-in, off by default (see #3060), and get its own case. The refusal's numbers, from ISO 68-1 (H = P sqrt3/2, basic depth 5H/8): M5x0.7: tap drill = 5 - 0.7 = 4.3 mm; depth 5H/8 = 5/8 x 0.7 x sqrt3/2 = 0.379 mm; the 5 mm hole is at the major diameter, so nothing would be cut. Expected message: \"this 5 mm hole is too wide for a modelled M5x0.7 thread: it would cut 0.00 mm of the thread's 0.38 mm depth; drill 4.3 mm for M5x0.7, or thread this hole M6\".",
"outcome": "refused",
"refusal": "this 5 mm hole is too wide for a modelled M5x0.7 thread: it would cut 0.00 mm of the thread's 0.38 mm depth; drill 4.3 mm for M5x0.7, or thread this hole M6"
"method": "Decision (#11609): a modelled thread in a hole as wide as the thread or wider no longer refuses; the bore is filled in to the thread's minor radius r1 = d/2 - 5H/8 over the threaded length and the groove is cut into that (the feature's warning says so). ISO 68-1 (H = P sqrt3/2, basic depth 5H/8): M5x0.7: P 0.7, 5H/8 = 0.3789 mm, r1 = 2.1211 mm. Internal groove: P/8 wide at the major radius d/2, widening by 2 tan30 per unit of radius to 3P/4 at r1; Pappus gives 1.65166 mm3 per turn (2 pi times the integral of r w(r) dr from r1 to d/2). Both ends free, thread over the full 4.2 mm: V = pi (R^2 - rho^2) L + pi (rho^2 - r1^2) L - (L/P) x V_turn = 577.2653 mm3, with R 7, rho 2.5. COM on the axis at z = L/2. Tolerance 1%: the thread is a faceted helical solid.",
"outcome": "solid",
"body_count": 1,
"volume_mm3": 577.2653,
"center_of_mass": [
0,
0,
2.1
],
"tolerance": {
"rel": 0.01
},
"bbox": {
"min": [
-7,
-7,
0
],
"max": [
7,
7,
4.2
]
}
}
@@ -1,12 +1,32 @@
{
"sources": [
"tangency-labs/solidcraft#2152",
"tangency-labs/solidcraft#1018",
"tangency-labs/solidcraft#2853"
"tangency-labs/solidcraft#11609"
],
"what": "a modelled thread on a hole that isn't the thread's size: refused with the size to use, never a silent change of the hole",
"what": "a modelled M3x0.2 thread in a 3 mm hole, the hole as wide as the thread: the bore is narrowed to the thread's minor diameter and the thread cut into it",
"source": "analytic",
"method": "Decision (#1018, #2853): a modelled thread never changes the size of the hole it is on; one that isn't the thread's size is refused, naming the size to use. A fill-to-tap-drill or turn-down option would be opt-in, off by default (see #3060), and get its own case. The refusal's numbers, from ISO 68-1 (H = P sqrt3/2, basic depth 5H/8): M3x0.2: tap drill = 3 - 0.2 = 2.8 mm; depth 5H/8 = 5/8 x 0.2 x sqrt3/2 = 0.108 mm; the 3 mm hole is at the major diameter. Expected message: \"this 3 mm hole is too wide for a modelled M3x0.2 thread: it would cut 0.00 mm of the thread's 0.11 mm depth; drill 2.8 mm for M3x0.2, or thread this hole M4\".",
"outcome": "refused",
"refusal": "this 3 mm hole is too wide for a modelled M3x0.2 thread: it would cut 0.00 mm of the thread's 0.11 mm depth; drill 2.8 mm for M3x0.2, or thread this hole M4"
"method": "Decision (#11609): a modelled thread in a hole as wide as the thread or wider no longer refuses; the bore is filled in to the thread's minor radius r1 = d/2 - 5H/8 over the threaded length and the groove is cut into that (the feature's warning says so). ISO 68-1 (H = P sqrt3/2, basic depth 5H/8): M3x0.2: P 0.2, 5H/8 = 0.1083 mm, r1 = 1.3917 mm. Internal groove: P/8 wide at the major radius d/2, widening by 2 tan30 per unit of radius to 3P/4 at r1; Pappus gives 0.08528 mm3 per turn (2 pi times the integral of r w(r) dr from r1 to d/2). Both ends free, thread over the full 2 mm: V = pi (R^2 - rho^2) L + pi (rho^2 - r1^2) L - (L/P) x V_turn = 144.0565 mm3, with R 5, rho 1.5. COM on the axis at z = L/2. Tolerance 1%: the thread is a faceted helical solid.",
"outcome": "solid",
"body_count": 1,
"volume_mm3": 144.0565,
"center_of_mass": [
0,
0,
1.0
],
"tolerance": {
"rel": 0.01
},
"bbox": {
"min": [
-5,
-5,
0
],
"max": [
5,
5,
2
]
}
}
@@ -1,12 +1,32 @@
{
"sources": [
"tangency-labs/solidcraft#2969",
"tangency-labs/solidcraft#1018",
"tangency-labs/solidcraft#2853"
"tangency-labs/solidcraft#11609"
],
"what": "a modelled thread on a hole that isn't the thread's size: refused with the size to use, never a silent change of the hole",
"what": "a modelled M48x0.75 thread in a 48 mm hole, the hole as wide as the thread: the bore is narrowed to the thread's minor diameter and the thread cut into it",
"source": "analytic",
"method": "Decision (#1018, #2853): a modelled thread never changes the size of the hole it is on; one that isn't the thread's size is refused, naming the size to use. A fill-to-tap-drill or turn-down option would be opt-in, off by default (see #3060), and get its own case. The refusal's numbers, from ISO 68-1 (H = P sqrt3/2, basic depth 5H/8): M48x0.75: tap drill = 48 - 0.75 = 47.25 mm; depth 5H/8 = 5/8 x 0.75 x sqrt3/2 = 0.406 mm; the 48 mm hole is at the major diameter. Expected message: \"this 48 mm hole is too wide for a modelled M48x0.75 thread: it would cut 0.00 mm of the thread's 0.41 mm depth; drill 47.25 mm for M48x0.75, or thread this hole M56\".",
"outcome": "refused",
"refusal": "this 48 mm hole is too wide for a modelled M48x0.75 thread: it would cut 0.00 mm of the thread's 0.41 mm depth; drill 47.25 mm for M48x0.75, or thread this hole M56"
"method": "Decision (#11609): a modelled thread in a hole as wide as the thread or wider no longer refuses; the bore is filled in to the thread's minor radius r1 = d/2 - 5H/8 over the threaded length and the groove is cut into that (the feature's warning says so). ISO 68-1 (H = P sqrt3/2, basic depth 5H/8): M48x0.75: P 0.75, 5H/8 = 0.4059 mm, r1 = 23.5941 mm. Internal groove: P/8 wide at the major radius d/2, widening by 2 tan30 per unit of radius to 3P/4 at r1; Pappus gives 19.87609 mm3 per turn (2 pi times the integral of r w(r) dr from r1 to d/2). Both ends free, thread over the full 3 mm: V = pi (R^2 - rho^2) L + pi (rho^2 - r1^2) L - (L/P) x V_turn = 1544.5807 mm3, with R 27, rho 24. COM on the axis at z = L/2. Tolerance 1%: the thread is a faceted helical solid.",
"outcome": "solid",
"body_count": 1,
"volume_mm3": 1544.5807,
"center_of_mass": [
0,
0,
1.5
],
"tolerance": {
"rel": 0.01
},
"bbox": {
"min": [
-27,
-27,
0
],
"max": [
27,
27,
3
]
}
}
@@ -1,13 +1,32 @@
{
"sources": [
"tangency-labs/solidcraft#3366",
"tangency-labs/solidcraft#3367",
"tangency-labs/solidcraft#1018",
"tangency-labs/solidcraft#2853"
"tangency-labs/solidcraft#11609"
],
"what": "a modelled thread on a hole that isn't the thread's size: refused with the size to use, never a silent change of the hole",
"what": "a modelled M20 thread in a 20 mm hole, the hole as wide as the thread: the bore is narrowed to the thread's minor diameter and the thread cut into it",
"source": "analytic",
"method": "Decision (#1018, #2853): a modelled thread never changes the size of the hole it is on; one that isn't the thread's size is refused, naming the size to use. A fill-to-tap-drill or turn-down option would be opt-in, off by default (see #3060), and get its own case. The refusal's numbers, from ISO 68-1 (H = P sqrt3/2, basic depth 5H/8): M20 (P 2.5): tap drill = 20 - 2.5 = 17.5 mm; depth 5H/8 = 5/8 x 2.5 x sqrt3/2 = 1.353 mm; the 20 mm hole is at the major diameter. Expected message: \"this 20 mm hole is too wide for a modelled M20 thread: it would cut 0.00 mm of the thread's 1.35 mm depth; drill 17.5 mm for M20, or thread this hole M22\".",
"outcome": "refused",
"refusal": "this 20 mm hole is too wide for a modelled M20 thread: it would cut 0.00 mm of the thread's 1.35 mm depth; drill 17.5 mm for M20, or thread this hole M22"
"method": "Decision (#11609): a modelled thread in a hole as wide as the thread or wider no longer refuses; the bore is filled in to the thread's minor radius r1 = d/2 - 5H/8 over the threaded length and the groove is cut into that (the feature's warning says so). ISO 68-1 (H = P sqrt3/2, basic depth 5H/8): M20: P 2.5, 5H/8 = 1.3532 mm, r1 = 8.6468 mm. Internal groove: P/8 wide at the major radius d/2, widening by 2 tan30 per unit of radius to 3P/4 at r1; Pappus gives 85.20290 mm3 per turn (2 pi times the integral of r w(r) dr from r1 to d/2). Both ends free, thread over the full 10 mm: V = pi (R^2 - rho^2) L + pi (rho^2 - r1^2) L - (L/P) x V_turn = 15405.8636 mm3, with R 24, rho 10. COM on the axis at z = L/2. Tolerance 1%: the thread is a faceted helical solid.",
"outcome": "solid",
"body_count": 1,
"volume_mm3": 15405.8636,
"center_of_mass": [
0,
0,
5.0
],
"tolerance": {
"rel": 0.01
},
"bbox": {
"min": [
-24,
-24,
0
],
"max": [
24,
24,
10
]
}
}
@@ -1,12 +1,32 @@
{
"sources": [
"tangency-labs/solidcraft#995",
"tangency-labs/solidcraft#1018",
"tangency-labs/solidcraft#2853"
"tangency-labs/solidcraft#11609"
],
"what": "a modelled thread on a hole that isn't the thread's size: refused with the size to use, never a silent change of the hole",
"what": "a modelled M5 thread in a 5 mm hole, the hole as wide as the thread: the bore is narrowed to the thread's minor diameter and the thread cut into it",
"source": "analytic",
"method": "Decision (#1018, #2853): a modelled thread never changes the size of the hole it is on; one that isn't the thread's size is refused, naming the size to use. A fill-to-tap-drill or turn-down option would be opt-in, off by default (see #3060), and get its own case. The refusal's numbers, from ISO 68-1 (H = P sqrt3/2, basic depth 5H/8): M5 (P 0.8): tap drill = 5 - 0.8 = 4.2 mm; basic depth 5H/8 = 5/8 x 0.8 x sqrt3/2 = 0.433 mm; a 5 mm hole is at the major diameter, so the internal thread (major d, minor d - 2 x 5H/8) cuts 0.00 mm. Expected message: \"this 5 mm hole is too wide for a modelled M5 thread: it would cut 0.00 mm of the thread's 0.43 mm depth; drill 4.2 mm for M5, or thread this hole M6\".",
"outcome": "refused",
"refusal": "this 5 mm hole is too wide for a modelled M5 thread: it would cut 0.00 mm of the thread's 0.43 mm depth; drill 4.2 mm for M5, or thread this hole M6"
"method": "Decision (#11609): a modelled thread in a hole as wide as the thread or wider no longer refuses; the bore is filled in to the thread's minor radius r1 = d/2 - 5H/8 over the threaded length and the groove is cut into that (the feature's warning says so). ISO 68-1 (H = P sqrt3/2, basic depth 5H/8): M5: P 0.8, 5H/8 = 0.4330 mm, r1 = 2.0670 mm. Internal groove: P/8 wide at the major radius d/2, widening by 2 tan30 per unit of radius to 3P/4 at r1; Pappus gives 2.12536 mm3 per turn (2 pi times the integral of r w(r) dr from r1 to d/2). Both ends free, thread over the full 4 mm: V = pi (R^2 - rho^2) L + pi (rho^2 - r1^2) L - (L/P) x V_turn = 551.4364 mm3, with R 7, rho 2.5. COM on the axis at z = L/2. Tolerance 1%: the thread is a faceted helical solid.",
"outcome": "solid",
"body_count": 1,
"volume_mm3": 551.4364,
"center_of_mass": [
0,
0,
2.0
],
"tolerance": {
"rel": 0.01
},
"bbox": {
"min": [
-7,
-7,
0
],
"max": [
7,
7,
4
]
}
}