From 40b1b70decb76faa244c09aa961124ec19ee0abd Mon Sep 17 00:00:00 2001 From: ReDead <104050379+ReDead@users.noreply.github.com> Date: Wed, 4 Nov 2026 16:01:35 +0000 Subject: [PATCH] Shell: pick a body from the Browser for a closed hollow (#794) (#11441) * claim: #794 Co-authored-by: ReDead * Shell: pick a body from the Browser for a closed hollow (#794) Faces/Body accepted only faces, so a Browser body click never filled the Shell dialog. Accept bodies, build faces:[] with that body, restore empty-face shells as a body pick, and keep the chip/highlights on the body itself. Co-authored-by: ReDead * Shell: refuse faces that sit on a different body than the Browser-picked one Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Cursor Agent Co-authored-by: ReDead Co-authored-by: bherbruck Co-authored-by: Claude Opus 5.5 --- crates/ui-egui/src/browser.rs | 6 +- crates/ui-egui/src/dialogs.rs | 138 +++++++++++++++++++++++++++++----- 2 files changed, 122 insertions(+), 22 deletions(-) diff --git a/crates/ui-egui/src/browser.rs b/crates/ui-egui/src/browser.rs index 1ffe9e025..8e42ca344 100644 --- a/crates/ui-egui/src/browser.rs +++ b/crates/ui-egui/src/browser.rs @@ -2399,9 +2399,9 @@ impl CanvasPanel { } /// Does the open dialog's active input take bodies (Combine's target and tools, #4452; -/// Move/Copy's bodies, #4771)? Then a body clicked in the Browser goes there, as a click -/// on it in the view does, rather than replacing the selection: overlapping bodies are -/// often only told apart in the Browser. +/// Move/Copy's bodies, #4771; Shell's Faces/Body for a closed hollow, #794)? Then a body +/// clicked in the Browser goes there, as a click on it in the view does, rather than +/// replacing the selection: overlapping bodies are often only told apart in the Browser. fn dialog_takes_body(app: &SolveApp) -> bool { app.dialog.as_ref().and_then(|d| d.active_input()).is_some_and(|i| i.accept & crate::selection::BODIES != 0) } diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index 9cc8a731c..1e13a50fe 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -112,7 +112,8 @@ const HOLE_LABELS: [&str; 3] = ["Simple", "Counterbore", "Countersink"]; crate::dialog_descriptor::dialog_descriptors! { #[derive(Clone, Debug)] pub enum Kind { - Shell("solid.shell", "SHELL", [("Faces/Body", FACES, true)], + // Faces to remove, or a body for a closed hollow with none (#794). + Shell("solid.shell", "SHELL", [("Faces/Body", FACES | BODIES, true)], FeatureKind::Shell { thickness, .. }) { thickness: String = "2 mm".into() => shown_expr(thickness, ValueKind::Length), } => json!({"thickness": thickness}); @@ -1471,6 +1472,11 @@ impl Dialog { return None; } let picks = sels(self, 0); + // A body alone is a closed hollow: no faces to chain, so the chip and highlights use the + // body pick itself (#794). Returning an empty face list would show "0 selected". + if picks.iter().all(|p| !matches!(p, Sel::Face { .. })) { + return None; + } if let Ok(cache) = self.shell_chain.try_borrow() && let Some(chain) = cache.as_ref() && chain.revision == s.revision @@ -2594,6 +2600,9 @@ fn hint(inp: &SelInput) -> &'static str { "click sketch points" } else if inp.label == "Components" { "click components" + } else if inp.label == "Faces/Body" { + // Shell (#794): faces open the hollow; a body alone seals a closed void inside. + "click faces to remove, or a body in the Browser for a closed hollow" } else if a & BODIES != 0 { "click bodies" } else { @@ -5001,15 +5010,36 @@ fn dialog_commands(app: &SolveApp, d: &Dialog) -> Result, S } } Kind::Shell { .. } => { - need(0, "faces to remove")?; - let mut p = json!({"faces": face_points(0)}); - // The picked faces' body: a point alone may name a flush face of another body (#4555). - let mut bodies = sels(d, 0).iter().filter_map(|s| if let Sel::Face { body, .. } = s { Some(body) } else { None }); - if let Some(first) = bodies.next() - && bodies.all(|b| b == first) - { - p["body"] = json!(first); - } + let picks = sels(d, 0); + let face_sels: Vec<_> = picks.iter().filter(|s| matches!(s, Sel::Face { .. })).collect(); + let body_names: Vec<_> = picks.iter().filter_map(|s| if let Sel::Body { name } = s { Some(name.as_str()) } else { None }).collect(); + // A body alone (no faces): a closed hollow (#794, #4009). Faces still open the shell. + let p = if face_sels.is_empty() { + need(0, "faces to remove, or a body for a closed hollow")?; + match body_names.as_slice() { + [name] => json!({"faces": [], "body": name}), + [] => return Err("select faces to remove, or a body for a closed hollow".into()), + _ => return Err("select one body for a closed hollow".into()), + } + } else { + let mut p = json!({"faces": face_points(0)}); + // The picked faces' body: a point alone may name a flush face of another body (#4555). + // A Browser body pick with faces scopes them when they all sit on that body. + if let [name] = body_names.as_slice() { + if face_sels.iter().any(|s| matches!(s, Sel::Face { body, .. } if body != name)) { + return Err("the faces are on a different body than the one picked".into()); + } + p["body"] = json!(name); + } else { + let mut bodies = face_sels.iter().filter_map(|s| if let Sel::Face { body, .. } = s { Some(body.as_str()) } else { None }); + if let Some(first) = bodies.next() + && bodies.all(|b| b == first) + { + p["body"] = json!(first); + } + } + p + }; ("solid.shell", p) } Kind::Draft { .. } => { @@ -6414,7 +6444,7 @@ pub fn for_feature(app: &SolveApp, id: u64, marker: Option) -> Option { + FeatureKind::Shell { faces, direction, tangent_chain, body, .. } => { let mut d = start("solid.shell")?; d.kind = Kind::simple_restore(&f.kind)?; d.extra.insert("tangent_chain".into(), json!(tangent_chain)); @@ -6422,13 +6452,20 @@ pub fn for_feature(app: &SolveApp, id: u64, marker: Option) -> Option