SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
fix(sketch): a line of another sketch projects from the Project dialog (#10390)
Homero Thompson9e3cf05c4f31
diff --git a/crates/ui-egui/src/tools.rs b/crates/ui-egui/src/tools.rsindex fa8254e0f7..0865215afd 100644--- a/crates/ui-egui/src/tools.rs+++ b/crates/ui-egui/src/tools.rs@@ -785,6 +785,9 @@ pub(crate) fn projection_preselection(selection: &[solidcraft_engine::Sel]) -> OSome(match item {Sel::Body { name } => json!({"body":name}),Sel::ExternalSketchCurve { sketch, id } => json!({"sketch":sketch,"curve":id}),+ // A straight line of another sketch, picked into the dialog, names its sketch+ // (#3726): the same reference the external pick stands for (#10291).+ Sel::SketchCurve { id, sketch: Some(sketch) } => json!({"sketch":sketch,"curve":id}),Sel::ExternalSketchPoint { sketch, id } => json!({"sketch":sketch,"point":id}),Sel::Vertex { body, point } => json!({"body":body,"vertex":[point.x,point.y,point.z]}),Sel::Edge { body, point, .. } => json!({"body":body,"edge":[point.x,point.y,point.z]}),diff --git a/crates/ui-egui/tests/projection_preselection.rs b/crates/ui-egui/tests/projection_preselection.rsindex 116b8f3e48..8e65e94b50 100644--- a/crates/ui-egui/tests/projection_preselection.rs+++ b/crates/ui-egui/tests/projection_preselection.rs@@ -18,6 +18,47 @@ fn setup() -> (Harness, u64) {(h, source)}+/// #10291: a line of another sketch, picked while the Project dialog is open, projects.+/// The pick names the sketch it came from, so the dialog's geometry input holds it and the+/// command gets a reference to it, even when the two sketches lie in parallel planes.+#[test]+fn a_line_of_another_sketch_picked_in_the_project_dialog_projects() {+ let mut h = Harness::new();+ // The options dialog is the workflow of the bug report: Project opens a dialog that+ // takes the geometry to project.+ h.app.preferences.project_options_dialog = true;+ // Sketch 1 on plane 1.+ let source = h.app.run("sketch.create", json!({"plane":"XY"})).unwrap()["sketch"].as_u64().unwrap();+ h.app.run("sketch.line", json!({"points":[[10,10],[30,10]],"infer":false})).unwrap();+ h.app.run("sketch.finish", json!({})).unwrap();+ // Plane 2 parallel to plane 1, and sketch 2 on it.+ h.app.run("construct.plane.offset", json!({"base":"XY","offset":10,"name":"Plane2"})).unwrap();+ h.app.run("sketch.create", json!({"plane":"Plane2"})).unwrap();+ h.call("ui.set", json!({"shownSketches":[source]}));+ h.call("ui.view", json!({"view":"top"}));+ // Project, then pick the line of sketch 1 in the viewport.+ h.app.start("sketch.project");+ h.frames(4);+ assert!(h.app.dialog.is_some(), "Project opens its options dialog");+ h.step(&json!({"click":{"world":[20,10,0]}})).unwrap();+ let d = h.app.dialog.as_ref().expect("the dialog is still open");+ assert_eq!(d.inputs[0].items.len(), 1, "the line of the other sketch is in the input: {:?}", d.inputs[0].items);+ h.step(&json!({"click":{"handle":"dialog:ok"}})).unwrap();+ h.settle();+ assert!(h.app.dialog.is_none(), "the dialog closes on a valid pick: {:?}", h.app.dialog.as_ref().and_then(|d| d.error.clone()));+ assert!(!h.app.status.as_ref().is_some_and(|(_, _, error)| *error), "{:?}", h.app.status);+ let sketch = h.app.session.active_sketch.expect("Project leaves the sketch active");+ let state = h.app.session.world_state();+ let sk = &state.sketch(sketch).unwrap().sketch;+ assert!(sk.curves.iter().any(|curve| curve.link.is_some()), "the line is projected into the sketch");+ // The projection names the sketch it came from, so it follows it.+ assert!(+ sk.links.iter().any(|l| matches!(&l.source, solidcraft_engine::sketch::LinkSource::SketchCurve { sketch, .. } if *sketch == source)),+ "{:?}",+ sk.links+ );+}+#[test]fn clicked_external_curve_and_point_project_with_source_identity_and_one_undo() {let (mut h, source) = setup();