Wave 451/509: Preferences: symmetric surface extrudes read only the total distance (and 3 more)

4 commits, squashed; the originals stay reachable from tag archive/merge-main-develop.

- 2ae53d387 jyviko: Preferences: metric tapped holes drill only the tap maker's drill
- a71450aeb jyviko: Preferences: symmetric surface extrudes read only the total distance
- 26b42048c jyviko: Preferences: the Body check note says each option in one short line
- 2c1901371 jyviko: kernel: the record test takes the one wall a circle of arcs extrudes to

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ
This commit is contained in:
jyviko
2026-10-30 16:03:31 -04:00
parent bc93a653f6
commit 5fa7a8497c
19 changed files with 70 additions and 237 deletions
@@ -1,30 +0,0 @@
{
"en": {
"prefs.surface_extrude_symmetric_per_side": "Symmetric surface extrudes go the distance each way (10 mm: 20 mm in all), as before, not the total like solid extrudes",
"prefs.surfaces": "Surfaces"
},
"ar": {
"prefs.surface_extrude_symmetric_per_side": "يمتد بثق السطح المتماثل بالمسافة في كل جانب كما كان من قبل (10 مم: 20 مم إجمالًا)، لا بالمسافة الكلية كبثق المجسم",
"prefs.surfaces": "الأسطح"
},
"he": {
"prefs.surface_extrude_symmetric_per_side": "שליפת משטח סימטרית נשלפת את המרחק לכל צד כמו קודם (10 מ\"מ: 20 מ\"מ בסך הכול), ולא את המרחק הכולל כמו שליפת גוף",
"prefs.surfaces": "משטחים"
},
"ja": {
"prefs.surface_extrude_symmetric_per_side": "対称のサーフェス押し出しを、ソリッドの押し出しのような合計ではなく、以前のように両側にそれぞれその距離だけ押し出す(10 mm: 合計 20 mm)",
"prefs.surfaces": "サーフェス"
},
"zh": {
"prefs.surface_extrude_symmetric_per_side": "对称曲面拉伸像以前一样向两侧各拉伸该距离(10 mm:共 20 mm),而非像实体拉伸那样取总距离",
"prefs.surfaces": "曲面"
},
"de": {
"prefs.surface_extrude_symmetric_per_side": "Symmetrische Flächen-Extrusionen wie bisher um den Abstand nach jeder Seite (10 mm: insgesamt 20 mm), nicht um die Gesamtlänge wie Volumen-Extrusionen",
"prefs.surfaces": "Flächen"
},
"ko": {
"prefs.surface_extrude_symmetric_per_side": "대칭 서피스 돌출을 솔리드 돌출처럼 전체 거리가 아니라 이전처럼 양쪽으로 각각 그 거리만큼 돌출 (10 mm: 총 20 mm)",
"prefs.surfaces": "서피스"
}
}
-14
View File
@@ -1,49 +1,35 @@
{
"en": {
"prefs.holes": "Holes",
"prefs.metric_tap_drill_major_less_pitch": "Metric tapped holes drill the major diameter less the pitch (M8: 6.75 mm), not the tap maker's drill",
"thread.drill_range": "The tap maker's drill is {drill} mm. The internal thread's standard minor diameter is {minor} mm. A drill from {low} to {high} mm is accepted.",
"thread.drill_range_custom": "The drill is the major diameter less the pitch, {drill} mm. The internal thread's standard minor diameter is {minor} mm. A drill from {low} to {high} mm is accepted.",
"thread.drill_range_taper": "The tap maker's drill is {drill} mm. The standard's minor diameter where the thread ends is {minor} mm. A drill from {low} to {high} mm is accepted."
},
"ar": {
"prefs.holes": "الثقوب",
"prefs.metric_tap_drill_major_less_pitch": "تُثقب الثقوب الملولبة المترية بالقطر الأكبر ناقص الخطوة (M8: 6.75 مم) بدل مثقاب صانع اللقمة",
"thread.drill_range": "مثقاب صانع اللقمة {drill} مم. القطر الأصغر القياسي للسن الداخلي {minor} مم. يُقبل مثقاب من {low} إلى {high} مم.",
"thread.drill_range_custom": "المثقاب هو القطر الأكبر ناقص الخطوة، {drill} مم. القطر الأصغر القياسي للسن الداخلي {minor} مم. يُقبل مثقاب من {low} إلى {high} مم.",
"thread.drill_range_taper": "مثقاب صانع اللقمة {drill} مم. القطر الأصغر القياسي عند نهاية السن {minor} مم. يُقبل مثقاب من {low} إلى {high} مم."
},
"he": {
"prefs.holes": "חורים",
"prefs.metric_tap_drill_major_less_pitch": "חורים מתוברגים מטריים נקדחים בקוטר הגדול פחות הפסיעה (M8: 6.75 מ\"מ) ולא במקדח של יצרן המברז",
"thread.drill_range": "מקדח יצרן המברז הוא {drill} מ\"מ. הקוטר הקטן התקני של התבריג הפנימי הוא {minor} מ\"מ. מתקבל מקדח מ-{low} עד {high} מ\"מ.",
"thread.drill_range_custom": "המקדח הוא הקוטר הגדול פחות הפסיעה, {drill} מ\"מ. הקוטר הקטן התקני של התבריג הפנימי הוא {minor} מ\"מ. מתקבל מקדח מ-{low} עד {high} מ\"מ.",
"thread.drill_range_taper": "מקדח יצרן המברז הוא {drill} מ\"מ. הקוטר הקטן התקני בסוף התבריג הוא {minor} מ\"מ. מתקבל מקדח מ-{low} עד {high} מ\"מ."
},
"ja": {
"prefs.holes": "穴",
"prefs.metric_tap_drill_major_less_pitch": "メートルねじ穴の下穴を、タップメーカーの推奨値ではなく外径からピッチを引いた値にする(M8: 6.75 mm)",
"thread.drill_range": "タップメーカーの下穴ドリルは {drill} mm です。めねじの規格の内径は {minor} mm です。{low}~{high} mm のドリルを使用できます。",
"thread.drill_range_custom": "下穴ドリルは外径からピッチを引いた {drill} mm です。めねじの規格の内径は {minor} mm です。{low}~{high} mm のドリルを使用できます。",
"thread.drill_range_taper": "タップメーカーの下穴ドリルは {drill} mm です。ねじ終端での規格の内径は {minor} mm です。{low}~{high} mm のドリルを使用できます。"
},
"zh": {
"prefs.holes": "孔",
"prefs.metric_tap_drill_major_less_pitch": "公制螺纹孔的底孔取大径减螺距(M8:6.75 mm),而非丝锥制造商的钻头",
"thread.drill_range": "丝锥制造商的钻头为 {drill} mm。内螺纹的标准小径为 {minor} mm。可使用 {low} 至 {high} mm 的钻头。",
"thread.drill_range_custom": "钻头为大径减螺距,{drill} mm。内螺纹的标准小径为 {minor} mm。可使用 {low} 至 {high} mm 的钻头。",
"thread.drill_range_taper": "丝锥制造商的钻头为 {drill} mm。螺纹终端处的标准小径为 {minor} mm。可使用 {low} 至 {high} mm 的钻头。"
},
"de": {
"prefs.holes": "Bohrungen",
"prefs.metric_tap_drill_major_less_pitch": "Metrische Gewindebohrungen mit Nenndurchmesser minus Steigung bohren (M8: 6,75 mm), nicht mit dem Bohrer des Gewindebohrerherstellers",
"thread.drill_range": "Der Bohrer des Gewindebohrerherstellers ist {drill} mm. Der genormte Kerndurchmesser des Innengewindes ist {minor} mm. Ein Bohrer von {low} bis {high} mm wird angenommen.",
"thread.drill_range_custom": "Der Bohrer ist der Nenndurchmesser minus Steigung, {drill} mm. Der genormte Kerndurchmesser des Innengewindes ist {minor} mm. Ein Bohrer von {low} bis {high} mm wird angenommen.",
"thread.drill_range_taper": "Der Bohrer des Gewindebohrerherstellers ist {drill} mm. Der genormte Kerndurchmesser am Gewindeende ist {minor} mm. Ein Bohrer von {low} bis {high} mm wird angenommen."
},
"ko": {
"prefs.holes": "구멍",
"prefs.metric_tap_drill_major_less_pitch": "미터 탭 구멍을 탭 제조사의 드릴 대신 바깥지름에서 피치를 뺀 값으로 뚫기 (M8: 6.75 mm)",
"thread.drill_range": "탭 제조사의 드릴은 {drill} mm입니다. 암나사의 규격 골지름은 {minor} mm입니다. {low}~{high} mm 드릴을 사용할 수 있습니다.",
"thread.drill_range_custom": "드릴은 바깥지름에서 피치를 뺀 {drill} mm입니다. 암나사의 규격 골지름은 {minor} mm입니다. {low}~{high} mm 드릴을 사용할 수 있습니다.",
"thread.drill_range_taper": "탭 제조사의 드릴은 {drill} mm입니다. 나사 끝에서의 규격 골지름은 {minor} mm입니다. {low}~{high} mm 드릴을 사용할 수 있습니다."
@@ -6,7 +6,7 @@
"prefs.validation.each_step": "بعد كل خطوة",
"prefs.validation.label": "فحص النواة الكامل",
"prefs.validation.off": "متوقف (تجريبي)",
"prefs.validation_note": "مرة لكل ميزة: تُفحص الأجسام التي تنتجها الميزة مرة واحدة قبل الاحتفاظ بها، وتفشل الميزة إذا رُفض أحدها. بعد كل خطوة: يُفحص ناتج كل عملية سحب ودمج وتقويس، كما في السابق. متوقف: لا فحص، فقد يُحتفظ بجسم معيب."
"prefs.validation_note": "بعد كل خطوة: يفحص كل عملية سحب ودمج وتقويس.\nمرة لكل ميزة: يفحص ناتج كل ميزة مرة واحدة.\nمتوقف (تجريبي): لا فحص."
},
"de": {
"cmd.diagnostics_validation": "Prüfung",
@@ -15,7 +15,7 @@
"prefs.validation.each_step": "Nach jedem Schritt",
"prefs.validation.label": "Vollständige Kernel-Prüfung",
"prefs.validation.off": "Aus (experimentell)",
"prefs.validation_note": "Einmal je Feature: Die Körper, die ein Feature erzeugt, werden einmal geprüft, bevor sie übernommen werden; wird einer abgelehnt, schlägt das Feature fehl. Nach jedem Schritt: Das Ergebnis jedes Sweeps, jeder Boolesche Operation und jeder Rundung wird geprüft, wie bisher. Aus: keine Prüfung, ein fehlerhafter Körper kann bleiben."
"prefs.validation_note": "Nach jedem Schritt: prüft jeden Sweep, jede Boolesche Operation und jede Rundung.\nEinmal je Feature: prüft das Ergebnis jedes Features einmal.\nAus (experimentell): keine Prüfung."
},
"en": {
"cmd.diagnostics_validation": "Validation",
@@ -24,7 +24,7 @@
"prefs.validation.each_step": "After every step",
"prefs.validation.label": "Full kernel check",
"prefs.validation.off": "Off (experimental)",
"prefs.validation_note": "Once per feature: the bodies a feature makes are checked once before they are kept, and the feature fails if one is refused. After every step: the result of every sweep, boolean and blend is checked, as before. Off: no check, so a faulty body can be kept."
"prefs.validation_note": "After every step: checks each sweep, boolean and blend.\nOnce per feature: checks each feature's result once.\nOff (experimental): no check."
},
"he": {
"cmd.diagnostics_validation": "אימות",
@@ -33,7 +33,7 @@
"prefs.validation.each_step": "אחרי כל שלב",
"prefs.validation.label": "הבדיקה המלאה של הקרנל",
"prefs.validation.off": "כבוי (ניסיוני)",
"prefs.validation_note": "פעם אחת לכל תכונה: הגופים שתכונה יוצרת נבדקים פעם אחת לפני שהם נשמרים, והתכונה נכשלת אם אחד מהם נדחה. אחרי כל שלב: התוצאה של כל סחיפה, פעולה בוליאנית ועיגול נבדקת, כמו קודם. כבוי: אין בדיקה, ולכן גוף פגום עלול להישמר."
"prefs.validation_note": "אחרי כל שלב: בודק כל סחיפה, פעולה בוליאנית ועיגול.\nפעם אחת לכל תכונה: בודק את התוצאה של כל תכונה פעם אחת.\nכבוי (ניסיוני): אין בדיקה."
},
"ja": {
"cmd.diagnostics_validation": "検証",
@@ -42,7 +42,7 @@
"prefs.validation.each_step": "各ステップの後",
"prefs.validation.label": "カーネルの完全チェック",
"prefs.validation.off": "オフ (試験的)",
"prefs.validation_note": "フィーチャーごとに 1 回: フィーチャーが作るボディを保持する前に 1 回チェックし、拒否されたものがあればフィーチャーは失敗します。各ステップの後: これまでどおり、スイープ、ブーリアン、ブレンドのたびに結果をチェックします。オフ: チェックしないため、不正なボディが残ることがあります。"
"prefs.validation_note": "各ステップの後: スイープ、ブーリアン、ブレンドのたびにチェックします。\nフィーチャーごとに 1 回: 各フィーチャーの結果を 1 回チェックします。\nオフ (試験的): チェックしません。"
},
"ko": {
"cmd.diagnostics_validation": "검증",
@@ -51,7 +51,7 @@
"prefs.validation.each_step": "모든 단계 후",
"prefs.validation.label": "커널 전체 검사",
"prefs.validation.off": "끄기 (실험적)",
"prefs.validation_note": "피처마다 한 번: 피처가 만든 바디를 유지하기 전에 한 번 검사하며, 하나라도 거부되면 피처가 실패합니다. 모든 단계 후: 이전처럼 스윕, 불리언, 블렌드마다 결과를 검사합니다. 끄기: 검사하지 않으므로 결함 있는 바디가 남을 수 있습니다."
"prefs.validation_note": "모든 단계 후: 스윕, 불리언, 블렌드마다 검사합니다.\n피처마다 한 번: 각 피처의 결과를 한 번 검사합니다.\n끄기 (실험적): 검사하지 않습니다."
},
"zh": {
"cmd.diagnostics_validation": "验证",
@@ -60,6 +60,6 @@
"prefs.validation.each_step": "每一步之后",
"prefs.validation.label": "内核完整检查",
"prefs.validation.off": "关闭(实验性)",
"prefs.validation_note": "每个特征一次:特征生成的实体在保留前检查一次,若有实体被拒绝,该特征失败。每一步之后:与以前一样,每次扫掠、布尔运算和倒圆后都检查结果。关闭:不检查,因此可能保留有缺陷的实体。"
"prefs.validation_note": "每一步之后:检查每次扫掠、布尔运算和倒圆。\n每个特征一次:每个特征的结果检查一次。\n关闭(实验性):不检查。"
}
}
-10
View File
@@ -485,16 +485,6 @@ impl TappedThread {
(self.minor_diameter().min(self.tap_drill), self.tap_drill * (1.0 + DRILL_ALLOWANCE))
}
/// The drill a new hole of this size takes without a `diameter`: the tap maker's, or for an
/// ISO metric size with `major_less_pitch` (the preference that keeps the drill every metric
/// size took before) the major diameter less the pitch, to the micrometre.
pub fn default_drill(&self, major_less_pitch: bool) -> f64 {
match (self.family, major_less_pitch) {
(TappedThreadFamily::Metric, true) => ((self.major_diameter - self.pitch) * 1000.0).round() / 1000.0,
_ => self.tap_drill,
}
}
/// Whether a hole of `diameter` mm can be tapped to this size; the error names the range.
pub fn check_drill(&self, diameter: f64) -> Result<(), String> {
let (lo, hi) = self.drill_range();
+2 -3
View File
@@ -1051,14 +1051,13 @@ fn edit_feature(s: &mut Session, p: &Value) -> Result<Value> {
nf.id = f.id;
// A one-sided extrude made symmetric takes the convention a new one would: its old marker
// never read a symmetric distance.
let maker = if matches!(f.kind, FeatureKind::SurfaceExtrude { .. }) { "surface.extrude" } else { "solid.extrude" };
if let (FeatureKind::Extrude { extent: old, .. }, FeatureKind::Extrude { extent: new, .. })
| (FeatureKind::SurfaceExtrude { extent: old, .. }, FeatureKind::SurfaceExtrude { extent: new, .. }) = (&f.kind, &mut nf.kind)
&& old.direction != solidcraft_doc::Direction::Symmetric
&& new.direction == solidcraft_doc::Direction::Symmetric
&& set.get("extent").and_then(|e| e.get("convention")).is_none()
{
new.convention = super::features::default_extrude_convention(s, maker);
new.convention = solidcraft_doc::ExtrudeConvention::TotalDistance;
}
if std::mem::discriminant(&nf.kind) != std::mem::discriminant(&f.kind) {
return Err(bad(cmd, "the feature type cannot change"));
@@ -1419,7 +1418,7 @@ fn redefine(s: &mut Session, p: &Value) -> Result<Value> {
let convention = if extent.direction == solidcraft_doc::Direction::Symmetric {
extent.convention
} else {
super::features::default_extrude_convention(s, cid)
solidcraft_doc::ExtrudeConvention::TotalDistance
};
parameters.entry("convention").or_insert_with(|| json!(convention));
}
@@ -193,34 +193,6 @@ fn older_symmetric_surface_extrudes_keep_the_distance_on_each_side() {
}
}
/// The preference brings back the per-side reading for new surface extrudes only: solid
/// extrudes and an explicit `convention` are unchanged by it.
#[test]
fn the_per_side_preference_keeps_the_older_surface_extrude_reading() {
let mut s = fixture(json!({}));
s.surface_extrude_symmetric_per_side = true;
run(&mut s, "surface.extrude", json!({"sketch":"Square","distance":"10 mm","direction":"symmetric","name":"Sheet","body_name":"Sheet"}));
assert_z(&s, "Sheet", -10.0, 10.0);
let FeatureKind::SurfaceExtrude { extent, .. } = &s.doc.find_feature("Sheet").unwrap().kind else { panic!("surface extrude") };
assert_eq!(extent.convention, ExtrudeConvention::LegacyPerSide);
run(
&mut s,
"surface.extrude",
json!({"sketch":"Square","distance":"10 mm","direction":"symmetric","convention":"total_distance","name":"Total","body_name":"Total"}),
);
assert_z(&s, "Total", -5.0, 5.0);
run(&mut s, "solid.extrude", json!({"sketch":"Square","distance":"10 mm","direction":"symmetric","operation":"new","body_name":"Solid"}));
assert_z(&s, "Solid", -5.0, 5.0);
// The saved marker, not the preference, decides on reopening.
s.surface_extrude_symmetric_per_side = false;
let reopened = Session::new(Document::from_json(&s.doc.to_json()).unwrap());
assert_z(&reopened, "Sheet", -10.0, 10.0);
// A design opened or started keeps the user's choice.
s.surface_extrude_symmetric_per_side = true;
s.replace_design(Session::default());
assert!(s.surface_extrude_symmetric_per_side);
}
/// A second distance goes the other way from the first side (#2700): along the normal when the
/// first side goes against it, whether by `direction: negative` or by a negative distance.
#[test]
+4 -14
View File
@@ -1120,18 +1120,6 @@ fn thin_regions(s: &Session, ss: &solidcraft_doc::SolvedSketch, thin: &ThinWall)
solidcraft_sketch::thin_wall_regions(&curves, inside, outside).map_err(|e| format!("thin wall: {e}"))
}
/// How a new extent of `cmd` (`solid.extrude` or `surface.extrude`) reads a symmetric distance
/// when the call doesn't say: the total, split evenly around the start plane, for both. A surface
/// extrude reads it on each side, as surface extrudes did before, while the user's preference
/// says so ([`Session::surface_extrude_symmetric_per_side`]).
pub(crate) fn default_extrude_convention(s: &Session, cmd: &str) -> solidcraft_doc::ExtrudeConvention {
if cmd == "surface.extrude" && s.surface_extrude_symmetric_per_side {
solidcraft_doc::ExtrudeConvention::LegacyPerSide
} else {
solidcraft_doc::ExtrudeConvention::TotalDistance
}
}
/// An extrude's extent from its parameters: distance (or through all, or to an object), the
/// side(s), a second distance, a start offset, a taper, and from an object.
pub(super) fn extent_param(s: &Session, p: &Value, cmd: &str) -> Result<Extent> {
@@ -1167,8 +1155,10 @@ pub(super) fn extent_param(s: &Session, p: &Value, cmd: &str) -> Result<Extent>
if let Some(d) = &start_offset {
check_expr(s, d, Kind::Length, cmd, "start_offset")?;
}
// A symmetric distance the call doesn't qualify is the total, split evenly around the start
// plane, for solid and surface extrudes alike.
let convention = match p.get("convention") {
None => default_extrude_convention(s, cmd),
None => solidcraft_doc::ExtrudeConvention::TotalDistance,
Some(value) => serde_json::from_value(value.clone()).map_err(|_| bad(cmd, "`convention` must be total_distance or legacy_per_side"))?,
};
Ok(Extent {
@@ -2551,7 +2541,7 @@ fn hole(s: &mut Session, p: &Value) -> Result<Value> {
}
(None, Some(t), None) => {
let size = solidcraft_doc::parse_tapped_thread(t).ok_or_else(|| bad(cmd, "thread"))?;
Expr::new(format!("{} mm", size.default_drill(s.metric_tap_drill_major_less_pitch)))
Expr::new(format!("{} mm", size.tap_drill))
}
(None, None, None) => return Err(bad(cmd, "needs `diameter`, `thread` (a tapped hole) or `clearance` (a bolt size)")),
};
+1 -1
View File
@@ -39,7 +39,7 @@ pub static COMMANDS: &[CommandSpec] = &[
CommandSpec::new("surface.extrude", "Surface Extrude", surface_extrude)
.at("SURFACE", "CREATE")
.icon("surface_extrude")
.params("sketch?: id|name; curves?: [curve ids] (open or closed chains of curves meeting end to end) and/or profiles? (their boundaries; the default when no curves are given); distance: expr; direction?: positive|negative|symmetric (symmetric: distance is the total, split evenly around the start plane, as solid.extrude); convention?: total_distance|legacy_per_side (as solid.extrude; default total_distance, or legacy_per_side, the distance on each side, under the user's preference for the older reading); distance2?: expr; start_offset?: expr; name?, body_name? (a surface body: walls only, no caps)"),
.params("sketch?: id|name; curves?: [curve ids] (open or closed chains of curves meeting end to end) and/or profiles? (their boundaries; the default when no curves are given); distance: expr; direction?: positive|negative|symmetric (symmetric: distance is the total, split evenly around the start plane, as solid.extrude); convention?: total_distance|legacy_per_side (as solid.extrude; default total_distance; legacy_per_side: the distance on each side, as older symmetric surface extrudes keep); distance2?: expr; start_offset?: expr; name?, body_name? (a surface body: walls only, no caps)"),
CommandSpec::new("surface.revolve", "Surface Revolve", surface_revolve)
.at("SURFACE", "CREATE")
.icon("surface_revolve")
-15
View File
@@ -377,13 +377,6 @@ pub struct Session {
pub(crate) followed: Option<cmd::inspect::Followed>,
/// Project a face's edges into a sketch created on it (the default; `sketch.auto_project`).
pub auto_project: bool,
/// A new metric tapped hole given no `diameter` drills the major diameter less the pitch,
/// as before the tap maker's drills (a user preference); false: the tap maker's drill.
pub metric_tap_drill_major_less_pitch: bool,
/// A new symmetric surface extrude given no `convention` reads its distance on each side, as
/// surface extrudes did before they matched solid ones (a user preference); false: the total,
/// split evenly around the start plane, as a solid extrude reads it.
pub surface_extrude_symmetric_per_side: bool,
/// How calls that break a command's parameter contract are treated (off by default). It
/// belongs to the session, not the design, so it survives opening and starting designs.
pub param_check: schema::ParamCheck,
@@ -651,8 +644,6 @@ impl Session {
document_id: cmd::inspect::new_document_id(),
followed: None,
auto_project: true,
metric_tap_drill_major_less_pitch: false,
surface_extrude_symmetric_per_side: false,
param_check: schema::ParamCheck::Off,
easyprint_upload: None,
live_links: None,
@@ -702,8 +693,6 @@ impl Session {
pub fn replace_design(&mut self, fresh: Session) {
let auto_project = self.auto_project;
let validation = self.validation();
let metric_tap_drill_major_less_pitch = self.metric_tap_drill_major_less_pitch;
let surface_extrude_symmetric_per_side = self.surface_extrude_symmetric_per_side;
let param_check = self.param_check;
let easyprint_upload = self.easyprint_upload.take();
let render_viewport = self.render_viewport.clone();
@@ -722,8 +711,6 @@ impl Session {
// The user's, like `auto_project`: the commands that open a design evaluate it under it
// already (`Session::opened_validating`).
self.set_validation(validation);
self.metric_tap_drill_major_less_pitch = metric_tap_drill_major_less_pitch;
self.surface_extrude_symmetric_per_side = surface_extrude_symmetric_per_side;
self.param_check = param_check;
self.easyprint_upload = easyprint_upload;
self.render_viewport = render_viewport;
@@ -1480,8 +1467,6 @@ impl Session {
document_id: self.document_id.clone(),
followed: None,
auto_project: self.auto_project,
metric_tap_drill_major_less_pitch: self.metric_tap_drill_major_less_pitch,
surface_extrude_symmetric_per_side: self.surface_extrude_symmetric_per_side,
param_check: self.param_check,
easyprint_upload: self.easyprint_upload.clone(),
live_links: None,
+18
View File
@@ -1268,3 +1268,21 @@ fn a_modelled_tapped_hole_stops_clear_of_its_bottom_or_fades_out_before_it() {
assert!(drill(6.5).contains("the tap cannot cut"));
assert!(drill(7.1).is_empty() && drill(6.7).is_empty(), "inside the range");
}
/// A tapped hole given no `diameter` drills the tap maker's drill for its size (M8: 6.8 mm, 1/4-20
/// UNC: 5.1054 mm); a given diameter is kept.
#[test]
fn a_tapped_hole_given_no_diameter_drills_the_tap_makers_drill() {
let mut s = Session::default();
run(&mut s, "solid.box", json!({"length":40,"width":20,"height":10,"body_name":"Plate"}));
let mut drilled = |p: Value| {
let id = run(&mut s, "solid.hole", p)["feature"].as_u64().unwrap();
match &s.doc.feature(id).unwrap().kind {
solidcraft_doc::FeatureKind::Hole { diameter, .. } => diameter.to_string(),
k => panic!("{k:?}"),
}
};
assert_eq!(drilled(json!({"position":[10,10,10],"thread":"M8"})), "6.8 mm");
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");
}
+21 -5
View File
@@ -49,7 +49,9 @@ fn mesh_points(b: &Body) -> (Vec<Vec<Vec3>>, Vec<Vec<Vec3>>) {
}
/// The segments a face lies over: its vertices on them within `tol`, its triangles' centres
/// near them (`to_2d` takes a point into the profile's plane).
/// near them (`to_2d` takes a point into the profile's plane). A face over one segment has all
/// of them on it; a face over several (the one wall a circle drawn in arcs sweeps) has each
/// centre near one of them and each vertex on one of them.
fn swept_from(b: &Body, loops: &[&Loop2], to_2d: impl Fn(Vec3) -> Vec2, tol: f64) -> Vec<Vec<usize>> {
let (corners, centres) = mesh_points(b);
let flat = |pts: &Vec<Vec3>| pts.iter().map(|p| to_2d(*p)).collect::<Vec<_>>();
@@ -57,8 +59,19 @@ fn swept_from(b: &Body, loops: &[&Loop2], to_2d: impl Fn(Vec3) -> Vec2, tol: f64
.iter()
.zip(&centres)
.map(|(v, c)| {
let near = under(loops, &flat(c), b.size() * 3e-3);
under(loops, &flat(v), tol).into_iter().filter(|k| near.contains(k)).collect()
let (v, c) = (flat(v), flat(c));
let near = under(loops, &c, b.size() * 3e-3);
let one: Vec<usize> = under(loops, &v, tol).into_iter().filter(|k| near.contains(k)).collect();
if !one.is_empty() {
return one;
}
let each = |pts: &[Vec2], tol: f64| pts.iter().map(|q| under(loops, std::slice::from_ref(q), tol)).collect::<Vec<_>>();
let centre_segs = each(&c, b.size() * 3e-3);
let mut over: Vec<usize> = centre_segs.iter().flatten().copied().collect();
over.sort_unstable();
over.dedup();
let covered = |segs: &[Vec<usize>]| segs.iter().all(|s| s.iter().any(|k| over.contains(k)));
if over.len() > 1 && covered(&centre_segs) && covered(&each(&v, tol)) { over } else { Vec::new() }
})
.collect()
}
@@ -234,7 +247,8 @@ fn revolve_partial_and_full() {
}
/// Loops given clockwise, a hole that is a full circle of three arcs: extrude and revolve
/// number every face by the segment as given, one face each.
/// number every face by the segments as given. Extruded, the circle's arcs sweep one wall,
/// made from all three; the rectangle's sides one face each.
#[test]
fn clockwise_loops_and_a_circle_of_arcs_keep_their_numbers() {
let (c, rad) = (Vec2::new(20.0, 10.0), 4.0);
@@ -245,9 +259,11 @@ fn clockwise_loops_and_a_circle_of_arcs_keep_their_numbers() {
let b = crate::extrude(&Plane::XY, std::slice::from_ref(&r), 0.0, 10.0).unwrap().pop().unwrap();
let got = origins(&b);
assert_eq!(got, expected_extrusion(&b, &Plane::XY, &r, 10.0));
for k in 0..7 {
for k in 0..4 {
assert_eq!(got.iter().filter(|o| **o == [P(k)]).count(), 1, "segment {k}");
}
assert_eq!(got.iter().filter(|o| **o == [P(4), P(5), P(6)]).count(), 1, "the circle's one wall");
assert_eq!(got.len(), 7, "four sides, the wall, two caps");
// Revolved, each arc turns into a face of its own, as the rectangle's sides do.
for angle in [FRAC_PI_2, TAU] {
let b = crate::revolve(&SIDE, std::slice::from_ref(&r), Vec2::ZERO, Vec2::Y, angle).unwrap().pop().unwrap();
+1 -8
View File
@@ -631,14 +631,7 @@ pub(super) fn rows(app: &mut SolveApp, ctx: &egui::Context, d: &mut Dialog, ui:
opts.tapped = tap == 1;
});
if opts.tapped {
enter |= crate::dialogs_thread::hole_rows(
ui,
&app.session.doc,
&mut opts.thread,
&mut opts.custom_thread,
&mut opts.drill,
app.preferences.metric_tap_drill_major_less_pitch,
);
enter |= crate::dialogs_thread::hole_rows(ui, &app.session.doc, &mut opts.thread, &mut opts.custom_thread, &mut opts.drill);
crate::dialogs_thread::hole_hand_row(ui, &mut opts.hand);
ui_kit::checkbox_grid(ui, &mut [("Full thread depth", &mut opts.thread_full_depth), ("Modeled", &mut opts.modeled)], 1);
// A modelled thread's inner end, towards the bottom, as the thread dialog's.
+5 -7
View File
@@ -74,7 +74,6 @@ pub(crate) fn hole_rows(
designation: &mut String,
custom: &mut Option<HoleThreadDraft>,
drill: &mut Option<String>,
major_less_pitch: bool,
) -> bool {
let before = designation.clone();
let designation_id = ui.make_persistent_id("hole_thread_designation");
@@ -170,13 +169,12 @@ pub(crate) fn hole_rows(
form_row(ui, "Tap drill diameter", |ui| {
match parse_tapped_thread(designation).filter(|_| custom.as_ref().is_none_or(|draft| draft.error.is_none())) {
Some(size) => {
let default = format!("{} mm", size.default_drill(major_less_pitch));
let default = format!("{} mm", size.tap_drill);
let (lo, hi) = size.drill_range();
let mm = |v: f64| format!("{:.3}", v);
let args =
[("drill", mm(size.default_drill(major_less_pitch))), ("minor", mm(size.minor_diameter())), ("low", mm(lo)), ("high", mm(hi))];
let args = [("drill", mm(size.tap_drill)), ("minor", mm(size.minor_diameter())), ("low", mm(lo)), ("high", mm(hi))];
let args: Vec<(&str, &str)> = args.iter().map(|(k, v)| (*k, v.as_str())).collect();
let id = match (size.taper_drill().is_some(), size.drill_is_tabulated() && size.default_drill(major_less_pitch) == size.tap_drill) {
let id = match (size.taper_drill().is_some(), size.drill_is_tabulated()) {
(true, _) => "thread.drill_range_taper",
(false, true) => "thread.drill_range",
(false, false) => "thread.drill_range_custom",
@@ -984,7 +982,7 @@ mod contribution_tests {
let doc = Document::default();
let _ = ctx.run_ui(Default::default(), |ui| {
egui::Grid::new("hole_catalogue").show(ui, |ui| {
hole_rows(ui, &doc, &mut designation, &mut custom, &mut None, false);
hole_rows(ui, &doc, &mut designation, &mut custom, &mut None);
});
});
assert_eq!(designation, original);
@@ -1135,7 +1133,7 @@ mod contribution_tests {
let doc = Document::default();
let _ = context.run_ui(Default::default(), |ui| {
egui::Grid::new("authored_hole").show(ui, |ui| {
hole_rows(ui, &doc, &mut hole, &mut custom, &mut None, false);
hole_rows(ui, &doc, &mut hole, &mut custom, &mut None);
});
});
assert_eq!(hole, original);
-2
View File
@@ -158,8 +158,6 @@ fn swap_in(app: &mut SolveApp, mut slot: DocSlot) -> DocSlot {
put_view(app, slot.view);
// Preferences the session holds go with the user, not the tab (#680).
app.session.auto_project = out.session.auto_project;
app.session.metric_tap_drill_major_less_pitch = out.session.metric_tap_drill_major_less_pitch;
app.session.surface_extrude_symmetric_per_side = out.session.surface_extrude_symmetric_per_side;
app.session.set_validation(out.session.validation());
// So does the host's pre-command check: every tab is held to it.
app.session.set_command_check(out.session.command_check());
-4
View File
@@ -978,10 +978,6 @@ impl SolveApp {
if matches!(id, "file.save_mesh" | "file.send_to_slicer") {
solidcraft_engine::slicers::set_chosen_programs(&self.preferences.custom_slicers);
}
// The preferences the hole and surface extrude commands read, current even before the
// next frame applies them.
self.session.metric_tap_drill_major_less_pitch = self.preferences.metric_tap_drill_major_less_pitch;
self.session.surface_extrude_symmetric_per_side = self.preferences.surface_extrude_symmetric_per_side;
self.session.set_validation(self.preferences.validation);
let t0 = now_ms();
let r = self.session.execute(id, &params).map_err(|e| e.to_string());
+10 -76
View File
@@ -633,14 +633,6 @@ preference_settings! {
/// Up/Down and the wheel over a focused value field step its plain number (`value_step`,
/// #2320). Off by default: the keys move the text cursor and the wheel scrolls, as before.
step_values: bool = false, PAGE_DESIGN => check_id("ui.step_values");
/// New metric tapped holes drill the major diameter less the pitch (M8: 6.75 mm), as before
/// the tap maker's drills; off by default: the tap maker's drill (M8: 6.8 mm). Saved designs
/// keep the drill they stored either way.
metric_tap_drill_major_less_pitch: bool = false, PAGE_DESIGN => check_id("prefs.metric_tap_drill_major_less_pitch");
/// New symmetric surface extrudes go their distance each way, as before they matched solid
/// extrudes; off by default: the distance is the total, split evenly around the start plane.
/// Saved designs keep the reading they stored either way.
surface_extrude_symmetric_per_side: bool = false, PAGE_DESIGN => check_id("prefs.surface_extrude_symmetric_per_side");
/// When SMLib's full check runs while features are computed (`diagnostics.validation`):
/// `each_feature` (the default) checks the bodies each feature keeps once; `each_step`, as
/// before, checks after every sweep, boolean and blend; `off` (experimental) never does.
@@ -1130,10 +1122,6 @@ fn defaults(app: &mut SolveApp, page: usize) {
/// the interface scale.
pub fn apply(app: &mut SolveApp, ctx: &egui::Context) {
apply_network(&app.preferences);
// The hole command reads the metric tapped drill rule from the session, Surface Extrude its
// symmetric reading.
app.session.metric_tap_drill_major_less_pitch = app.preferences.metric_tap_drill_major_less_pitch;
app.session.surface_extrude_symmetric_per_side = app.preferences.surface_extrude_symmetric_per_side;
// The features computed from now on are checked as the preference says.
app.session.set_validation(app.preferences.validation);
// The profiler records while the preference is on (switched when it changes; at start-up only
@@ -2461,72 +2449,18 @@ mod tests {
assert!(!solidcraft_engine::profile::enabled());
}
/// New metric tapped holes drill the tap maker's drill (M8: 6.8 mm); the preference keeps
/// the major diameter less the pitch they took before (6.75 mm). It reaches the hole command
/// whether set through the control channel or the Preferences page, and a hole given its
/// diameter keeps it either way.
/// Preferences saved with a setting this version no longer has still load, every other
/// setting kept: the removed key is ignored like any unknown one.
#[test]
fn the_metric_tap_drill_preference_keeps_major_less_pitch() {
fn saved_preferences_with_a_removed_setting_still_load() {
use serde_json::json;
let plate = || {
let mut h = crate::scenario::Harness::new();
h.app.run("solid.box", json!({"length":40,"width":20,"height":10,"body_name":"Plate"})).unwrap();
h
};
let drilled = |h: &mut crate::scenario::Harness, params: serde_json::Value| {
let id = h.app.run("solid.hole", params).unwrap()["feature"].as_u64().unwrap();
match &h.app.session.doc.feature(id).unwrap().kind {
solidcraft_engine::doc::FeatureKind::Hole { diameter, .. } => diameter.to_string(),
k => panic!("{k:?}"),
}
};
let m8 = json!({"position":[10,10,10],"thread":"M8"});
let mut h = plate();
h.frames(1);
assert!(!h.app.preferences.metric_tap_drill_major_less_pitch, "off by default");
assert_eq!(drilled(&mut h, m8.clone()), "6.8 mm");
let mut h = plate();
h.call("ui.prefs", json!({"metric_tap_drill_major_less_pitch": true}));
h.frames(2);
assert!(h.app.session.metric_tap_drill_major_less_pitch);
assert_eq!(drilled(&mut h, m8.clone()), "6.75 mm");
// Only metric changes: a Unified size keeps its tabulated drill.
assert_eq!(drilled(&mut h, json!({"position":[25,10,10],"thread":"1/4-20 UNC"})), "5.1054 mm");
let mut given = m8;
given["position"] = json!([33, 10, 10]);
given["diameter"] = json!("6.9 mm");
assert_eq!(drilled(&mut h, given), "6.9 mm");
// A design opened or started keeps the user's choice.
h.app.run("file.new", json!({})).unwrap();
assert!(h.app.session.metric_tap_drill_major_less_pitch);
}
/// New symmetric surface extrudes read their distance as the total, as solid extrudes do; the
/// preference brings back the distance on each side they took before. It reaches the command
/// whether set through the control channel or the Preferences page, and survives a new design.
#[test]
fn the_surface_extrude_preference_keeps_the_distance_on_each_side() {
use serde_json::json;
let height = |h: &mut crate::scenario::Harness, name: &str| {
h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();
h.app.run("sketch.rectangle.two_point", json!({"p0":[0,0],"p1":[10,10]})).unwrap();
h.app.run("sketch.finish", json!({})).unwrap();
h.app.run("surface.extrude", json!({"distance":"10 mm","direction":"symmetric","body_name":name})).unwrap();
let st = h.app.session.world_state().unwrap();
let b = st.body(name).unwrap().mesh().bounds();
b.max.z - b.min.z
};
let mut h = crate::scenario::Harness::new();
h.frames(1);
assert!(!h.app.preferences.surface_extrude_symmetric_per_side, "off by default");
assert!((height(&mut h, "Total") - 10.0).abs() < 1e-7);
let mut h = crate::scenario::Harness::new();
h.call("ui.prefs", json!({"surface_extrude_symmetric_per_side": true}));
h.frames(2);
assert!(h.app.session.surface_extrude_symmetric_per_side);
assert!((height(&mut h, "Each") - 20.0).abs() < 1e-7);
h.app.run("file.new", json!({})).unwrap();
assert!(h.app.session.surface_extrude_symmetric_per_side);
for removed in ["metric_tap_drill_major_less_pitch", "surface_extrude_symmetric_per_side"] {
let saved = json!({"length_decimals": 4, removed: true});
let p = serde_json::from_value::<super::Prefs>(saved.clone()).unwrap();
assert_eq!(p.length_decimals, 4, "{removed}");
assert_eq!(super::lenient(&saved).length_decimals, 4, "{removed}");
assert!(serde_json::to_value(&p).unwrap().get(removed).is_none(), "{removed} is not written back");
}
}
#[test]
-8
View File
@@ -36,14 +36,6 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
let step = setting::step_values(app, ui).on_hover_text(tip);
crate::scenario::publish_handle("prefs:step_values", step.rect.center());
});
ui_kit::settings_section(ui, "holes", app.tr("prefs.holes"), |ui| {
let check = setting::metric_tap_drill_major_less_pitch(app, ui);
crate::scenario::publish_handle("prefs:metric_tap_drill_major_less_pitch", check.rect.center());
});
ui_kit::settings_section(ui, "surfaces", app.tr("prefs.surfaces"), |ui| {
let check = setting::surface_extrude_symmetric_per_side(app, ui);
crate::scenario::publish_handle("prefs:surface_extrude_symmetric_per_side", check.rect.center());
});
// When SMLib's full check runs while features are computed (`diagnostics.validation`).
ui_kit::settings_section(ui, "validation", app.tr("prefs.validation"), |ui| {
use solidcraft_engine::kernel::Validation;
-4
View File
@@ -27,10 +27,6 @@ cutting taps, printed p.704 (M, coarse) and pp.704 to 706 (MF, fine); M8 drills
the pitch, to 0.001 mm (M8.5x1: 7.5 mm). This replaces the major-minus-pitch
estimate every metric size took before (M8 6.75 mm). A saved design keeps the
diameter it stored, so it builds as before; editing such a hole keeps its drill.
The Design preference "Metric tapped holes drill the major diameter less the
pitch" (`metric_tap_drill_major_less_pitch`, off by default) gives new metric
holes that older drill again, in the Hole dialog and for the `solid.hole` command
given no `diameter`.
Custom metric dimensions remain editable, and Custom stays selected even when its
current dimensions match a catalogue entry.
@@ -2,7 +2,7 @@
"sources": [],
"what": "a line extruded symmetric 10 as a surface with no convention: the total, 5 each side of the sketch plane, as for a solid extrude (#9091)",
"source": "analytic",
"method": "surface.extrude without `convention` reads the distance as the total (default_extrude_convention): the plane y = 0, x 0..10, z -5..5, area 100, 4 free edges",
"method": "surface.extrude without `convention` reads the distance as the total: the plane y = 0, x 0..10, z -5..5, area 100, 4 free edges",
"valid": false,
"body_count": 1,
"faces": 1,