Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

Shell: the dialog sends the picked face's body (#4555) (#6092)

semmelrinde0477e0ba4e61
diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs
index db332f2302..d5466d5705 100644
--- a/crates/ui-egui/src/dialogs.rs
+++ b/crates/ui-egui/src/dialogs.rs
@@ -3531,7 +3531,15 @@ fn dialog_commands(app: &SolveApp, d: &Dialog) -> Result<Vec<(String, Value)>, S
}
Kind::Shell { .. } => {
need(0, "faces to remove")?;
- ("solid.shell", json!({"faces": face_points(0)}))
+ 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);
+ }
+ ("solid.shell", p)
}
Kind::Draft { .. } => {
need(0, "faces")?;
@@ -5532,3 +5540,33 @@ mod extrude_mixed_pick_tests {
assert!((volume - 8000.0).abs() < 1e-6, "the box grown to 20 mm: {volume}");
}
}
+
+#[cfg(test)]
+mod shell_body_tests {
+ //! The Shell dialog says whose face it removes (#4555).
+
+ use super::*;
+ use crate::scenario::Harness;
+
+ /// Two boxes stacked flush: the upper one's bottom face lies in the lower one's top. Picked
+ /// from below with the lower box hidden, the face is the upper box's, and the dialog says so.
+ #[test]
+ fn a_face_flush_with_another_body_is_shelled_on_its_own_body() {
+ let mut h = Harness::new();
+ h.app.run("solid.box", json!({"length":20,"width":20,"height":20,"corner":[0,0,0]})).unwrap();
+ h.app.run("solid.box", json!({"length":20,"width":20,"height":10,"corner":[0,0,20],"operation":"new"})).unwrap();
+ let st = h.app.session.world_state();
+ let (lower, upper) = (st.bodies[0].name.to_string(), st.bodies[1].name.to_string());
+ h.app.run("browser.visibility", json!({"visible":false,"items":[lower]})).unwrap();
+ h.step(&json!({"call":"ui.view","params":{"view":"bottom"}})).unwrap();
+ h.settle();
+ h.step(&json!({"start":"solid.shell"})).unwrap();
+ h.step(&json!({"click":{"world":[10,10,20]}})).unwrap();
+ h.frames(2);
+ let d = h.app.dialog.as_ref().expect("the shell dialog");
+ let commands = dialog_commands(&h.app, d).unwrap();
+ let (cmd, p) = commands.first().unwrap();
+ assert_eq!(cmd, "solid.shell");
+ assert_eq!(p["body"], json!(upper), "{p}");
+ }
+}