Sketch: sketch.create says which way the origin planes' sketch axes run (#10397)

On XZ a sketch's y runs along world -Z, so a value written as a height lands
below the plane; only the modelling skill's reference said so. The command's
parameter text now gives the axes of all three origin planes (XY: +X, +Y;
XZ: +X, -Z; YZ: +Y, +Z), and a test pins them.

Assisted-by: LLM
This commit is contained in:
Christian Glombek
2026-11-01 04:19:07 +00:00
committed by GitHub
parent 5c1aad8a09
commit 4c44126a4d
2 changed files with 16 additions and 2 deletions
+1 -1
View File
@@ -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)
+15 -1
View File
@@ -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"] {