* claim: #6000 * Sketch: explicit planes take a frame, world or component (#6000) sketch.create and sketch.redefine take frame: "world" (the default, as before) or "component" for an explicit {origin, x_dir, y_dir} plane. The reply says which frame the plane was read in, with a note when a world plane goes into a moved or turned component. frame on a named plane or a face is refused: those are where they are. 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:
@@ -286,3 +286,42 @@ fn root_picks_on_a_moved_component_build_where_it_is_shown() {
|
||||
let across = crate::view::construction_planes(&s).into_iter().find(|(_, n, _)| n == "Across").unwrap().2;
|
||||
assert!((across.origin.y - 40.0).abs() < 1e-6, "{across:?}");
|
||||
}
|
||||
|
||||
/// #6000: in a turned component, a named plane ("XY") is the component's own; an explicit
|
||||
/// `{origin, x_dir, y_dir}` is world unless `frame: "component"` says otherwise. The reply says
|
||||
/// which, with a note when the two differ.
|
||||
#[test]
|
||||
fn an_explicit_sketch_plane_is_read_in_the_frame_asked_for() {
|
||||
let mut s = moved_part();
|
||||
run(&mut s, "occurrence.move", json!({"occurrence": "Part:1", "axis": [1, 0, 0], "angle": "30 deg", "move_grounded": true}));
|
||||
let explicit = json!({"origin": [0, 0, 0], "x_dir": [1, 0, 0], "y_dir": [0, 1, 0]});
|
||||
let centre = |s: &mut Session, name: &str, p: Value| {
|
||||
let r = run(s, "sketch.create", p);
|
||||
run(s, "sketch.circle.center", json!({"center": [20, 10], "radius": 6}));
|
||||
run(s, "sketch.finish", json!({}));
|
||||
(r, *sketch_world_points(s, name).last().unwrap())
|
||||
};
|
||||
let (named, own) = centre(&mut s, "Named", json!({"plane": "XY", "name": "Named"}));
|
||||
assert!(named.get("frame").is_none(), "{named}");
|
||||
assert!((own.z - 5.0).abs() < 1e-6, "the component's XY is turned with it: {own:?}");
|
||||
|
||||
let (world, at) = centre(&mut s, "World", json!({"plane": explicit, "name": "World"}));
|
||||
assert_eq!(world["frame"], "world");
|
||||
assert!(world["note"].as_str().is_some_and(|n| n.contains("frame")), "{world}");
|
||||
assert!(at.z.abs() < 1e-6, "today's reading: on the world XY plane: {at:?}");
|
||||
|
||||
let (comp, at) = centre(&mut s, "Own", json!({"plane": explicit, "frame": "component", "name": "Own"}));
|
||||
assert_eq!(comp["frame"], "component");
|
||||
assert!(comp.get("note").is_none(), "{comp}");
|
||||
assert!(near(at, own), "the component's XY written out: {at:?} vs {own:?}");
|
||||
|
||||
// Redefine reads the same way.
|
||||
let r = run(&mut s, "sketch.redefine", json!({"sketch": "World", "plane": explicit, "frame": "component"}));
|
||||
assert_eq!(r["frame"], "component");
|
||||
assert!(near(*sketch_world_points(&mut s, "World").last().unwrap(), own));
|
||||
|
||||
for (p, why) in [(json!({"plane": "XY", "frame": "component"}), "explicit"), (json!({"plane": explicit, "frame": "local"}), "world")] {
|
||||
let e = s.execute("sketch.create", &p).expect_err("refused").to_string();
|
||||
assert!(e.contains(why), "{p}: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user