Surface Loft: retain profiles from multiple sketches (#6400) (#6844)

* claim: #6400

* fix(ui): retain surface loft profiles across sketches (#6400)
This commit is contained in:
Colin Faulkingham
2026-10-26 10:42:05 +00:00
committed by GitHub
parent abdf9d79cf
commit a67b3bfdf3
2 changed files with 65 additions and 2 deletions
+3 -2
View File
@@ -1328,9 +1328,10 @@ impl Dialog {
if !one && self.active_input().is_some_and(|i| i.multi) { crate::viewport::picked_selection(s, &sel) } else { vec![sel.clone()] };
// Tangent chain: an edge brings the edges that continue it smoothly.
let picked = if chain { fillet_edges(s, &sel, true) } else { single.clone() };
// Extrude and revolve take profiles of one sketch.
// Extrude and revolve take profiles of one sketch; both lofts take sections
// from several sketches and must keep their pick order.
if let Sel::Profile { sketch, .. } = &sel
&& !matches!(self.kind, Kind::Loft { .. })
&& !matches!(self.kind, Kind::Loft { .. } | Kind::Surface(crate::dialogs_surface::Surf::Loft { .. }))
&& let Some(inp) = self.inputs.get_mut(self.active)
{
inp.items.retain(|x| !matches!(x, Sel::Profile { sketch: s2, .. } if s2 != sketch));
+62
View File
@@ -1745,6 +1745,68 @@ fn surface_sweep_dialog_takes_curves_and_a_path() {
assert_eq!(back.inputs[1].items, vec![Sel::SketchCurve { id: "up".into(), sketch: Some(2) }]);
}
#[test]
fn profile_picks_keep_multiple_sketches_only_for_lofts() {
let mut app = app_with(json!([
{"command":"sketch.create","params":{"plane":"XY"}},
{"command":"sketch.circle.center","params":{"center":[0,0],"radius":10}},
{"command":"sketch.finish","params":{}},
{"command":"sketch.create","params":{"plane":{"origin":[0,0,25],"x_dir":[1,0,0],"y_dir":[0,1,0]}}},
{"command":"sketch.circle.center","params":{"center":[0,0],"radius":10}},
{"command":"sketch.finish","params":{}}
]));
let first = Sel::Profile { sketch: app.session.doc.features[0].id, index: 0 };
let second = Sel::Profile { sketch: app.session.doc.features[1].id, index: 0 };
for command in ["solid.loft", "surface.loft", "solid.extrude", "surface.extrude", "solid.revolve", "surface.revolve"] {
let mut d = start(&mut app, vec![], command);
d.pick(&app.session, first.clone());
d.pick(&app.session, second.clone());
if command.ends_with("loft") {
assert_eq!(d.inputs[0].items, vec![first.clone(), second.clone()], "{command}");
d.pick(&app.session, first.clone());
assert_eq!(d.inputs[0].items, vec![second.clone()], "a second click removes only the picked section");
d.pick(&app.session, first.clone());
assert_eq!(d.inputs[0].items, vec![second.clone(), first.clone()], "sections retain their new pick order");
} else {
assert_eq!(d.inputs[0].items, vec![second.clone()], "{command} still takes profiles from one sketch");
}
}
}
#[test]
fn surface_loft_keeps_sections_picked_in_different_sketches() {
let mut h = crate::scenario::Harness::new();
let mut sketches = Vec::new();
for z in [0, 25] {
let sk = h.app.run("sketch.create", json!({"plane":{"origin":[0,0,z],"x_dir":[1,0,0],"y_dir":[0,1,0]}})).unwrap()["sketch"].as_u64().unwrap();
sketches.push(sk);
h.app.run("sketch.circle.center", json!({"center":[0,0],"radius":10})).unwrap();
h.app.run("sketch.finish", json!({})).unwrap();
}
h.app.set_origin_shown(false);
h.call("ui.camera", json!({"target":[0,0,12.5],"yaw":-0.6,"pitch":0.5,"distance":100}));
h.step(&json!({"start":"surface.loft"})).unwrap();
h.step(&json!({"click":{"world":[0,0,0]}})).unwrap();
assert_eq!(h.app.dialog.as_ref().unwrap().inputs[0].items, vec![Sel::Profile { sketch: sketches[0], index: 0 }]);
h.step(&json!({"click":{"world":[0,0,25]}})).unwrap();
let d = h.app.dialog.as_ref().unwrap();
let picks = vec![Sel::Profile { sketch: sketches[0], index: 0 }, Sel::Profile { sketch: sketches[1], index: 0 }];
assert_eq!(d.inputs[0].items, picks, "the second sketch must not replace the first loft section (#6400)");
let commands = apply_commands(&h.app, d).unwrap();
assert_eq!(commands[0].0, "surface.loft");
assert_eq!(commands[0].1["sections"], json!([{"sketch":sketches[0],"profiles":[0]}, {"sketch":sketches[1],"profiles":[0]}]));
h.step(&json!({"key":"Enter"})).unwrap();
assert!(h.app.dialog.is_none(), "{:?}", h.app.dialog);
let state = h.app.session.model.state();
let body = state.bodies.last().unwrap();
assert!(body.body.is_surface());
let area = body.mesh().measure().area;
assert!((area - 2.0 * std::f64::consts::PI * 10.0 * 25.0).abs() < 1.0, "{area}");
let feature = h.app.session.doc.features.last().unwrap().id;
let reopened = crate::dialogs::for_feature(&h.app, feature, None).unwrap();
assert_eq!(reopened.inputs[0].items, picks, "Edit Feature keeps both sections in pick order");
}
#[test]
fn surface_loft_dialog_makes_a_section_per_sketch() {
// A line in each of two sketches 5 apart: two sections, a 10 × 5 strip; Edit Feature brings