SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Redefine Sketch Plane names the plane a sketch is on now (#5103) (#5545)
dudedagger4210124c8ccfd7
diff --git a/assets/locales/en.json b/assets/locales/en.jsonindex 388bcf3ee9..73b8fea1f3 100644--- a/assets/locales/en.json+++ b/assets/locales/en.json@@ -143,6 +143,7 @@"Cube": "Cube","Current orthographic view (1:1 mm)": "Current orthographic view (1:1 mm)","Current perspective view": "Current perspective view",+ "Current plane": "Current plane","Curv. Comb": "Curv. Comb","Curvature (G2)": "Curvature (G2)","Curvature change (G3)": "Curvature change (G3)",@@ -2151,6 +2152,11 @@"sketch_panel.author": "Author placement: {path}","sketch_panel.dimension_hint": "Enter a value or expression, then press OK.","sketch_panel.move_hint": "Enter distances and an angle, then press OK.",+ "sketch_panel.plane_angle": "{plane}, turned by {angle}",+ "sketch_panel.plane_fixed": "A fixed plane",+ "sketch_panel.plane_flipped": "{plane}, from its other side",+ "sketch_panel.plane_offset": "{plane}, offset by {distance}",+ "sketch_panel.plane_origin": "The {plane} plane","sketch_panel.redefine_title": "{command}: {name}","sketch_panel.sheet_attachment": "Attached to a flat face of a sheet metal body; it follows that panel when the sheet changes.","sketch_panel.text_hint": "Edit the text and its placement, then press OK.",diff --git a/assets/locales/ja.json b/assets/locales/ja.jsonindex be5c267a32..02cc9e7cb4 100644--- a/assets/locales/ja.json+++ b/assets/locales/ja.json@@ -143,6 +143,7 @@"Cube": "キューブ","Current orthographic view (1:1 mm)": "現在の平行投影(実寸・mm)","Current perspective view": "現在の透視投影",+ "Current plane": "現在の平面","Curv. Comb": "曲率コーム","Curvature (G2)": "曲率 (G2)","Curvature change (G3)": "曲率変化 (G3)",@@ -2151,6 +2152,11 @@"sketch_panel.author": "作成時の配置: {path}","sketch_panel.dimension_hint": "値または式を入力し、OK を押してください。","sketch_panel.move_hint": "距離と角度を入力し、OK を押してください。",+ "sketch_panel.plane_angle": "{plane}、{angle} 回転",+ "sketch_panel.plane_fixed": "固定平面",+ "sketch_panel.plane_flipped": "{plane}(裏側から)",+ "sketch_panel.plane_offset": "{plane}、{distance} オフセット",+ "sketch_panel.plane_origin": "{plane} 平面","sketch_panel.redefine_title": "{command}:{name}","sketch_panel.sheet_attachment": "板金ボディの平面に接続されています。板金が変更されると、そのパネルに追従します。","sketch_panel.text_hint": "テキストと配置を編集し、OK を押してください。",diff --git a/assets/locales/zh.json b/assets/locales/zh.jsonindex 5bdea69615..32c41cbb7f 100644--- a/assets/locales/zh.json+++ b/assets/locales/zh.json@@ -143,6 +143,7 @@"Cube": "立方体","Current orthographic view (1:1 mm)": "当前正交视图(1:1毫米)","Current perspective view": "当前透视视图",+ "Current plane": "当前平面","Curv. Comb": "曲率梳","Curvature (G2)": "曲率 (G2)","Curvature change (G3)": "曲率变化 (G3)",@@ -2151,6 +2152,11 @@"sketch_panel.author": "创建时的放置:{path}","sketch_panel.dimension_hint": "输入数值或表达式,然后按“确定”。","sketch_panel.move_hint": "输入距离和角度,然后按“确定”。",+ "sketch_panel.plane_angle": "{plane},旋转 {angle}",+ "sketch_panel.plane_fixed": "固定平面",+ "sketch_panel.plane_flipped": "{plane}(从另一侧)",+ "sketch_panel.plane_offset": "{plane},偏移 {distance}",+ "sketch_panel.plane_origin": "{plane} 平面","sketch_panel.redefine_title": "{command}:{name}","sketch_panel.sheet_attachment": "附着到钣金实体的平面上;钣金变化时会跟随该面板。","sketch_panel.text_hint": "编辑文字及其位置,然后按“确定”。",diff --git a/crates/ui-egui/src/sketch_attachment_ui.rs b/crates/ui-egui/src/sketch_attachment_ui.rsindex 101d5f88b7..93974dcc62 100644--- a/crates/ui-egui/src/sketch_attachment_ui.rs+++ b/crates/ui-egui/src/sketch_attachment_ui.rs@@ -4,7 +4,7 @@ use egui::RichText;use serde_json::{Value, json};use solidcraft_engine::Sel;use solidcraft_engine::doc::face_anchor::plane_face_anchor;-use solidcraft_engine::doc::{EmbossFace, FaceAttachmentStatus, FeatureKind, mat_inverse};+use solidcraft_engine::doc::{EmbossFace, FaceAttachmentStatus, FeatureKind, PlaneRef, mat_inverse};use solidcraft_engine::geom::{Plane, Vec3};use crate::SolveApp;@@ -100,6 +100,25 @@ pub fn face_plane(app: &SolveApp, selection: &Sel) -> Option<Value> {}}+/// What a sketch's plane is, for the Redefine Sketch Plane panel: `XY`, a construction plane's+/// name, or the plane it's offset from, turned from or flipped from (#5103).+pub(crate) fn plane_description(plane: &PlaneRef) -> String {+ fn describe(plane: &PlaneRef, depth: usize) -> String {+ let base = |b: &PlaneRef| if depth < 8 { describe(b, depth + 1) } else { crate::i18n::tr("sketch_panel.plane_fixed").to_owned() };+ match plane {+ PlaneRef::Origin { name } => crate::i18n::format("sketch_panel.plane_origin", &[("plane", name)]),+ PlaneRef::Construction { name } => name.to_string(),+ PlaneRef::Offset { base: b, distance } => {+ crate::i18n::format("sketch_panel.plane_offset", &[("plane", &base(b)), ("distance", distance)])+ }+ PlaneRef::AtAngle { base: b, angle, .. } => crate::i18n::format("sketch_panel.plane_angle", &[("plane", &base(b)), ("angle", angle)]),+ PlaneRef::Flipped { base: b, .. } => crate::i18n::format("sketch_panel.plane_flipped", &[("plane", &base(b))]),+ _ => crate::i18n::tr("sketch_panel.plane_fixed").to_owned(),+ }+ }+ describe(plane, 0)+}+fn face_label(app: &SolveApp, selection: &Sel) -> String {let Sel::Face { body, .. } = selection else { return String::new() };let placed = app.session.placed_document();@@ -204,6 +223,13 @@ pub fn panel(app: &mut SolveApp, ctx: &egui::Context) {*plane}FaceAttachmentStatus::Fixed { plane } => {+ // Name the plane it's on now: an origin or construction plane (#5103).+ if let Some(FeatureKind::Sketch { plane: on, .. }) = app.session.doc.feature(sketch).map(|f| &f.kind) {+ let now = plane_description(on);+ ui_kit::row(ui, "Current plane", |ui| {+ ui.label(now);+ });+ }ui.label(crate::i18n::tr_label("Sketch plane has no body-face attachment."));*plane}diff --git a/crates/ui-egui/src/sketch_attachment_ui_tests.rs b/crates/ui-egui/src/sketch_attachment_ui_tests.rsindex 98a817d5de..c0b1a60ee9 100644--- a/crates/ui-egui/src/sketch_attachment_ui_tests.rs+++ b/crates/ui-egui/src/sketch_attachment_ui_tests.rs@@ -400,3 +400,22 @@ fn plane_redefinition_uses_dense_card_and_keeps_command_preview_cancel_and_ok()assert_eq!(h.app.session.doc.to_json(), before);}}++/// #5103: Redefine Sketch Plane names the plane a sketch is on now, not only "no body-face+/// attachment": an origin plane, a construction plane, and planes built from them.+#[test]+fn redefine_panel_names_the_plane_a_sketch_is_on() {+ use crate::sketch_attachment_ui::plane_description;+ let mut h = Harness::new();+ h.app.run("construct.plane.offset", json!({"base": "XY", "offset": 10, "name": "Shelf"})).unwrap();+ for (plane, expected) in [("XZ", "The XZ plane"), ("Shelf", "Shelf")] {+ let id = h.app.run("sketch.create", json!({"plane": plane})).unwrap()["sketch"].as_u64().unwrap();+ h.app.run("sketch.finish", json!({})).unwrap();+ let FeatureKind::Sketch { plane: on, .. } = &h.app.session.doc.feature(id).unwrap().kind else { panic!("a sketch") };+ assert_eq!(plane_description(on), expected, "{plane}");+ }+ let xy = Box::new(PlaneRef::Origin { name: "XY".into() });+ let offset = PlaneRef::Offset { base: xy.clone(), distance: "12 mm".into() };+ assert_eq!(plane_description(&offset), "The XY plane, offset by 12 mm");+ assert_eq!(plane_description(&PlaneRef::Flipped { base: xy, about_y: false }), "The XY plane, from its other side");+}