Revolve takes a planar body face as its profile (#2747) (#5170)

solid.revolve already revolves a planar body face (`face`, `face_body`), but
the Revolve window's Profile input took sketch profiles only, so a face
couldn't be picked. The input now takes planar faces too, and a picked face
is sent as `face`; sketch profiles win when both are picked.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dudedagger42andClaude Opus 5.5 authored and GitHub committed 2026-10-25 04:06:08 +00:00
1 parent cc1e654690
commit 7c2b2f1559
2 files changed
+41 -3

No files matched your search

+17 -3
View File
@@ -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")?;
}
+24
View File
@@ -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}");
}