Skip to content

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

Press Pull on a fillet's round face edits the fillet (#1932) (#6815)

yhamil046c0fca30a727
diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs
index 97d7903420..e19aa24e2b 100644
--- a/crates/ui-egui/src/dialogs.rs
+++ b/crates/ui-egui/src/dialogs.rs
@@ -1898,6 +1898,17 @@ pub fn planar_face(s: &Session, body: &str, face: usize) -> Option<(Vec3, Vec3)>
found
}
+/// The fillet or chamfer feature whose blend a body face is (a piece or copy of one too).
+pub fn blend_feature(s: &Session, body: &str, face: usize) -> Option<u64> {
+ use solidcraft_engine::doc::persistent_name;
+ let st = s.world_state();
+ let b = st.body(body)?;
+ let names = solidcraft_engine::doc::naming::face_names(b);
+ let name = names.get(face).filter(|n| persistent_name::is_blend(n))?;
+ let f = s.doc.feature(persistent_name::made_by(name)?)?;
+ matches!(f.kind, FeatureKind::Fillet { .. } | FeatureKind::Chamfer { .. }).then_some(f.id)
+}
+
thread_local! {
/// The planar faces looked up last, with the model state they were found in (kept, so the
/// pointer stays its own). Each lookup tessellates the whole body, about 0.1 s for an
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index 18e95a8ee7..f1ef309ef6 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -1320,21 +1320,28 @@ impl SolveApp {
self.cancel_sketch();
return;
}
- // Press Pull: edges get a fillet, curved faces an offset, planar faces and profiles an extrude.
+ // Press Pull: edges get a fillet, a fillet's round face reopens its fillet (its size
+ // changes, as `solid.press_pull` does: #1932), other curved faces an offset, planar faces
+ // and profiles an extrude.
if id == "solid.press_pull" {
if let Some(pending) = &mut self.pending_feature_edit {
pending.then_start(id);
return;
}
- let sel = &self.session.selection;
- let edges = sel.iter().any(|s| matches!(s, solidcraft_engine::Sel::Edge { .. }));
- let curved = sel.iter().any(
- |s| matches!(s, solidcraft_engine::Sel::Face { body, index, .. } if dialogs::planar_face(&self.session, body, *index).is_none()),
- );
- if edges {
+ if self.session.selection.iter().any(|s| matches!(s, solidcraft_engine::Sel::Edge { .. })) {
return self.start("solid.fillet");
}
- if curved {
+ let sel = &self.session.selection;
+ let curved = sel.iter().find_map(|s| match s {
+ solidcraft_engine::Sel::Face { body, index, .. } if dialogs::planar_face(&self.session, body, *index).is_none() => {
+ Some((body, *index))
+ }
+ _ => None,
+ });
+ if let Some((body, index)) = curved {
+ if let Some(blend) = dialogs::blend_feature(&self.session, body, index) {
+ return self.edit_feature(blend);
+ }
return self.start("solid.offset_face");
}
let empty = sel.is_empty();
diff --git a/crates/ui-egui/src/preselect_tests.rs b/crates/ui-egui/src/preselect_tests.rs
index 0733278bc7..fba61e42ba 100644
--- a/crates/ui-egui/src/preselect_tests.rs
+++ b/crates/ui-egui/src/preselect_tests.rs
@@ -789,6 +789,42 @@ fn press_pull_then_curved_face_offsets_it() {
assert!(matches!(app.dialog.as_ref().unwrap().kind, Kind::Extrude { .. }));
}
+/// Press Pull on a fillet's round face reopens the fillet to change its radius, as the
+/// command does, rather than an Offset Face that refuses it (#1932): picked first, or picked
+/// with Press Pull already open.
+#[test]
+fn fillet_face_then_press_pull_edits_its_fillet() {
+ let script = json!([
+ {"command": "solid.box", "params": {"length": 40, "width": 30, "height": 20}},
+ {"command": "solid.fillet", "params": {"edges": [[20, 0, 20], [40, 15, 20], [20, 30, 20], [0, 15, 20]], "radius": 3}}
+ ]);
+ // On the front round: its axis runs along X at y 3, z 17.
+ let p = Vec3::new(20.0, 3.0 - 3.0 * std::f64::consts::FRAC_1_SQRT_2, 17.0 + 3.0 * std::f64::consts::FRAC_1_SQRT_2);
+ let round = |app: &SolveApp| {
+ let names = solidcraft_engine::doc::naming::face_names_at(&app.session.model.state(), &[p]);
+ assert!(names[0].contains("blend"), "{names:?}");
+ let st = app.session.model.state();
+ let b = st.body("Body1").unwrap();
+ let index = solidcraft_engine::doc::naming::face_names(b).iter().position(|n| *n == names[0]).unwrap();
+ Sel::Face { body: "Body1".into(), index, point: p }
+ };
+ let mut app = app_with(script.clone());
+ let fillet = app.session.doc.features.last().unwrap().id;
+ let sel = round(&app);
+ let d = start(&mut app, vec![sel], "solid.press_pull");
+ assert!(matches!(&d.kind, Kind::Fillet { radius, chamfer: false, .. } if radius.starts_with('3')), "{:?}", d.kind);
+ assert_eq!(d.editing.map(|e| e.0), Some(fillet));
+
+ let mut app = app_with(script);
+ app.start("solid.press_pull");
+ let sel = round(&app);
+ let index = if let Sel::Face { index, .. } = &sel { *index } else { 0 };
+ crate::viewport::dialog_pick(&mut app, &crate::viewport::Hit::Face { body: "Body1".into(), index, point: p }, sel);
+ let d = app.dialog.clone().unwrap();
+ assert!(matches!(d.kind, Kind::Fillet { .. }), "{:?}", d.kind);
+ assert_eq!(d.editing.map(|e| e.0), Some(fillet));
+}
+
#[test]
fn faces_then_shell_and_face_then_hole() {
let mut app = boxed();