Skip to content

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

Extrude: accept manually selected target planes (#4974) (#6030)

Colin Faulkingham28fe5fdb432e
diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs
index 1a13ff7512..2031a062da 100644
--- a/crates/ui-egui/src/dialogs.rs
+++ b/crates/ui-egui/src/dialogs.rs
@@ -1209,15 +1209,13 @@ impl Dialog {
inp.accepts(h, |body, face| snap.and_then(|f| f.planar(body, face)).unwrap_or_else(|| planar_face(s, body, face).is_some()))
}
- /// Extrude's automatic To Object: with profiles picked, a face or vertex off their plane, or
- /// a plane parallel to it, is the object to extrude to rather than another profile. While the
- /// To Object input is active, a parallel plane is taken too (as a place on it).
+ /// With automatic To Object enabled and profiles picked, a face or vertex off their plane,
+ /// or a parallel plane, is the target rather than another profile. An explicitly active
+ /// To Object input accepts parallel planes regardless of the automatic switching preference.
fn extrude_target(&self, s: &Session, h: &Hit) -> Option<Sel> {
- if !matches!(self.kind, Kind::Extrude { thin: false, smart: crate::smart_extrude::Smart { auto_to_object: true, .. }, .. }) {
- return None;
- }
+ let Kind::Extrude { thin: false, smart, .. } = &self.kind else { return None };
let to_active = self.active_input().is_some_and(|i| i.label == TO_OBJECT);
- if self.active != 0 && !to_active {
+ if !to_active && (self.active != 0 || !smart.auto_to_object) {
return None;
}
let reference = profile_plane(s, self.inputs.first()?.items.first()?)?;
diff --git a/crates/ui-egui/src/extrude_auto_to_object_tests.rs b/crates/ui-egui/src/extrude_auto_to_object_tests.rs
index d1f894b64c..757d89e0fd 100644
--- a/crates/ui-egui/src/extrude_auto_to_object_tests.rs
+++ b/crates/ui-egui/src/extrude_auto_to_object_tests.rs
@@ -194,3 +194,18 @@ fn off_by_default_a_face_off_the_profile_plane_joins_the_profiles() {
assert!(!click(&mut h, |_| Hit::Plane { name: "Lid".into(), point: Vec3::new(5.0, 5.0, 25.0) }));
assert!(to_object(dialog(&h)).is_none());
}
+
+#[test]
+fn manual_to_object_accepts_a_parallel_plane_with_automatic_switching_off() {
+ let mut h = scene_with(false);
+ h.step(&json!({"click": {"handle": "dialog:Extent Type"}})).unwrap();
+ h.step(&json!({"click": {"handle": "dialog:Extent Type:To Object"}})).unwrap();
+ assert_eq!(dialog(&h).active_input().unwrap().label, "To Object");
+ assert!(!click(&mut h, |_| Hit::Plane { name: "YZ".into(), point: Vec3::new(0.0, 5.0, 5.0) }));
+ assert!(!click(&mut h, |_| Hit::Plane { name: "XY".into(), point: Vec3::new(5.0, 5.0, 0.0) }));
+ assert!(to_object(dialog(&h)).is_none());
+ assert!(click(&mut h, |_| Hit::Plane { name: "Lid".into(), point: Vec3::new(5.0, 5.0, 25.0) }));
+ let commands = apply_commands(&h.app, dialog(&h)).unwrap();
+ assert_eq!(commands[0].1["to"], json!([0.0, 0.0, 25.0]));
+ assert!((solidcraft_engine::extrude_reach(&h.app.session, &commands[0].1).unwrap() - 25.0).abs() < 1e-9);
+}