SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Revolve takes a planar body face as its profile (#2747) (#5170)
dudedagger427c2b2f155955
diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rsindex 5095318f64..2f8c34522e 100644--- a/crates/ui-egui/src/dialogs.rs+++ b/crates/ui-egui/src/dialogs.rs@@ -695,7 +695,7 @@ impl Dialog {),"solid.revolve" => Dialog::new(Kind::Revolve { angle: "360 deg".into(), operation: 0, axis: None },- vec![SelInput::new("Profile", PROFILES, true), SelInput::new("Axis", AXES, false)],+ vec![SelInput::new("Profile", PROFILES | PLANAR_FACES, true), SelInput::new("Axis", AXES, false)],),"solid.fillet" => Dialog::new(fillet_kind("2 mm", false), vec![SelInput::new("Edges", EDGES | FACES, true)]),"solid.chamfer" => Dialog::new(fillet_kind("1 mm", true), vec![SelInput::new("Edges", EDGES | FACES, true)]),@@ -3491,8 +3491,22 @@ fn dialog_commands(app: &SolveApp, d: &Dialog) -> Result<Vec<(String, Value)>, S_ => stored_axis.clone().ok_or("select an axis")?,};let (sketch, idx) = profiles();- let mut p =- json!({"sketch": sketch, "profiles": idx, "axis": axis, "angle": angle, "operation": OPS.get(*operation).copied().unwrap_or("new")});+ let mut p = json!({"axis": axis, "angle": angle, "operation": OPS.get(*operation).copied().unwrap_or("new")});+ // A planar body face revolves like a profile (#2747); profiles win when both are picked.+ let face = sels(d, 0).iter().find_map(|x| match x {+ Sel::Face { body, point, .. } => Some((body, point)),+ _ => None,+ });+ match face {+ Some((body, point)) if sketch.is_null() => {+ p["face"] = pt(*point);+ p["face_body"] = json!(body);+ }+ _ => {+ p["sketch"] = sketch;+ p["profiles"] = idx;+ }+ }if to_object_on(&d.inputs) {p["to"] = to_object_point(&d.inputs).ok_or("select the object to turn to")?;}diff --git a/crates/ui-egui/src/preselect_tests.rs b/crates/ui-egui/src/preselect_tests.rsindex db8b42ffbf..22e1e4f490 100644--- a/crates/ui-egui/src/preselect_tests.rs+++ b/crates/ui-egui/src/preselect_tests.rs@@ -2391,3 +2391,27 @@ fn model_bounds_are_kept_until_the_model_changes() {let far = crate::viewport::model_bounds(&app);assert!((far.max.x - 505.0).abs() < 1e-6, "a new sketch grows the box: {far:?}");}++/// #2747: the Revolve window takes a planar body face as its profile, as the engine already+/// does: the box's front face (on Y = 0, from the Z axis to X = 40) turned about Z is a+/// Ø80 × 20 cylinder.+#[test]+fn face_then_revolve_turns_the_face() {+ let mut app = boxed();+ let front = face(&app, Vec3::new(20.0, 0.0, 10.0));+ let mut d = start(&mut app, vec![front], "solid.revolve");+ assert_eq!(d.inputs[0].items.len(), 1, "the face is the profile");+ d.inputs[1].items = vec![Sel::Axis { name: "Z".into() }];+ let cmds = apply_commands(&app, &d).unwrap();+ assert_eq!(cmds[0].1["face"], json!([20.0, 0.0, 10.0]), "{:?}", cmds[0].1);+ assert_eq!(cmds[0].1["face_body"], "Body1");+ assert!(cmds[0].1.get("sketch").is_none(), "{:?}", cmds[0].1);+ for (cmd, p) in cmds {+ app.run(&cmd, p).unwrap();+ }+ let st = app.session.world_state();+ let made = st.bodies.iter().find(|b| b.name != "Body1").expect("the revolve makes a new body");+ let v = solidcraft_engine::doc::kernel::measure(&made.body).unwrap().volume;+ let want = std::f64::consts::PI * 40.0 * 40.0 * 20.0;+ assert!((v - want).abs() < want * 1e-3, "{v} vs {want}");+}