From 7bbfb02126435cf6e6c1ffd516cafdf022779f71 Mon Sep 17 00:00:00 2001 From: sascha2101 <221609842+sascha2101@users.noreply.github.com> Date: Tue, 27 Oct 2026 09:46:54 +0100 Subject: [PATCH 1/8] claim: #7520 From 8ac4bc68226dedccc0436e795470cb7089159ac7 Mon Sep 17 00:00:00 2001 From: sascha2101 <221609842+sascha2101@users.noreply.github.com> Date: Tue, 27 Oct 2026 10:02:51 +0100 Subject: [PATCH 2/8] Hole: drill only the shown bodies when no target is picked (#7520) A Hole that names no bodies drilled every body in its path, hidden ones too, and its dialog preview replaced the hidden bodies with drilled ones. Like a cut (#3961), it now takes the shown bodies of the active component as its participants while some are hidden, stored so showing the others later changes nothing. With nothing hidden, or everything, it still drills every body. Its face points are named on the bodies it drills first, so a hidden body's face in the same plane no longer takes the picked face's name. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01FN5eEMrqWWXqi65FcK8GXq --- crates/engine/src/cmd/features.rs | 26 +++++++++++++++++++++++ crates/engine/src/tests.rs | 34 +++++++++++++++++++++++++++++++ crates/ui-egui/src/preview.rs | 15 ++++++++++++++ 3 files changed, 75 insertions(+) diff --git a/crates/engine/src/cmd/features.rs b/crates/engine/src/cmd/features.rs index 89140d9821e..8357911fe8f 100644 --- a/crates/engine/src/cmd/features.rs +++ b/crates/engine/src/cmd/features.rs @@ -662,6 +662,8 @@ fn add_feature_in(s: &mut Session, p: &Value, kind: FeatureKind, world: bool) -> names } else if pts.is_empty() { Vec::new() + } else if matches!(kind, FeatureKind::Hole { .. }) { + hole_face_names(s, p, &kind) } else { solidcraft_doc::face_point_names(&s.doc, &s.model.state(), &kind, s.active_component) } @@ -975,6 +977,22 @@ fn face_body_reached(s: &Session, sketch: u64) -> Result> { Ok(Some(body.name.clone())) } +/// A hole's face points, named on the bodies it drills where one of theirs holds the point +/// (#7520): a face of another body in the same plane, a hidden one the hole leaves alone, would +/// otherwise take the name of the face that was picked. Over every body, as before, elsewhere. +fn hole_face_names(s: &Session, p: &Value, kind: &FeatureKind) -> Vec { + let st = s.model.state(); + let all = solidcraft_doc::face_point_names(&s.doc, &st, kind, s.active_component); + let drilled = string_list(p, "participants"); + if drilled.is_empty() || drilled.iter().any(|b| b == "*") { + return all; + } + let mut scoped = solidcraft_doc::ModelState::default(); + scoped.bodies = st.bodies.iter().filter(|b| drilled.contains(&b.name)).cloned().collect(); + let own = solidcraft_doc::face_point_names(&s.doc, &scoped, kind, s.active_component); + own.into_iter().zip(all).map(|(own, any)| if own.is_empty() { any } else { own }).collect() +} + /// A cut or intersect that names no bodies leaves hidden bodies alone, as hiding a body to keep /// it out of a cut is the usual way to (#3961): while some of the active component's bodies /// are hidden, its shown ones, stored as the feature's targets so showing the others again @@ -2529,6 +2547,14 @@ fn hole(s: &mut Session, p: &Value) -> Result { // placed) cuts that body: the pick is already in that body's frame, and the // component's own bodies alone would leave nothing to cut. p["participants"] = json!([body]); + } else { + // Like a cut (#3961), a hole leaves hidden bodies alone (#7520): while some are + // hidden, it drills the shown ones, stored so showing the others later changes + // nothing. + let shown = shown_scope(s); + if !shown.is_empty() { + p["participants"] = json!(shown); + } } } add_feature( diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index dea0aaeba8f..e9e1992ec7c 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -2982,6 +2982,40 @@ fn hole_as_deep_as_the_plate() { } } +/// #7520: a hole that names no bodies leaves hidden ones alone, as a cut does (#3961), and keeps +/// doing so once they are shown again. Its face is named on the body it drills, not on a hidden +/// one whose face lies in the same plane; with nothing hidden, it still drills every body. +#[test] +fn a_hole_leaves_hidden_bodies_alone() { + let setup = |hide: bool| { + let mut s = Session::default(); + // Two bodies whose bottom faces share the plane z = 0, the hidden one made first. + run(&mut s, "solid.box", json!({"length": 40, "width": 40, "height": 20, "body_name": "Block"})); + run(&mut s, "solid.box", json!({"length": 40, "width": 40, "height": 5, "operation": "new", "body_name": "Plate"})); + if hide { + run(&mut s, "browser.visibility", json!({"items": ["Block"], "visible": false})); + } + // The name of the plate's face that is picked, before the hole takes the point away. + let picked = solidcraft_doc::naming::face_name_at_body(s.world_state().body("Plate").unwrap(), solidcraft_geom::Vec3::new(20.0, 20.0, 0.0)); + let r = s.execute("solid.hole", &json!({"position": [20, 20, 0], "diameter": 5, "depth": 10, "name": "Hole1"})).unwrap(); + (s, r, picked) + }; + let vol = |s: &Session, name: &str| solidcraft_kernel::measure(&s.world_state().body(name).unwrap().body).unwrap().volume; + let (block, plate) = (40.0 * 40.0 * 20.0, 40.0 * 40.0 * 5.0); + let (mut hidden, r, picked) = setup(true); + assert_eq!(r["changed_bodies"], json!(["Plate"])); + assert!((vol(&hidden, "Block") - block).abs() < 1e-6, "the hidden body is not drilled"); + assert!(vol(&hidden, "Plate") < plate - 1.0, "the shown one is"); + let hole = hidden.doc.find_feature("Hole1").unwrap(); + assert!(picked.is_some()); + assert_eq!((hole.participants.clone(), hole.face_names.first().cloned()), (vec!["Plate".to_string()], picked)); + run(&mut hidden, "browser.visibility", json!({"items": ["Block"], "visible": true})); + assert!((vol(&hidden, "Block") - block).abs() < 1e-6, "shown again, it stays as it was"); + let (shown, r, _) = setup(false); + assert_eq!(r["changed_bodies"], json!(["Block", "Plate"]), "with nothing hidden, both are drilled"); + assert!(vol(&shown, "Block") < block - 1.0 && vol(&shown, "Plate") < plate - 1.0); +} + /// Appearances outlive later features: a coloured face keeps its colour after a fillet on a /// neighbouring edge; an imported STEP's body and face colours survive a hole. #[test] diff --git a/crates/ui-egui/src/preview.rs b/crates/ui-egui/src/preview.rs index e64fb145ed2..8ecc9250298 100644 --- a/crates/ui-egui/src/preview.rs +++ b/crates/ui-egui/src/preview.rs @@ -1118,6 +1118,21 @@ mod tests { } } + /// #7520: a Hole's preview leaves a hidden body out, drawn nor drilled, as OK does; before, + /// it replaced the hidden body with a drilled one while the dialog was open. + #[test] + fn a_hole_preview_leaves_hidden_bodies_out() { + let mut s = Session::default(); + s.execute("solid.box", &json!({"length": 40, "width": 40, "height": 5, "body_name": "Plate"})).unwrap(); + s.execute("solid.box", &json!({"corner": [0, 0, 5], "length": 40, "width": 40, "height": 20, "operation": "new", "body_name": "Block"})) + .unwrap(); + s.execute("browser.visibility", &json!({"items": ["Block"], "visible": false})).unwrap(); + let cmd = ("solid.hole".to_string(), json!({"position": [20, 20, 0], "diameter": 5, "depth": 10})); + let built = compute(&s, &[cmd], colors()).unwrap(); + assert!(built.error.is_none(), "{:?}", built.error); + assert_eq!(built.replaced, vec!["Plate".to_string()]); + } + /// A plate in its own component, stood up by its placement (an imported part set upright) /// and edited with that component active: the extrusion's tool is drawn where the plate is /// shown, on its top face, not at right angles to it in the component's own frame. From ef684f6bd2d50c6bf5327581a50e4b2399f1addf Mon Sep 17 00:00:00 2001 From: sascha2101 <221609842+sascha2101@users.noreply.github.com> Date: Sun, 1 Nov 2026 18:02:16 +0100 Subject: [PATCH 3/8] Hole: drill the picked body though it is hidden (#7520) Review on #7562: with the picked face's body hidden (picked through Select Other, or hidden while the dialog is open), the shown-bodies default left it out, so the hole drilled only shown bodies further along, or nothing, without a message. The body whose face holds the hole's position now joins the shown ones, unless a shown body has a face there too (a face shared by a shown and a hidden body is the shown one's, as a pick in the view takes it). The test also covers editing a hole made with nothing hidden while a body it drills is hidden: timeline.redefine stores participants only when the edit passes them, so the hole keeps its empty scope and the hidden body its bore. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EMbqRqYimvY26QzcvrojSC --- crates/engine/src/cmd/features.rs | 42 +++++++++++++++++++++++++------ crates/engine/src/tests.rs | 39 ++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 8 deletions(-) diff --git a/crates/engine/src/cmd/features.rs b/crates/engine/src/cmd/features.rs index def0adc32d0..0988d872514 100644 --- a/crates/engine/src/cmd/features.rs +++ b/crates/engine/src/cmd/features.rs @@ -2618,11 +2618,17 @@ fn hole(s: &mut Session, p: &Value) -> Result { // placed) cuts that body: the pick is already in that body's frame, and the // component's own bodies alone would leave nothing to cut. p["participants"] = json!([body]); - } else { + } else if let Some(mut shown) = shown_scope(s) { // Like a cut (#3961), a hole leaves hidden bodies alone (#7520): while some are // hidden, it drills the shown ones, stored so showing the others later changes - // nothing. - if let Some(shown) = shown_scope(s).filter(|shown| !shown.is_empty()) { + // nothing. The body whose face was picked is drilled though hidden (picked through + // Select Other, or hidden with the dialog open): it is the one the hole is for. + if points.is_none() + && let Some(body) = hidden_body_picked_at(s, position, &shown) + { + shown.push(body); + } + if !shown.is_empty() { p["participants"] = json!(shown); } } @@ -2692,16 +2698,36 @@ fn hole_reference_params(s: &Session, p: &Value, cmd: &str) -> Result Option { let st = s.model.state(); - let (_, body) = st - .bodies + let body = body_with_face_at(&st, p, |_| true)?; + (s.doc.model_body_component(body) != s.active_component).then(|| body.name.clone()) +} + +/// The hidden body whose face holds `p`, when no shown body has a face there: a face shared by +/// a shown and a hidden body is the shown one's, as a pick in the view would take it (#7520). +fn hidden_body_picked_at(s: &Session, p: Vec3, shown: &[String]) -> Option { + let st = s.model.state(); + if body_with_face_at(&st, p, |b| shown.contains(&b.name)).is_some() { + return None; + } + let scope: Vec<&str> = active_scope(s, &st).into_iter().map(|b| b.name.as_str()).collect(); + body_with_face_at(&st, p, |b| scope.contains(&b.name.as_str())).map(|b| b.name.clone()) +} + +/// The body, among those `keep` takes, with the face nearest `p` within its pick tolerance. +fn body_with_face_at( + st: &solidcraft_doc::ModelState, + p: Vec3, + keep: impl Fn(&solidcraft_doc::ModelBody) -> bool, +) -> Option<&solidcraft_doc::ModelBody> { + st.bodies .iter() - .filter(|b| !b.body.is_mesh()) + .filter(|b| !b.body.is_mesh() && keep(b)) .filter_map(|b| { let (d, _) = solidcraft_doc::appearance::nearest_face(b, p)?; (d <= solidcraft_doc::appearance::pick_tolerance(b)).then_some((d, b)) }) - .min_by(|a, b| a.0.total_cmp(&b.0))?; - (s.doc.model_body_component(body) != s.active_component).then(|| body.name.clone()) + .min_by(|a, b| a.0.total_cmp(&b.0)) + .map(|(_, b)| b) } /// The points of a sketch a hole drills at when only the sketch is given. diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 72c844416c2..0d4900e8903 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -3067,6 +3067,45 @@ fn a_hole_leaves_hidden_bodies_alone() { assert!(vol(&shown, "Block") < block - 1.0 && vol(&shown, "Plate") < plate - 1.0); } +/// #7520 (review): the body whose face is picked is drilled even while it is hidden (picked +/// through Select Other, or hidden with the dialog open), and editing a hole made with nothing +/// hidden keeps drilling every body, though one is hidden at the time of the edit. +#[test] +fn a_hole_drills_its_picked_body_and_an_edit_keeps_its_scope() { + let stack = || { + let mut s = Session::default(); + // Two plates stacked: Lower z 0..5, Upper z 5..10. + run(&mut s, "solid.box", json!({"length": 40, "width": 40, "height": 5, "body_name": "Lower"})); + run(&mut s, "solid.box", json!({"corner": [0, 0, 5], "length": 40, "width": 40, "height": 5, "operation": "new", "body_name": "Upper"})); + s + }; + let vol = |s: &Session, name: &str| solidcraft_kernel::measure(&s.world_state().body(name).unwrap().body).unwrap().volume; + let plate = 40.0 * 40.0 * 5.0; + let hole = |d: f64| json!({"position": [20, 20, 10], "direction": [0, 0, -1], "diameter": d, "depth": 20, "name": "Hole1"}); + + // The picked face is on the hidden Upper: it is drilled, and so is the shown Lower below. + let mut s = stack(); + run(&mut s, "browser.visibility", json!({"items": ["Upper"], "visible": false})); + let r = s.execute("solid.hole", &hole(5.0)).unwrap(); + assert_eq!(r["changed_bodies"], json!(["Lower", "Upper"]), "the picked body is drilled though hidden"); + assert!(vol(&s, "Upper") < plate - 1.0 && vol(&s, "Lower") < plate - 1.0); + + // Made with nothing hidden, then edited with Lower hidden: both stay drilled, at the new size. + let mut s = stack(); + run(&mut s, "solid.hole", hole(5.0)); + let small = vol(&s, "Lower"); + assert!(small < plate - 1.0); + run(&mut s, "browser.visibility", json!({"items": ["Lower"], "visible": false})); + run( + &mut s, + "timeline.redefine", + json!({"feature": "Hole1", "command": "solid.hole", "params": {"position": [20, 20, 10], "direction": [0, 0, -1], "diameter": 6, "depth": 20}}), + ); + assert!(s.doc.find_feature("Hole1").unwrap().participants.is_empty(), "the edit keeps the hole's scope"); + assert!(vol(&s, "Lower") < small - 1.0, "the hidden Lower keeps its hole, now wider"); + assert!(vol(&s, "Upper") < small - 1.0); +} + /// Appearances outlive later features: a coloured face keeps its colour after a fillet on a /// neighbouring edge; an imported STEP's body and face colours survive a hole. #[test] From d7db1ad5ae94547a5313c6536314cabcd3ea785c Mon Sep 17 00:00:00 2001 From: bherbruck Date: Wed, 4 Nov 2026 11:10:39 -0500 Subject: [PATCH 4/8] Hole: test that a hole made with a body hidden replays the same (#7520) Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/tests.rs | 77 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 0d4900e8903..601456150a2 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -3106,6 +3106,83 @@ fn a_hole_drills_its_picked_body_and_an_edit_keeps_its_scope() { assert!(vol(&s, "Upper") < small - 1.0); } +/// #7520 (history): a hole made with a body hidden stores the bodies it drills, so it replays +/// the same way: volumes match exactly after a save and reopen, a rebuild from scratch, undo and +/// redo, showing the hidden body, renaming bodies and editing an earlier feature. +#[test] +fn a_hole_made_with_a_hidden_body_replays_the_same() { + let build = |plate_height: f64| { + let mut s = Session::default(); + run(&mut s, "solid.box", json!({"length": 40, "width": 40, "height": 20, "body_name": "Block"})); + run(&mut s, "solid.box", json!({"length": 40, "width": 40, "height": plate_height, "operation": "new", "body_name": "Plate"})); + run(&mut s, "browser.visibility", json!({"items": ["Block"], "visible": false})); + run(&mut s, "solid.hole", json!({"position": [20, 20, 0], "diameter": 5, "depth": 3, "name": "Hole1"})); + s + }; + let vol = |s: &Session, name: &str| solidcraft_kernel::measure(&s.world_state().body(name).unwrap().body).unwrap().volume; + // A new session evaluated from the saved text alone, as a rebuild from scratch does. + let scratch = |s: &Session| Session::new(solidcraft_doc::Document::from_json(&s.doc.to_json()).unwrap()); + let s = build(5.0); + let (block, plate) = (vol(&s, "Block"), vol(&s, "Plate")); + assert_eq!(block, 40.0 * 40.0 * 20.0, "the hidden body is not drilled"); + assert!(plate < 40.0 * 40.0 * 5.0 - 1.0, "the shown one is"); + let same = |s: &Session, what: &str| { + assert_eq!(vol(s, "Block"), block, "{what}: Block"); + assert_eq!(vol(s, "Plate"), plate, "{what}: Plate"); + }; + // (1) Save and reopen. + let dir = std::env::temp_dir().join(format!("solidcraft-hole-history-{}", std::process::id())); + std::fs::create_dir_all(&dir).unwrap(); + let file = dir.join("hole.solidcraft"); + let mut saved = build(5.0); + run(&mut saved, "file.save_as", json!({"path": file.to_string_lossy()})); + let mut reopened = Session::default(); + run(&mut reopened, "doc.open", json!({"path": file.to_string_lossy()})); + same(&reopened, "reopened"); + let _ = std::fs::remove_dir_all(&dir); + // (2) Rebuild from scratch. + same(&scratch(&s), "rebuilt"); + // (3) Undo and redo. + let mut u = build(5.0); + run(&mut u, "edit.undo", json!({})); + assert_eq!(vol(&u, "Plate"), 40.0 * 40.0 * 5.0, "undone: no hole"); + run(&mut u, "edit.redo", json!({})); + same(&u, "redone"); + same(&scratch(&u), "redone and rebuilt"); + // (4) Show the hidden body, then rebuild. + let mut shown = build(5.0); + run(&mut shown, "browser.visibility", json!({"items": ["Block"], "visible": true})); + same(&shown, "shown"); + same(&scratch(&shown), "shown and rebuilt"); + // (5) Rename the drilled body (and the hidden one), then rebuild. + let mut renamed = build(5.0); + run(&mut renamed, "body.rename", json!({"body": "Plate", "name": "Slab"})); + run(&mut renamed, "body.rename", json!({"body": "Block", "name": "Core"})); + for r in [&renamed, &scratch(&renamed)] { + assert_eq!(vol(r, "Slab"), plate, "renamed: Slab"); + assert_eq!(vol(r, "Core"), block, "renamed: Core"); + } + // (6) Edit an earlier feature (the plate's own box, then the hidden block's), then rebuild: + // the same as a design made with the new size from the start. + let feature = |s: &Session, body: &str| { + let id = s.world_state().body(body).unwrap().feature; + s.doc.features.iter().find(|f| f.id == id).unwrap().name.clone() + }; + let mut edited = build(5.0); + let (plate_box, block_box) = (feature(&edited, "Plate"), feature(&edited, "Block")); + run(&mut edited, "timeline.edit", json!({"feature": plate_box, "set": {"height": "8"}})); + let fresh = build(8.0); + for r in [&edited, &scratch(&edited)] { + assert_eq!(vol(r, "Plate"), vol(&fresh, "Plate"), "plate edited"); + assert_eq!(vol(r, "Block"), block, "plate edited: Block"); + } + run(&mut edited, "timeline.edit", json!({"feature": block_box, "set": {"height": "30"}})); + for r in [&edited, &scratch(&edited)] { + assert_eq!(vol(r, "Block"), 40.0 * 40.0 * 30.0, "block edited stays undrilled"); + assert_eq!(vol(r, "Plate"), vol(&fresh, "Plate"), "block edited: Plate"); + } +} + /// Appearances outlive later features: a coloured face keeps its colour after a fillet on a /// neighbouring edge; an imported STEP's body and face colours survive a hole. #[test] From 737a09ac9b8ee1d140567af0836ee72cb8583cb0 Mon Sep 17 00:00:00 2001 From: bherbruck Date: Wed, 4 Nov 2026 11:31:12 -0500 Subject: [PATCH 5/8] Hole: follow the face-name lookup now returning a Result (#7520) Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/cmd/features.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/cmd/features.rs b/crates/engine/src/cmd/features.rs index 0988d872514..def6302f651 100644 --- a/crates/engine/src/cmd/features.rs +++ b/crates/engine/src/cmd/features.rs @@ -720,7 +720,7 @@ fn add_feature_in(s: &mut Session, p: &Value, kind: FeatureKind, world: bool) -> } else if pts.is_empty() { Vec::new() } else if matches!(kind, FeatureKind::Hole { .. }) { - hole_face_names(s, p, &kind) + hole_face_names(s, p, &kind)? } else { solidcraft_doc::face_point_names(&s.doc, &s.model.state(), &kind, s.active_component) } @@ -1038,17 +1038,17 @@ fn face_body_reached(s: &Session, sketch: u64) -> Result> { /// A hole's face points, named on the bodies it drills where one of theirs holds the point /// (#7520): a face of another body in the same plane, a hidden one the hole leaves alone, would /// otherwise take the name of the face that was picked. Over every body, as before, elsewhere. -fn hole_face_names(s: &Session, p: &Value, kind: &FeatureKind) -> Vec { +fn hole_face_names(s: &Session, p: &Value, kind: &FeatureKind) -> Result> { let st = s.model.state(); - let all = solidcraft_doc::face_point_names(&s.doc, &st, kind, s.active_component); + let all = solidcraft_doc::face_point_names(&s.doc, &st, kind, s.active_component)?; let drilled = string_list_or_default(p, "participants"); if drilled.is_empty() || drilled.iter().any(|b| b == "*") { - return all; + return Ok(all); } let mut scoped = solidcraft_doc::ModelState::default(); scoped.bodies = st.bodies.iter().filter(|b| drilled.contains(&b.name)).cloned().collect(); - let own = solidcraft_doc::face_point_names(&s.doc, &scoped, kind, s.active_component); - own.into_iter().zip(all).map(|(own, any)| if own.is_empty() { any } else { own }).collect() + let own = solidcraft_doc::face_point_names(&s.doc, &scoped, kind, s.active_component)?; + Ok(own.into_iter().zip(all).map(|(own, any)| if own.is_empty() { any } else { own }).collect()) } /// The body whose face `sketch` is attached to (on the face itself, not offset from it), when From 9eb8b44a1c4738ef99a66a822501dc8c44b130cf Mon Sep 17 00:00:00 2001 From: bherbruck Date: Wed, 4 Nov 2026 12:04:25 -0500 Subject: [PATCH 6/8] Hole: tests follow main's Vec3 and world_state (#7520) Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/tests.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 5bc56b871bd..79d739e827a 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -3413,11 +3413,11 @@ fn a_hole_leaves_hidden_bodies_alone() { run(&mut s, "browser.visibility", json!({"items": ["Block"], "visible": false})); } // The name of the plate's face that is picked, before the hole takes the point away. - let picked = solidcraft_doc::naming::face_name_at_body(s.world_state().body("Plate").unwrap(), solidcraft_geom::Vec3::new(20.0, 20.0, 0.0)); + let picked = solidcraft_doc::naming::face_name_at_body(s.world_state().unwrap().body("Plate").unwrap(), solidcore_record::Vec3::new(20.0, 20.0, 0.0)); let r = s.execute("solid.hole", &json!({"position": [20, 20, 0], "diameter": 5, "depth": 10, "name": "Hole1"})).unwrap(); (s, r, picked) }; - let vol = |s: &Session, name: &str| solidcraft_kernel::measure(&s.world_state().body(name).unwrap().body).unwrap().volume; + let vol = |s: &Session, name: &str| solidcraft_kernel::measure(&s.world_state().unwrap().body(name).unwrap().body).unwrap().volume; let (block, plate) = (40.0 * 40.0 * 20.0, 40.0 * 40.0 * 5.0); let (mut hidden, r, picked) = setup(true); assert_eq!(r["changed_bodies"], json!(["Plate"])); @@ -3445,7 +3445,7 @@ fn a_hole_drills_its_picked_body_and_an_edit_keeps_its_scope() { run(&mut s, "solid.box", json!({"corner": [0, 0, 5], "length": 40, "width": 40, "height": 5, "operation": "new", "body_name": "Upper"})); s }; - let vol = |s: &Session, name: &str| solidcraft_kernel::measure(&s.world_state().body(name).unwrap().body).unwrap().volume; + let vol = |s: &Session, name: &str| solidcraft_kernel::measure(&s.world_state().unwrap().body(name).unwrap().body).unwrap().volume; let plate = 40.0 * 40.0 * 5.0; let hole = |d: f64| json!({"position": [20, 20, 10], "direction": [0, 0, -1], "diameter": d, "depth": 20, "name": "Hole1"}); @@ -3485,7 +3485,7 @@ fn a_hole_made_with_a_hidden_body_replays_the_same() { run(&mut s, "solid.hole", json!({"position": [20, 20, 0], "diameter": 5, "depth": 3, "name": "Hole1"})); s }; - let vol = |s: &Session, name: &str| solidcraft_kernel::measure(&s.world_state().body(name).unwrap().body).unwrap().volume; + let vol = |s: &Session, name: &str| solidcraft_kernel::measure(&s.world_state().unwrap().body(name).unwrap().body).unwrap().volume; // A new session evaluated from the saved text alone, as a rebuild from scratch does. let scratch = |s: &Session| Session::new(solidcraft_doc::Document::from_json(&s.doc.to_json()).unwrap()); let s = build(5.0); @@ -3531,7 +3531,7 @@ fn a_hole_made_with_a_hidden_body_replays_the_same() { // (6) Edit an earlier feature (the plate's own box, then the hidden block's), then rebuild: // the same as a design made with the new size from the start. let feature = |s: &Session, body: &str| { - let id = s.world_state().body(body).unwrap().feature; + let id = s.world_state().unwrap().body(body).unwrap().feature; s.doc.features.iter().find(|f| f.id == id).unwrap().name.clone() }; let mut edited = build(5.0); From 6d780a00f5bb876677bfc74f067294184a0c2e68 Mon Sep 17 00:00:00 2001 From: bherbruck Date: Wed, 4 Nov 2026 12:04:31 -0500 Subject: [PATCH 7/8] Hole: format (#7520) Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/tests.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 79d739e827a..ce44a251da5 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -3413,7 +3413,8 @@ fn a_hole_leaves_hidden_bodies_alone() { run(&mut s, "browser.visibility", json!({"items": ["Block"], "visible": false})); } // The name of the plate's face that is picked, before the hole takes the point away. - let picked = solidcraft_doc::naming::face_name_at_body(s.world_state().unwrap().body("Plate").unwrap(), solidcore_record::Vec3::new(20.0, 20.0, 0.0)); + let picked = + solidcraft_doc::naming::face_name_at_body(s.world_state().unwrap().body("Plate").unwrap(), solidcore_record::Vec3::new(20.0, 20.0, 0.0)); let r = s.execute("solid.hole", &json!({"position": [20, 20, 0], "diameter": 5, "depth": 10, "name": "Hole1"})).unwrap(); (s, r, picked) }; From 7865b3a6984db3b7846fe6911ee6fe8e6afe111d Mon Sep 17 00:00:00 2001 From: bherbruck Date: Wed, 4 Nov 2026 12:21:54 -0500 Subject: [PATCH 8/8] Hole: with every body hidden, drill them all as before (#7520) Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/cmd/features.rs | 3 ++- crates/engine/src/tests.rs | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/features.rs b/crates/engine/src/cmd/features.rs index e4c46809841..3699578482f 100644 --- a/crates/engine/src/cmd/features.rs +++ b/crates/engine/src/cmd/features.rs @@ -2913,7 +2913,8 @@ fn hole(s: &mut Session, p: &Value) -> Result { // hidden, it drills the shown ones, stored so showing the others later changes // nothing. The body whose face was picked is drilled though hidden (picked through // Select Other, or hidden with the dialog open): it is the one the hole is for. - if points.is_none() + if !shown.is_empty() + && points.is_none() && let Some(body) = hidden_body_picked_at(s, position, &shown) { shown.push(body); diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index ce44a251da5..e93ccb840c3 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -3550,6 +3550,18 @@ fn a_hole_made_with_a_hidden_body_replays_the_same() { } } +/// #7520 (review): with every body hidden, a hole still drills all of them, as before. +#[test] +fn a_hole_with_every_body_hidden_drills_them_all() { + let mut s = Session::default(); + run(&mut s, "solid.box", json!({"length": 40, "width": 40, "height": 20, "body_name": "Block"})); + run(&mut s, "solid.box", json!({"length": 40, "width": 40, "height": 5, "operation": "new", "body_name": "Plate"})); + run(&mut s, "browser.visibility", json!({"items": ["Block", "Plate"], "visible": false})); + let r = s.execute("solid.hole", &json!({"position": [20, 20, 0], "diameter": 5, "depth": 3, "name": "Hole1"})).unwrap(); + assert_eq!(r["changed_bodies"], json!(["Block", "Plate"])); + assert!(s.doc.find_feature("Hole1").unwrap().participants.is_empty()); +} + /// Appearances outlive later features: a coloured face keeps its colour after a fillet on a /// neighbouring edge; an imported STEP's body and face colours survive a hole. #[test]