diff --git a/assets/locales/pending/sketch-align-points.json b/assets/locales/pending/sketch-align-points.json
new file mode 100644
index 000000000..6e697b75b
--- /dev/null
+++ b/assets/locales/pending/sketch-align-points.json
@@ -0,0 +1,34 @@
+{
+ "en": {
+ "prefs.sketch_align_points": "Line up with other sketch points while drawing",
+ "prefs.sketch_align_points_note": "While drawing, a point lines up horizontally with one sketch point and vertically with another at the same time, with a dotted guide, and the click keeps both alignments. Off: only with the previous point, one axis at a time."
+ },
+ "ar": {
+ "prefs.sketch_align_points": "المحاذاة مع نقاط الرسم الأخرى أثناء الرسم",
+ "prefs.sketch_align_points_note": "أثناء الرسم، تتحاذى النقطة أفقيًا مع نقطة رسم وعموديًا مع نقطة أخرى في الوقت نفسه، مع خط إرشادي منقط، وتحتفظ النقرة بالمحاذاتين. عند الإيقاف: مع النقطة السابقة فقط، محور واحد في كل مرة."
+ },
+ "de": {
+ "prefs.sketch_align_points": "Beim Zeichnen an anderen Skizzenpunkten ausrichten",
+ "prefs.sketch_align_points_note": "Beim Zeichnen richtet sich ein Punkt zugleich waagerecht an einem Skizzenpunkt und senkrecht an einem anderen aus, mit einer gepunkteten Hilfslinie; der Klick behält beide Ausrichtungen. Aus: nur am vorherigen Punkt, jeweils eine Achse."
+ },
+ "he": {
+ "prefs.sketch_align_points": "יישור לנקודות סקיצה אחרות בזמן השרטוט",
+ "prefs.sketch_align_points_note": "בזמן השרטוט, נקודה מתיישרת אופקית עם נקודת סקיצה אחת ואנכית עם אחרת בו-זמנית, עם קו עזר מנוקד, והלחיצה שומרת את שני היישורים. כבוי: רק עם הנקודה הקודמת, ציר אחד בכל פעם."
+ },
+ "ja": {
+ "prefs.sketch_align_points": "描画中にほかのスケッチ点に揃える",
+ "prefs.sketch_align_points_note": "描画中、点が一つのスケッチ点と水平に、別の点と垂直に同時に揃い、点線のガイドが表示されます。クリックすると両方の整列が保持されます。オフ: 直前の点にのみ、一度に一方向だけ揃えます。"
+ },
+ "ko": {
+ "prefs.sketch_align_points": "그리는 동안 다른 스케치 점에 맞추기",
+ "prefs.sketch_align_points_note": "그리는 동안 점이 한 스케치 점과 수평으로, 다른 점과 수직으로 동시에 맞춰지고 점선 안내선이 표시됩니다. 클릭하면 두 정렬이 모두 유지됩니다. 끄기: 이전 점에만, 한 번에 한 축씩 맞춥니다."
+ },
+ "vi": {
+ "prefs.sketch_align_points": "Căn theo các điểm phác thảo khác khi vẽ",
+ "prefs.sketch_align_points_note": "Khi vẽ, một điểm được căn ngang theo một điểm phác thảo và căn dọc theo điểm khác cùng lúc, kèm đường dẫn chấm; cú nhấp giữ cả hai ràng buộc căn. Tắt: chỉ căn theo điểm trước, mỗi lần một trục."
+ },
+ "zh": {
+ "prefs.sketch_align_points": "绘制时与其他草图点对齐",
+ "prefs.sketch_align_points_note": "绘制时,点可同时与一个草图点水平对齐、与另一个草图点竖直对齐,并显示虚线参考线;单击后保留两个对齐约束。关闭:仅与上一点对齐,每次一个方向。"
+ }
+}
diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rs
index 4d3c1eb09..681e49cd5 100644
--- a/crates/ui-egui/src/prefs.rs
+++ b/crates/ui-egui/src/prefs.rs
@@ -1229,6 +1229,10 @@ preference_settings! {
suppress_sketch_snap: ModifierCombo = ModifierCombo::CTRL_ALT, PAGE_SKETCH;
/// Temporary horizontal/vertical guides from hovered centres and edge midpoints.
sketch_tracking_guides: bool = true, PAGE_SKETCH;
+ /// Drawing lines a point up with the sketch's points on both axes at once, keeping the
+ /// horizontal or vertical snap to the previous point, and the click adds the alignments
+ /// (#7828). Off by default: only with the previous point, one axis at a time, as before.
+ sketch_align_points: bool = false, PAGE_SKETCH;
/// Open Project's options before picking; off restores its previous direct-pick workflow.
project_options_dialog: bool = true, PAGE_SKETCH;
/// Whether Alt/Option also frees gizmo / canvas manipulator arrows (Primary always does).
@@ -4806,6 +4810,7 @@ mod tests {
("suppress_sketch_snap", json!(ModifierCombo::NONE), PAGE_SKETCH),
("sketch_state_icons", json!(false), PAGE_SKETCH),
("sketch_tracking_guides", json!(false), PAGE_SKETCH),
+ ("sketch_align_points", json!(true), PAGE_SKETCH),
("msaa", json!(8), PAGE_GRAPHICS),
("single_surface_analysis", json!(false), PAGE_GRAPHICS),
];
diff --git a/crates/ui-egui/src/prefs/sketch.rs b/crates/ui-egui/src/prefs/sketch.rs
index b72466c2c..6455f8835 100644
--- a/crates/ui-egui/src/prefs/sketch.rs
+++ b/crates/ui-egui/src/prefs/sketch.rs
@@ -7,6 +7,8 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
ui_kit::settings_section(ui, "sketch", app.tr("prefs.sketching"), |ui| {
ui_kit::checkbox(ui, app.tr("prefs.sketch_tracking_guides"), &mut app.preferences.sketch_tracking_guides)
.on_hover_text(app.tr("prefs.sketch_tracking_guides_note"));
+ ui_kit::checkbox(ui, app.tr("prefs.sketch_align_points"), &mut app.preferences.sketch_align_points)
+ .on_hover_text(app.tr("prefs.sketch_align_points_note"));
let mut auto = app.session.auto_project;
if ui_kit::checkbox(ui, crate::i18n::tr_label("Project face edges into new sketches"), &mut auto).changed() {
let _ = app.run("sketch.auto_project", json!({"value": auto}));
diff --git a/crates/ui-egui/src/sketch_guidance_ui_tests.rs b/crates/ui-egui/src/sketch_guidance_ui_tests.rs
index 8a659ec81..63185e10a 100644
--- a/crates/ui-egui/src/sketch_guidance_ui_tests.rs
+++ b/crates/ui-egui/src/sketch_guidance_ui_tests.rs
@@ -355,3 +355,112 @@ fn tracking_does_not_leak_outside_the_viewport_or_into_another_sketch() {
h.frames(3);
assert!(h.app.viewport.tracking.guide.is_none());
}
+
+/// Lining up while drawing (#7828), turned on (it is off by default): a fixture whose points sit
+/// off the grid, so that only lining up can place a point exactly on them, seen from the top at
+/// about 1 mm of snap tolerance.
+fn lining_up_fixture(points: &[(&str, Value)]) -> Harness {
+ let mut h = Harness::new();
+ h.app.home.open = false;
+ h.app.preferences.look_at_anim = false;
+ assert!(!h.app.preferences.sketch_align_points, "off unless turned on");
+ h.app.preferences.sketch_align_points = true;
+ h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();
+ for (command, params) in points {
+ h.app.run(command, params.clone()).unwrap();
+ }
+ h.call("ui.view", json!({"view":"top"}));
+ h.call("ui.camera", json!({"target":[25,0,0],"distance":180}));
+ h.frames(3);
+ h
+}
+
+/// The active sketch's point at `at`, and the points level (`Horizontal`) or plumb (`Vertical`)
+/// constraints tie it to.
+fn point_and_alignments(h: &Harness, at: [f64; 2]) -> Option<(String, Vec<(&'static str, String)>)> {
+ use solidcraft_engine::sketch::ConstraintKind::{HorizontalPoints, VerticalPoints};
+ let st = h.app.session.world_state();
+ let sk = &st.sketch(h.app.session.active_sketch?)?.sketch;
+ let at = solidcraft_engine::geom::Vec2::new(at[0], at[1]);
+ let i = sk.points.iter().position(|p| p.pos.dist(at) < 1e-9)?;
+ let id = |k: usize| sk.points.get(k).map(|p| p.id.clone()).unwrap_or_default();
+ let tied = sk
+ .constraints
+ .iter()
+ .filter_map(|c| match c.kind {
+ HorizontalPoints { p, q } if p == i || q == i => Some(("Horizontal", id(if p == i { q } else { p }))),
+ VerticalPoints { p, q } if p == i || q == i => Some(("Vertical", id(if p == i { q } else { p }))),
+ _ => None,
+ })
+ .collect();
+ Some((id(i), tied))
+}
+
+#[test]
+fn line_up_takes_the_nearest_point_on_each_axis_on_its_own() {
+ use crate::sketch_tools::{Lined, line_up};
+ use solidcraft_engine::geom::Vec2;
+ let points = [(Some("a".to_string()), Vec2::new(0.0, 10.4)), (Some("b".to_string()), Vec2::new(50.3, -30.0)), (None, Vec2::new(5.0, 10.2))];
+ let (level, plumb) = line_up(&points, Vec2::new(50.0, 10.0), 0.5);
+ assert_eq!(level, Some(Lined { id: None, at: Vec2::new(5.0, 10.2), horizontal: true }), "the nearer of the two level points");
+ assert_eq!(plumb, Some(Lined { id: Some("b".into()), at: Vec2::new(50.3, -30.0), horizontal: false }));
+ // Right on a point is a point snap's business, not lining up; far from all, nothing.
+ assert_eq!(line_up(&points, Vec2::new(50.3, -30.1), 0.5), (None, None));
+ assert_eq!(line_up(&points, Vec2::new(25.0, -10.0), 0.5), (None, None));
+}
+
+/// #8089, a duplicate of #7828: a rectangle drawn beside another takes its height from one
+/// rectangle and its width from a point below, both at once, and keeps both alignments, in the
+/// rectangle's one undo step. With the preference off, only one axis lines up, as before.
+#[test]
+fn a_rectangle_corner_lines_up_with_two_points_at_once_and_keeps_both() {
+ for aligning in [true, false] {
+ let mut h = lining_up_fixture(&[
+ ("sketch.rectangle.two_point", json!({"p0":[0,0],"p1":[20.37,10.43]})),
+ ("sketch.point", json!({"point":[50.37,-30.21]})),
+ ]);
+ h.app.preferences.sketch_align_points = aligning;
+ let undo = h.app.session.undo.len();
+ let below = point_and_alignments(&h, [50.37, -30.21]).unwrap().0;
+ step(&mut h, json!({"start":"sketch.rectangle.two_point"}));
+ step(&mut h, json!({"click":{"sketch":[30,0.3]}}));
+ step(&mut h, json!({"move":{"sketch":[50.2,10.6]}}));
+ if aligning {
+ step(&mut h, json!({"expect":{"count":{"name":"sketch_align_guides","value":2}}}));
+ }
+ step(&mut h, json!({"click":{"sketch":[50.2,10.6]}}));
+ let corner = point_and_alignments(&h, [50.37, 10.43]);
+ if !aligning {
+ assert!(corner.is_none(), "off: the corner follows the grid, not the other points");
+ continue;
+ }
+ let (_, tied) = corner.expect("the corner lands level with the rectangle's top and plumb with the point");
+ assert!(tied.iter().any(|(kind, to)| *kind == "Vertical" && *to == below), "{tied:?}");
+ assert!(tied.iter().any(|(kind, _)| *kind == "Horizontal"), "{tied:?}");
+ let (_, start) = point_and_alignments(&h, [30.0, 0.0]).expect("the first corner lines up with the bottom");
+ assert!(start.iter().any(|(kind, _)| *kind == "Horizontal"), "{start:?}");
+ assert_eq!(h.app.session.undo.len(), undo + 1, "the alignments are in the rectangle's undo step");
+ }
+}
+
+/// #7828: a line kept horizontal from its start also lines up under a point above, and the
+/// click keeps both: the line's Horizontal and the end's alignment with that point.
+#[test]
+fn a_horizontal_line_ends_plumb_with_a_point_above_and_keeps_both() {
+ let mut h = lining_up_fixture(&[("sketch.point", json!({"point":[20.37,30.13]}))]);
+ let above = point_and_alignments(&h, [20.37, 30.13]).unwrap().0;
+ step(&mut h, json!({"start":"sketch.line"}));
+ step(&mut h, json!({"click":{"sketch":[0,0]}}));
+ step(&mut h, json!({"move":{"sketch":[20.2,0.15]}}));
+ step(&mut h, json!({"expect":{"count":{"name":"sketch_align_guides","value":1}}}));
+ step(&mut h, json!({"click":{"sketch":[20.2,0.15]}}));
+ step(&mut h, json!({"key":"Escape"}));
+ let (_, tied) = point_and_alignments(&h, [20.37, 0.0]).expect("the end is level with the start and plumb with the point");
+ assert_eq!(tied, [("Vertical", above)]);
+ let st = h.app.session.world_state();
+ let sk = &st.sketch(h.app.session.active_sketch.unwrap()).unwrap().sketch;
+ assert!(
+ sk.constraints.iter().any(|c| matches!(c.kind, solidcraft_engine::sketch::ConstraintKind::Horizontal { .. })),
+ "the line stays horizontal"
+ );
+}
diff --git a/crates/ui-egui/src/sketch_tools.rs b/crates/ui-egui/src/sketch_tools.rs
index 0a8fa3a9f..d64c84aaf 100644
--- a/crates/ui-egui/src/sketch_tools.rs
+++ b/crates/ui-egui/src/sketch_tools.rs
@@ -85,7 +85,11 @@ thread_local! {
static PICKED: RefCell