diff --git a/crates/engine/src/cmd/sketch.rs b/crates/engine/src/cmd/sketch.rs index 0f06b8aba..ae94a70e3 100644 --- a/crates/engine/src/cmd/sketch.rs +++ b/crates/engine/src/cmd/sketch.rs @@ -37,7 +37,7 @@ pub static COMMANDS: &[CommandSpec] = &[ CommandSpec::new("sketch.create", "Create Sketch", create_sketch) .at("SOLID", "CREATE") .icon("sketch") - .params("plane: XY|XZ|YZ | construction plane name or id | {origin?: [x,y,z] numbers in mm, default [0,0,0] (not an expression), x_dir, y_dir} (in world coordinates unless frame says otherwise; a named plane is the active component's own) | {face: [world x,y,z], body?: exact world body, index?: face index, path?: complete occurrence ids, fixed?: bool}; new face attachments require a unique certified source (a flat face of a sheet metal body attaches to its panel instead, in the flat pattern's coordinates), fixed:true explicitly freezes the selected plane; offset?: expr, flip?: bool | \"x\" | \"y\" (not on a face: sketch the plane from its other side, so the normal and the default extrude direction are reversed; a half turn about the plane's own x or y axis, true picks the one keeping the sketch's y axis upward; offset still moves along the unflipped normal), frame?: world (default) | component (which coordinates an explicit plane is in; the reply's `frame` says which, with a `note` when the active component is moved or turned), project_edges?: bool, activate_part?: bool (default false; on a face of a body of another component than the active one: activate that component at the picked placement first, as component.activate would, and make the sketch there; it stays active afterwards and the reply's `activated` names it), name?"), + .params("plane: XY|XZ|YZ (sketch x, y along world +X, +Y on XY; +X, -Z on XZ; +Y, +Z on YZ) | construction plane name or id | {origin?: [x,y,z] numbers in mm, default [0,0,0] (not an expression), x_dir, y_dir} (in world coordinates unless frame says otherwise; a named plane is the active component's own) | {face: [world x,y,z], body?: exact world body, index?: face index, path?: complete occurrence ids, fixed?: bool}; new face attachments require a unique certified source (a flat face of a sheet metal body attaches to its panel instead, in the flat pattern's coordinates), fixed:true explicitly freezes the selected plane; offset?: expr, flip?: bool | \"x\" | \"y\" (not on a face: sketch the plane from its other side, so the normal and the default extrude direction are reversed; a half turn about the plane's own x or y axis, true picks the one keeping the sketch's y axis upward; offset still moves along the unflipped normal), frame?: world (default) | component (which coordinates an explicit plane is in; the reply's `frame` says which, with a `note` when the active component is moved or turned), project_edges?: bool, activate_part?: bool (default false; on a face of a body of another component than the active one: activate that component at the picked placement first, as component.activate would, and make the sketch there; it stays active afterwards and the reply's `activated` names it), name?"), CommandSpec::new("sketch.edit", "Edit Sketch", edit_sketch).noundo().icon("sketch").params("sketch: id or name"), CommandSpec::new("sketch.finish", "Finish Sketch", finish_sketch).at("SKETCH", "FINISH SKETCH").icon("finish").enabled(in_sketch).noundo(), CommandSpec::new("sketch.cancel", "Cancel Sketch", cancel_sketch) diff --git a/crates/engine/src/cmd/sketch_flip_tests.rs b/crates/engine/src/cmd/sketch_flip_tests.rs index 2385cb743..14222e844 100644 --- a/crates/engine/src/cmd/sketch_flip_tests.rs +++ b/crates/engine/src/cmd/sketch_flip_tests.rs @@ -3,7 +3,7 @@ use serde_json::{Value, json}; use solidcraft_doc::{FeatureKind, PlaneRef}; -use solidcraft_geom::{Plane, Vec3}; +use solidcraft_geom::{Plane, Vec2, Vec3}; use crate::Session; @@ -26,6 +26,20 @@ fn close(a: Vec3, b: Vec3) -> bool { a.dist(b) < 1e-9 } +/// The origin planes' sketch axes, as `sketch.create` documents them: sketch x and y run along world +X, +Y on XY; +/// +X, -Z on XZ; +Y, +Z on YZ. +#[test] +fn origin_planes_put_the_sketch_axes_where_sketch_create_says() { + let (x, y, z) = (Vec3::new(1.0, 0.0, 0.0), Vec3::new(0.0, 1.0, 0.0), Vec3::new(0.0, 0.0, 1.0)); + for (name, u, v) in [("XY", x, y), ("XZ", x, z * -1.0), ("YZ", y, z)] { + let mut s = Session::default(); + let id = run(&mut s, "sketch.create", json!({"plane": name}))["sketch"].as_u64().unwrap(); + let p = sketch_plane(&s, id); + let (su, sv) = (p.to_world(Vec2::new(1.0, 0.0)), p.to_world(Vec2::new(0.0, 1.0))); + assert!(close(su, u) && close(sv, v), "{name}: sketch x lands on {su:?}, sketch y on {sv:?}"); + } +} + #[test] fn without_flip_a_sketch_keeps_the_planes_own_side_and_saves_as_before() { for name in ["XY", "XZ", "YZ"] {