Sketch: the first dimension scales a sketch drawn by eye (#1365) (#1416)

* Sketch: the first dimension scales a sketch drawn by eye (#1365)

Lines drawn by eye have no size of their own until a dimension gives them one, but the first
dimension kept every other drawn length and distorted the sketch to fit (a free construction
line through the origin turned instead of the shape moving). The dimension tool now scales
the whole sketch about its origin to the first length dimension, as long as nothing in the
sketch fixes a size yet: no other driving length dimension, nothing fixed, projected or
patterned. Every geometric constraint and angle holds on the scaled sketch. Later
dimensions size what they measure as before; sketch.dimension does this only with
scale_sketch: true, so scripts are unchanged.

Fixes #1365

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Scenario s01: dimension the box's height too, now that the first dimension scales the sketch

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bherbruckandClaude Opus 5.5 authored and GitHub committed 2026-10-15 13:13:14 -04:00
1 parent 8b7fa2602e
commit ef53bc46f3
6 files changed
+168 -8

No files matched your search

@@ -146,7 +146,8 @@ fn rectangle_side_and_fixed_origin_line_dimensions_preserve_other_constraints()
h.step(&json!({"key":"Enter"})).unwrap();
let state = h.app.session.world_state();
let solved = state.sketch(h.app.session.active_sketch.unwrap()).unwrap();
assert!((solved.profiles[0].area - 240.).abs() < 1e-5, "side dimensions keep rectangle width: {}", solved.profiles[0].area);
// The sketch's first dimension scales it (#1365): 20 × 10 becomes 24 × 12.
assert!((solved.profiles[0].area - 288.).abs() < 1e-5, "the first dimension scales the rectangle: {}", solved.profiles[0].area);
assert_eq!(h.app.session.undo.len(), undo + 1);
h.app.run("edit.undo", json!({})).unwrap();
assert_eq!(h.app.session.doc.to_json(), baseline);
@@ -342,9 +343,11 @@ fn placing_a_two_point_dimension_picks_horizontal_vertical_or_aligned() {
let b = sk.point(sk.resolve_point("l1.end").unwrap()).unwrap();
let spans = spans(a, b);
assert!((spans[measured] - 10.0).abs() < 1e-6, "placed at {at:?}: {a:?} {b:?}");
// A horizontal or vertical dimension leaves the other span as drawn.
// The sketch's first dimension scales it (#1365): the other span keeps its proportion.
if measured < 2 {
assert!((spans[1 - measured] - [12.0, 16.0][1 - measured]).abs() < 1e-6, "placed at {at:?}: {a:?} {b:?}");
let drawn = [12.0, 16.0];
let other = drawn[1 - measured] * 10.0 / drawn[measured];
assert!((spans[1 - measured] - other).abs() < 1e-6, "placed at {at:?}: {a:?} {b:?}");
}
}
}