From 8fa3393da5913673b0e6cfb3f1b69e3eb072b8a6 Mon Sep 17 00:00:00 2001 From: Karl Von Richter Date: Sat, 31 Oct 2026 10:18:49 +1000 Subject: [PATCH 1/2] frame(chore): claim continuous chassis members (#9792) Claim the curved and continuous member-path step of the chassis request under #4003 before implementation. Signed-off-by: Karl Von Richter From d8ddb29212efbc64e9716153df3593d568e029f1 Mon Sep 17 00:00:00 2001 From: Karl Von Richter Date: Wed, 4 Nov 2026 15:08:12 +1000 Subject: [PATCH 2/2] frame(feat): create bent members along connected sketch curves Create frame members on selected planar and spatial circular arcs, or one physical member along an ordered tangent line/arc chain. Carry the section through compound bends and preserve the member name through edits, reversal, undo and reopening. Recognize straight paths from their defining or retained exact curves and bound bend clearance from exact section geometry. Support the current solidcore record types and path reversal API without changing the kernel. Keep analytic chassis cases in the existing engine test file, and route frame evaluation through the control worker so the window reuses the sweep. Expose continuous creation in the Frame Member dialog with typed command parameters, translated messages and a pending design-format note. Document the workflow and the separate bend-list and cope-template work. Signed-off-by: Karl Von Richter --- ROADMAP.md | 2 +- apps/solidcraft-cli/src/recipe.rs | 9 + .../pending/frame-continuous-paths.json | 34 ++ attribution/pending/frame-continuous-paths.md | 1 + crates/doc/src/document.rs | 8 +- crates/doc/src/eval_frame.rs | 325 ++++++++++++++---- .../format/pending/frame-continuous-paths.rs | 4 + crates/engine/src/cmd/frame.rs | 31 +- crates/engine/src/cmd/frame_tests.rs | 222 +++++++++++- crates/engine/src/schema/frame.rs | 61 ++++ crates/engine/src/schema/frame_tests.rs | 46 +++ crates/engine/src/schema/mod.rs | 1 + crates/engine/src/schema/unconverted.txt | 1 - crates/ui-egui/src/control_job.rs | 1 + crates/ui-egui/src/dialogs_frame.rs | 20 +- crates/ui-egui/src/dialogs_frame_tests.rs | 30 ++ .../ui-egui/src/history_off_thread_tests.rs | 45 +++ docs/book/src/reference/glossary.md | 10 + docs/frames.md | 45 ++- docs/roadmap-detail.md | 2 +- 20 files changed, 798 insertions(+), 100 deletions(-) create mode 100644 assets/locales/pending/frame-continuous-paths.json create mode 100644 attribution/pending/frame-continuous-paths.md create mode 100644 crates/doc/src/format/pending/frame-continuous-paths.rs create mode 100644 crates/engine/src/schema/frame.rs create mode 100644 crates/engine/src/schema/frame_tests.rs diff --git a/ROADMAP.md b/ROADMAP.md index 0ee1e258eef..0df55fd8a19 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -146,7 +146,7 @@ PCB / Package, Render, Animation, Simulation, Manufacture/CAM, Drawings. | M12 | Release: cross-platform packages, verification and deliberate publication implemented; original current-UI demo refreshed. Trusted distribution signing and broader performance work remain | in progress | 16 | | M14 | Configurations: a table of rows (parameter expressions and feature suppressions per row) switched with config.activate (undoable, all or nothing), kept through parameter renames and feature deletes (config.configure, config.table, config.column/row/activate). Per-row body materials and appearances (library looks, custom colour/opacity and clearing overrides), undoable activation and save/reopen: done. Ordered typed configuration rules, atomic validation and structured rule editing: done. Component appearance and certified semantic face style columns, atomic preview/apply and independent-copy remapping: done. Exact constructed sketch-side and immutable imported-face lineage now preserve legacy names and reject retargeting. Left: ambiguous shifted/two-sided caps | in progress | 4 | | M13 | Never lose work: atomic saves (temporary file, flush, rename; a crash at any moment leaves the old file or the new one) with the replaced version kept as `.bak`; autosave of unsaved changes to the recovery folder every 5 minutes (preference) and after big operations, only when something changed; "Recover unsaved design?" on the next launch (`doc.recovery_list`, `doc.recover`, `doc.recovery_discard`); a kill-mid-save test (process killed while saving a 0.5 MB design 25 times). File format: `"format": "solidcraft/12"`, older formats upgraded step by step (`doc::format`), newer ones refused with a message, out-of-range numbers and broken placements refused; a corpus of designs saved by M0, components-era, joints-era and current builds (apps/solidcraft-cli/tests/corpus) that must open and evaluate as saved; damaged and hostile variants (truncation, bit flips, hostile values, removed keys, repeated features, deep nesting) never panic | done | 6 | -| M15 | Frames and weldments (#4003): structural members along 2D and 3D sketch lines, butt and mitre corners, trim to faces and bodies, end caps, gussets, cosmetic welds and a cut list. Done: the profile library (`frame.profile.list`, `frame.profile.properties`, `frame.profile.insert`): bar, round bar, rectangular and round tube, angle, channel and I-beam, each SolidCraft's own parametric definition with exact fillet arcs and exact section properties (area, centroid, second moments), tested against hand-computed values; members (`frame.member`): one body per straight line of a 2D or 3D frame sketch, following parameter edits, with a built-in profile (its dimensions parameter expressions) or a profile sketch (its drawn material by alternating nested loops), anchor, angle and mirror; each member's name kept with its line. Left: corners, trims, end caps, gussets, welds, cut list, FRAME tab and dialogs | in progress | 60 | +| M15 | Frames and weldments (#4003): structural members along 2D and 3D sketch lines, butt and mitre corners, trim to faces and bodies, end caps, gussets, cosmetic welds and a cut list. Done: the profile library (`frame.profile.list`, `frame.profile.properties`, `frame.profile.insert`): bar, round bar, rectangular and round tube, angle, channel and I-beam, each SolidCraft's own parametric definition with exact fillet arcs and exact section properties (area, centroid, second moments), tested against hand-computed values; members (`frame.member`): separate selected 2D/3D lines or circular arcs, or one continuous tangent line/arc path per physical member (#9792), following parameter edits, with a built-in profile (its dimensions parameter expressions) or a profile sketch (its drawn material by alternating nested loops), anchor, angle and mirror; each member's name kept with its line or continuous path. Left: corners, trims, end caps, gussets, welds, cut list, bend lists (#9795), flattened round-tube cope DXF templates (#9796), FRAME tab and dialogs | in progress | 60 | M6 navigation preferences include **Touchpad**: Shift + pointer movement pans, Alt/Option + pointer movement orbits without a mouse button, and vertical scrolling zooms. Other presets diff --git a/apps/solidcraft-cli/src/recipe.rs b/apps/solidcraft-cli/src/recipe.rs index d5a810b09c8..2acf2a5a5dd 100644 --- a/apps/solidcraft-cli/src/recipe.rs +++ b/apps/solidcraft-cli/src/recipe.rs @@ -294,6 +294,15 @@ pub fn to_script(recipe: &Value) -> Result { let bodies = f.get("result_bodies").cloned().unwrap_or(json!([])); match f.get("op").and_then(Value::as_str) { Some("sketch") => sketch_cmds(f, &mut out)?, + Some("frame_member") => { + let mut p = json!({"name": name}); + for key in ["sketch", "lines", "continuous", "profile", "profile_sketch", "profiles", "anchor", "angle", "mirror", "body_name"] { + if let Some(v) = f.get(key) { + p[key] = v.clone(); + } + } + out.push(json!({"command": "frame.member", "params": p})); + } Some("extrude") => { let mut p = json!({"sketch": profile_sketch(f), "profiles": profiles_of(f), "operation": op(f), "name": name, "body_names": bodies}); // Thin: {sketch, curves, thickness, side?, thickness2?} instead of profiles. diff --git a/assets/locales/pending/frame-continuous-paths.json b/assets/locales/pending/frame-continuous-paths.json new file mode 100644 index 00000000000..9ebfac93fa9 --- /dev/null +++ b/assets/locales/pending/frame-continuous-paths.json @@ -0,0 +1,34 @@ +{ + "en": { + "ui.frame.continuous": "One Continuous Member", + "ui.frame.continuous_requires_selection": "Select connected lines and arcs in path order; turn off All Lines for one continuous member." + }, + "ar": { + "ui.frame.continuous": "عنصر هيكلي واحد متصل", + "ui.frame.continuous_requires_selection": "حدّد خطوطًا وأقواسًا متصلة بترتيب المسار؛ عطّل «كل الخطوط» لإنشاء عنصر هيكلي واحد متصل." + }, + "de": { + "ui.frame.continuous": "Ein durchgehendes Rahmenelement", + "ui.frame.continuous_requires_selection": "Zusammenhängende Linien und Bögen in Pfadreihenfolge auswählen; für ein durchgehendes Rahmenelement Alle Linien ausschalten." + }, + "he": { + "ui.frame.continuous": "איבר מסגרת רציף אחד", + "ui.frame.continuous_requires_selection": "בחרו קווים וקשתות מחוברים לפי סדר המסלול; בטלו את ״כל הקווים״ כדי ליצור איבר מסגרת רציף אחד." + }, + "ja": { + "ui.frame.continuous": "1 本の連続部材", + "ui.frame.continuous_requires_selection": "接続された線と円弧をパスの順に選択し、連続部材では「すべての線」をオフにしてください。" + }, + "ko": { + "ui.frame.continuous": "하나의 연속 부재", + "ui.frame.continuous_requires_selection": "연결된 선과 원호를 경로 순서대로 선택하고 연속 부재에서는 모든 선을 끄세요." + }, + "vi": { + "ui.frame.continuous": "Một phần tử khung kết cấu liên tục", + "ui.frame.continuous_requires_selection": "Chọn các đoạn thẳng và cung tròn nối tiếp theo thứ tự đường dẫn; tắt Tất cả đoạn thẳng để tạo một phần tử khung kết cấu liên tục." + }, + "zh": { + "ui.frame.continuous": "单根连续构件", + "ui.frame.continuous_requires_selection": "按路径顺序选择相连的直线和圆弧;创建连续构件时请关闭所有直线。" + } +} diff --git a/attribution/pending/frame-continuous-paths.md b/attribution/pending/frame-continuous-paths.md new file mode 100644 index 00000000000..6e8dd566084 --- /dev/null +++ b/attribution/pending/frame-continuous-paths.md @@ -0,0 +1 @@ +| `assets/locales/pending/frame-continuous-paths.json` | SolidCraft contributors | Original continuous frame-member labels and translations | MIT OR Apache-2.0 | diff --git a/crates/doc/src/document.rs b/crates/doc/src/document.rs index e2fb074e6b4..9bb77388311 100644 --- a/crates/doc/src/document.rs +++ b/crates/doc/src/document.rs @@ -1127,14 +1127,18 @@ pub enum FeatureKind { #[serde(default, skip_serializing_if = "Vec::is_empty")] targets: Vec, }, - /// Structural members (#4003): one body per straight line of a frame sketch (2D sketch lines - /// and 3D sketch lines), its cross-section the profile, square to the line from end to end. + /// Structural members (#4003): separate selected lines/arcs, or one continuous tangent + /// path, including exact 3D sketch arcs. The all-lines default selects straight lines. FrameMember { path_sketch: SketchId, /// The lines, by curve id; none: every straight line drawn in the sketch (not /// construction, not projected or otherwise linked, not of no length). #[serde(default, skip_serializing_if = "Vec::is_empty")] lines: Vec, + /// The explicitly selected curves form one open, tangent line/arc chain, in selection + /// order. Otherwise each selected curve makes a separate member. + #[serde(default, skip_serializing_if = "std::ops::Not::not")] + continuous: bool, profile: crate::frame::MemberProfile, /// The profile point that sits on the line. #[serde(default, skip_serializing_if = "crate::frame::Anchor::is_origin")] diff --git a/crates/doc/src/eval_frame.rs b/crates/doc/src/eval_frame.rs index 7abd78ec794..d31aa9db758 100644 --- a/crates/doc/src/eval_frame.rs +++ b/crates/doc/src/eval_frame.rs @@ -1,11 +1,10 @@ -//! Frame members (#4003): one body per straight line of a frame sketch, its cross-section a -//! profile laid square to the line (`frame::member_axes`) and run from one end to the other. +//! Frame members (#4003): separate sketch curves, or one continuous tangent line/arc path. use solidcraft_geom::prelude::*; use std::borrow::Cow; use std::collections::{BTreeMap, HashSet}; -use solidcore_record::{Plane, Region2, Vec2, Vec3}; +use solidcore_record::{Plane, Region2, Seg2, Vec2, Vec3}; use solidcraft_geom::{Aabb2, Ring}; use solidcraft_kernel as kernel; use solidcraft_sketch::CurveKind; @@ -19,20 +18,18 @@ use crate::{DocError, Document, Feature, FeatureKind, ProfileSel, Result}; const MAX_PROFILE_PIECES: usize = 256; /// Shortest member (mm). const MIN_LENGTH: f64 = 1e-6; -/// How far (mm) a 3D sketch curve may stray from the line between its ends and still be a line. -const STRAIGHT_TOL: f64 = 1e-3; -/// Evaluate a `FrameMember` feature: one new body per line, each named -/// ([`member_names`], or by position for a copy whose `body_names` were set). +/// Evaluate a `FrameMember` feature: one body per selected curve, or one for a continuous path. +/// Bodies use [`member_names`], or positional names for a copy whose `body_names` were set. pub(super) fn evaluate(doc: &Document, vals: &BTreeMap, f: &Feature, st: &mut ModelState) -> Result<()> { - let FeatureKind::FrameMember { path_sketch, lines, profile, anchor, angle, mirror, body_name, names } = &f.kind else { + let FeatureKind::FrameMember { path_sketch, lines, continuous, profile, anchor, angle, mirror, body_name, names } = &f.kind else { return Err(DocError::Invalid("not a frame member feature".into())); }; let ps = st.sketch(path_sketch.0).ok_or_else(|| DocError::Unknown(format!("sketch {path_sketch} (it must come earlier in the timeline)")))?; // The frame sketch in this feature's component frame: its plane, and its 3D lines. let mapped = if ps.sketch.wires.is_empty() { Cow::Owned(sketch_in_feature_frame(doc, ps, f.component)?) } else { path_in_frame(doc, ps, f.component)? }; - let segments = member_lines(mapped.as_ref(), lines)?; + let paths = member_paths(mapped.as_ref(), lines, *continuous)?; let (mut regions, description) = profile_regions(vals, st, profile)?; if *mirror { regions = regions.iter().map(frame::mirrored).collect(); @@ -42,14 +39,21 @@ pub(super) fn evaluate(doc: &Document, vals: &BTreeMap, f: &Featu Some(e) => val(vals, e, Kind::Angle)?, None => 0.0, }; - let mut made = Vec::with_capacity(segments.len()); - for (id, a, b) in &segments { - let (x, y) = frame::member_axes(*b - *a, turn).ok_or_else(|| DocError::Invalid(format!("line `{id}` has no length")))?; - let plane = Plane::new(*a - x * at.x - y * at.y, x, y).ok_or_else(|| DocError::Invalid(format!("line `{id}`: no plane square to it")))?; - let mut bodies = kernel::extrude(&plane, ®ions, 0.0, a.dist(*b))?; - let body = match (bodies.pop(), bodies.is_empty()) { - (Some(body), true) => body, - _ => return Err(DocError::Invalid(format!("the member on line `{id}` is not one solid"))), + let mut made = Vec::with_capacity(paths.len()); + for path in &paths { + let first = path.first().ok_or_else(|| DocError::Invalid("a member path is empty".into()))?; + let (x, y) = frame::member_axes(first.t0, turn).ok_or_else(|| DocError::Invalid("the member has no start direction".into()))?; + let plane = Plane::new(first.a - x * at.x - y * at.y, x, y).ok_or_else(|| DocError::Invalid("no plane square to the member".into()))?; + let body = if let [Piece { seg: kernel::PathSeg::Line { a, b }, .. }] = path.as_slice() { + let mut bodies = kernel::extrude(&plane, ®ions, 0.0, a.dist(*b))?; + match (bodies.pop(), bodies.is_empty()) { + (Some(body), true) => body, + _ => return Err(DocError::Invalid("the member is not one solid".into())), + } + } else { + let region = regions.first().ok_or_else(|| DocError::Invalid("the member profile has no area".into()))?; + check_bend_clearance(path, region, at, x, y)?; + kernel::sweep(&plane, region, &path.iter().map(|p| p.seg).collect::>())? }; made.push(crate::lineage::numbered_tool(body)); } @@ -63,7 +67,7 @@ pub(super) fn evaluate(doc: &Document, vals: &BTreeMap, f: &Featu return Ok(()); } let base = body_name.as_deref().map(str::trim).filter(|n| !n.is_empty()).map_or(description, str::to_string); - let ids: Vec = segments.into_iter().map(|(id, _, _)| id).collect(); + let ids = path_keys(&paths, *continuous); for (name, t) in member_names(st, &ids, names, &base).into_iter().zip(made) { st.bodies.push(ModelBody::traced_new(name, t, f.id)); } @@ -102,67 +106,237 @@ pub fn member_names(st: &ModelState, lines: &[String], pinned: &BTreeMap Result> { - let FeatureKind::FrameMember { path_sketch, lines, .. } = kind else { + let FeatureKind::FrameMember { path_sketch, lines, continuous, .. } = kind else { return Err(DocError::Invalid("not a frame member feature".into())); }; let ps = st.sketch(path_sketch.0).ok_or_else(|| DocError::Unknown(format!("sketch {path_sketch}")))?; - Ok(member_lines(ps, lines)?.into_iter().map(|(id, _, _)| id).collect()) + Ok(path_keys(&member_paths(ps, lines, *continuous)?, *continuous)) +} + +/// A continuous member belongs to its feature, independently of traversal order or which +/// end segment is selected first. Keep using per-curve keys for separate members. +fn path_keys(paths: &[Vec], continuous: bool) -> Vec { + if continuous { vec!["$path".into()] } else { paths.iter().filter_map(|p| p.first().map(|p| p.id.clone())).collect() } +} + +/// One exact segment, retaining analytic end tangents even for spatial arcs. +struct Piece { + id: String, + a: Vec3, + b: Vec3, + t0: Vec3, + t1: Vec3, + seg: kernel::PathSeg, +} + +impl Piece { + fn line(id: &str, a: Vec3, b: Vec3) -> Result { + let t = (b - a).normalized().filter(|_| a.dist(b) > MIN_LENGTH); + let t = t.ok_or_else(|| DocError::Invalid(format!("line `{id}` has no length")))?; + if !point_ok(a) || !point_ok(b) { + return Err(DocError::Invalid(format!("line `{id}` has invalid coordinates"))); + } + Ok(Self { id: id.into(), a, b, t0: t, t1: t, seg: kernel::PathSeg::Line { a, b } }) + } + + fn arc(id: &str, a: Vec3, b: Vec3, center: Vec3, axis: Vec3, angle: f64) -> Result { + let k = axis.normalized().ok_or_else(|| DocError::Invalid(format!("arc `{id}` has no normal")))?; + let radius = a.dist(center); + if !point_ok(a) + || !point_ok(b) + || !point_ok(center) + || !radius.is_finite() + || radius <= MIN_LENGTH + || !angle.is_finite() + || angle <= MIN_LENGTH + || angle >= std::f64::consts::TAU - 1e-9 + || (b.dist(center) - radius).abs() > 1e-6 * radius.max(1.0) + || (a - center).dot(k).abs() > 1e-6 + || (b - center).dot(k).abs() > 1e-6 + || rotate(a - center, k, angle).dist(b - center) > 1e-6 * radius.max(1.0) + { + return Err(DocError::Invalid(format!("arc `{id}` needs a finite, open circular path"))); + } + let t0 = k.cross(a - center).normalized().ok_or_else(|| DocError::Invalid(format!("arc `{id}` has no tangent")))?; + let t1 = k.cross(b - center).normalized().ok_or_else(|| DocError::Invalid(format!("arc `{id}` has no tangent")))?; + Ok(Self { id: id.into(), a, b, t0, t1, seg: kernel::PathSeg::Arc { a, center, axis: k, angle } }) + } + + fn reverse(&mut self) { + self.seg = self.seg.reversed(); + std::mem::swap(&mut self.a, &mut self.b); + let old = self.t0; + self.t0 = -self.t1; + self.t1 = -old; + } } -/// The member lines of the frame sketch, each as (curve id, start, end) in its frame: the lines -/// asked for, or every straight line drawn in it (not construction, not projected or otherwise -/// linked, and with a length). -fn member_lines(ss: &SolvedSketch, ids: &[String]) -> Result> { +fn point_ok(p: Vec3) -> bool { + p.is_finite() && p.x.abs().max(p.y.abs()).max(p.z.abs()) <= 1e9 +} + +fn rotate(v: Vec3, k: Vec3, angle: f64) -> Vec3 { + let (s, c) = angle.sin_cos(); + v * c + k.cross(v) * s + k * (k.dot(v) * (1.0 - c)) +} + +fn curve_piece(ss: &SolvedSketch, id: &str) -> Result { let sk = &ss.sketch; - let mut out = Vec::new(); - if ids.is_empty() { - for (ci, c) in sk.curves.iter().enumerate() { - if !c.construction - && !c.centerline - && c.link.is_none() - && matches!(c.kind, CurveKind::Line { .. }) - && let Some((a, b)) = planar_line(ss, ci) - && a.dist(b) > MIN_LENGTH - { - out.push((c.id.clone(), a, b)); + if let Some(w) = sk.wire_index(id).and_then(|i| sk.wires.get(i)) { + if let Some(arc) = w.arc { + if !arc.radius.is_finite() || (arc.normal.len() - 1.0).abs() > 1e-6 || (arc.start.dist(arc.center) - arc.radius).abs() > 1e-6 { + return Err(DocError::Invalid(format!("arc `{id}` has invalid circle data"))); } + let u = arc.start - arc.center; + let v = arc.end - arc.center; + let angle = arc.normal.dot(u.cross(v)).atan2(u.dot(v)).rem_euclid(std::f64::consts::TAU); + return Piece::arc(id, arc.start, arc.end, arc.center, arc.normal, angle); } - for w in sk.wires.iter().filter(|w| w.link.is_none()) { - if let Some((a, b)) = straight(&w.pts) - && a.dist(b) > MIN_LENGTH - { - out.push((w.id.clone(), a, b)); - } + if let Some((a, b)) = wire_line(w) { + return Piece::line(id, a, b); } - if out.is_empty() { - return Err(DocError::Invalid(format!("{} has no lines for members", ss.name))); + } else if let Some(ci) = sk.curve_index(id) { + if !sk.curves.get(ci).is_some_and(|c| matches!(c.kind, CurveKind::Line { .. } | CurveKind::Arc { .. })) { + return Err(DocError::Invalid(format!("not supported yet: `{id}` must be a straight line or an open circular arc"))); } - if out.len() > MAX_MEMBERS { - return Err(DocError::Invalid(format!("at most {MAX_MEMBERS} members in one feature (pick the lines)"))); + return match sk.segs(ci).as_slice() { + [Seg2::Line { a, b }] => Piece::line(id, ss.plane.to_world(*a), ss.plane.to_world(*b)), + [s @ Seg2::Arc { center, sweep, .. }] => Piece::arc( + id, + ss.plane.to_world(s.start()), + ss.plane.to_world(s.end()), + ss.plane.to_world(*center), + ss.plane.normal() * sweep.signum(), + sweep.abs(), + ), + _ => Err(DocError::Invalid(format!("not supported yet: `{id}` must be a straight line or an open circular arc"))), + }; + } else { + return Err(DocError::Unknown(format!("path curve `{id}` in {}", ss.name))); + } + Err(DocError::Invalid(format!("not supported yet: `{id}` must be a straight line or an exact circular arc"))) +} + +fn member_paths(ss: &SolvedSketch, ids: &[String], continuous: bool) -> Result>> { + // Preserve the existing meaning of an unselected feature, including on older designs. + if ids.is_empty() { + if continuous { + return Err(DocError::Invalid("a continuous member needs explicit `lines` in path order".into())); } - return Ok(out); + return default_member_lines(ss)?.into_iter().map(|(id, a, b)| Ok(vec![Piece::line(&id, a, b)?])).collect(); } if ids.len() > MAX_MEMBERS { - return Err(DocError::Invalid(format!("at most {MAX_MEMBERS} members in one feature"))); + return Err(DocError::Invalid(format!("at most {MAX_MEMBERS} curves in one member feature"))); } let mut seen = HashSet::new(); + let mut pieces = Vec::with_capacity(ids.len()); for id in ids { if !seen.insert(id.as_str()) { - return Err(DocError::Invalid(format!("line `{id}` is listed twice"))); + return Err(DocError::Invalid(format!("curve `{id}` is listed twice"))); } - let line = if let Some(wi) = sk.wire_index(id) { - sk.wires.get(wi).and_then(|w| straight(&w.pts)) - } else { - let ci = sk.curve_index(id).ok_or_else(|| DocError::Unknown(format!("line `{id}` in {}", ss.name)))?; - planar_line(ss, ci) - }; - let (a, b) = line.ok_or_else(|| DocError::Invalid(format!("`{id}` is not a straight line (members run along lines)")))?; - if !(a.dist(b) > MIN_LENGTH) { - return Err(DocError::Invalid(format!("line `{id}` has no length"))); + pieces.push(curve_piece(ss, id)?); + } + if !continuous { + return Ok(pieces.into_iter().map(|p| vec![p]).collect()); + } + if let (Some(first), Some(next)) = (pieces.first(), pieces.get(1)) { + let flip = first.a.dist(next.a).min(first.a.dist(next.b)) < first.b.dist(next.a).min(first.b.dist(next.b)); + if flip && let Some(first) = pieces.first_mut() { + first.reverse(); } - out.push((id.clone(), a, b)); + } + let mut end = None; + for p in &mut pieces { + if let Some((b, tangent)) = end { + if p.b.dist(b) < p.a.dist(b) { + p.reverse(); + } + if p.a.dist(b) > 1e-6 { + return Err(DocError::Invalid(format!("continuous member: `{}` is not connected end to end in path order", p.id))); + } + if p.t0.dot(tangent) < (1e-6_f64).cos() { + return Err(DocError::Invalid(format!("continuous member: `{}` is not tangent to the previous curve; draw a bend arc", p.id))); + } + } + end = Some((p.b, p.t1)); + } + if pieces.first().zip(pieces.last()).is_some_and(|(a, b)| a.a.dist(b.b) <= 1e-6) { + return Err(DocError::Invalid("not supported yet: a continuous member must have two open ends".into())); + } + Ok(vec![pieces]) +} + +/// Refuse a section crossing a bend axis. Transport the section axes exactly as the sweep +/// does; an anchored or rotated rectangular section need not be symmetric about the path. +fn check_bend_clearance(path: &[Piece], region: &Region2, at: Vec2, mut x: Vec3, mut y: Vec3) -> Result<()> { + let bb = section_bounds(region)?; + let corners = [bb.min, Vec2::new(bb.max.x, bb.min.y), bb.max, Vec2::new(bb.min.x, bb.max.y)]; + for p in path { + if let kernel::PathSeg::Arc { center, axis, angle, .. } = p.seg { + let radial = (p.a - center).normalized().ok_or_else(|| DocError::Invalid("the bend has no radius".into()))?; + let inward = corners.iter().map(|q| (x * (q.x - at.x) + y * (q.y - at.y)).dot(radial)).fold(0.0_f64, f64::min); + if p.a.dist(center) + inward <= MIN_LENGTH + 2e-3 { + return Err(DocError::Invalid(format!("arc `{}`: the bend radius is too small for the anchored profile", p.id))); + } + x = rotate(x, axis, angle); + y = rotate(y, axis, angle); + } + } + Ok(()) +} + +/// A conservative enclosure from the section's exact curves, never its display samples. +/// Circles enclose arcs; positive-weight rational curves and polynomial curves stay within +/// the convex hull of their controls. An unsupported rational weight cannot certify clearance. +fn section_bounds(region: &Region2) -> Result { + let mut bounds = Aabb2::EMPTY; + for seg in ®ion.outer.segs { + match *seg { + Seg2::Line { a, b } => bounds.extend([a, b]), + Seg2::Arc { center, radius, .. } => { + let d = Vec2::new(radius.abs(), radius.abs()); + bounds.extend([center - d, center + d]); + } + Seg2::Cubic { p0, p1, p2, p3 } => bounds.extend([p0, p1, p2, p3]), + Seg2::Conic { a, apex, b, w } if w.is_finite() && w > 0.0 => bounds.extend([a, apex, b]), + Seg2::Bezier { n, ref p } if (n as usize) < p.len() => bounds.extend(p[..=n as usize].iter().copied()), + _ => return Err(DocError::Invalid("not supported yet: the profile has no certified bound for bend clearance".into())), + } + } + if bounds.is_empty() { + return Err(DocError::Invalid("the member profile has no boundary".into())); + } + Ok(bounds) +} + +/// The unchanged all-lines default: drawn straight lines with a length, in the sketch's frame. +fn default_member_lines(ss: &SolvedSketch) -> Result> { + let sk = &ss.sketch; + let mut out = Vec::new(); + for (ci, c) in sk.curves.iter().enumerate() { + if !c.construction + && !c.centerline + && c.link.is_none() + && matches!(c.kind, CurveKind::Line { .. }) + && let Some((a, b)) = planar_line(ss, ci) + && a.dist(b) > MIN_LENGTH + { + out.push((c.id.clone(), a, b)); + } + } + for w in sk.wires.iter().filter(|w| w.link.is_none()) { + if let Some((a, b)) = wire_line(w) { + out.push((w.id.clone(), a, b)); + } + } + if out.is_empty() { + return Err(DocError::Invalid(format!("{} has no lines for members", ss.name))); + } + if out.len() > MAX_MEMBERS { + return Err(DocError::Invalid(format!("at most {MAX_MEMBERS} members in one feature (pick the lines)"))); } Ok(out) } @@ -174,22 +348,25 @@ fn planar_line(ss: &SolvedSketch, ci: usize) -> Option<(Vec3, Vec3)> { Some((ss.plane.to_world(pa), ss.plane.to_world(pb))) } -/// The ends of a 3D polyline that runs straight from its first point to its last: every point -/// within [`STRAIGHT_TOL`] of the line between them, none behind the start, past the end or back -/// from a point before it. -fn straight(pts: &[Vec3]) -> Option<(Vec3, Vec3)> { - let (a, b) = (*pts.first()?, *pts.last()?); - let (len, d) = (a.dist(b), (b - a).normalized()?); - let mut reached = 0.0_f64; - for p in pts { - let q = *p - a; - let t = q.dot(d); - if (q - d * t).len() > STRAIGHT_TOL || t < reached - STRAIGHT_TOL || t > len + STRAIGHT_TOL { - return None; - } - reached = reached.max(t); +/// A drawn line's defining points, or one linked exact line on its retained interval. +/// A spline that merely looks straight in its display samples is still a spline. +fn wire_line(w: &solidcraft_sketch::Wire) -> Option<(Vec3, Vec3)> { + if w.arc.is_some() { + return None; } - Some((a, b)) + let (a, b) = if w.link.is_none() + && w.exact.is_empty() + && let [a, b] = w.fit.as_slice() + { + (*a, *b) + } else if let [solidcraft_sketch::WireCurve { curve: solidcore_record::brep::Curve::Line { start, end }, interval }] = w.exact.as_slice() { + let a = Vec3::from(*start); + let d = Vec3::from(*end) - a; + (a + d * interval[0], a + d * interval[1]) + } else { + return None; + }; + (point_ok(a) && point_ok(b) && a.dist(b) > MIN_LENGTH).then_some((a, b)) } /// The regions of a member's profile, in the profile's own coordinates: one piece of material, diff --git a/crates/doc/src/format/pending/frame-continuous-paths.rs b/crates/doc/src/format/pending/frame-continuous-paths.rs new file mode 100644 index 00000000000..98819b0fecf --- /dev/null +++ b/crates/doc/src/format/pending/frame-continuous-paths.rs @@ -0,0 +1,4 @@ +//! Frame members can retain explicitly selected circular arcs and a `continuous` line/arc +//! chain as one physical member. Older designs default to separate members, with the existing +//! all-straight-lines selection unchanged. The previous release requests an update rather than +//! attempting to read this format and losing the continuous-member intent. diff --git a/crates/engine/src/cmd/frame.rs b/crates/engine/src/cmd/frame.rs index 4eabb3edb02..00cbd82631c 100644 --- a/crates/engine/src/cmd/frame.rs +++ b/crates/engine/src/cmd/frame.rs @@ -17,8 +17,13 @@ use super::features::{add_feature, check_expr, sketch_id}; use super::sketch::edit; use super::{CommandSpec, in_sketch, not_in_sketch}; use crate::params::{bad, bool_, expr, num, str_, string_list, vec2}; +use crate::schema::features::FeatureResult; +use crate::schema::frame::MemberParams; +use crate::schema::{TypedContract, output_schema_for}; use crate::{Result, Session}; +const MEMBER_CONTRACT: TypedContract = TypedContract::new(); + #[cfg(test)] #[path = "frame_tests.rs"] mod tests; @@ -31,10 +36,10 @@ macro_rules! profile_doc { } pub static COMMANDS: &[CommandSpec] = &[ - CommandSpec::new("frame.member", "Frame Member", member).at("WELDMENTS", "CREATE").icon("frame_member").enabled(not_in_sketch).params(concat!( - "sketch: the frame sketch (id or name; 2D or 3D); lines?: [curve ids] (one member each; default: every straight line drawn in the sketch: not construction, not projected or otherwise linked, not of no length); ", + CommandSpec::new("frame.member", "Frame Member", crate::checked!("frame.member", member)).at("WELDMENTS", "CREATE").icon("frame_member").enabled(not_in_sketch).contract(&MEMBER_CONTRACT).output(output_schema_for::).params(concat!( + "sketch: the frame sketch (id or name; 2D or 3D); lines?: [line or circular arc ids] (one member each; default: every straight line drawn in the sketch: not construction, not projected or otherwise linked, not of no length); continuous?: bool (default false; true: one member along explicit lines in connected tangent path order, reversing individual curves as needed; open paths only; its name uses the stable names key `$path`); ", profile_doc!(), - " | profile_sketch: a sketch whose profile is the section, in its own x and y around its origin, with profiles?: picks as solid.extrude takes them (default: its material, nested loops alternating, so two circles make a tube); anchor?: origin|center|centroid|top_left|top|top_right|left|right|bottom_left|bottom|bottom_right (the profile point that sits on each line, default origin); angle?: angle expr (the profile turned about the line; default 0: its y as near world up as the line allows, a vertical member's x along world X); mirror?: bool (the profile mirrored across its y axis); name?; body_name? (what the members are named after, then numbered: `Rail`, `Rail (2)`…; default the profile's description, `Rect Tube 40x40x3`, or the profile sketch's name); names?: {line id: name} (names to keep, as Edit Feature keeps them). One body per line, from its start to its end; each member keeps its name when other lines are added or deleted. Returns the feature and the bodies it made" + " | profile_sketch: a sketch whose profile is the section, in its own x and y around its origin, with profiles?: picks as solid.extrude takes them (default: its material, nested loops alternating, so two circles make a tube); anchor?: origin|center|centroid|top_left|top|top_right|left|right|bottom_left|bottom|bottom_right (the profile point that sits on each line, default origin); angle?: angle expr (the profile turned about the line; default 0: its y as near world up as the line allows, a vertical member's x along world X); mirror?: bool (the profile mirrored across its y axis); name?; body_name? (what the members are named after, then numbered: `Rail`, `Rail (2)`…; default the profile's description, `Rect Tube 40x40x3`, or the profile sketch's name); names?: {line id: name} (names to keep, as Edit Feature keeps them). One body per selected curve, or one body for a continuous path; each member keeps its name when other members are added or deleted. Returns the feature and the bodies it made" )), CommandSpec::new("frame.profile.list", "Profile Library", list).icon("library") .noundo() @@ -198,6 +203,13 @@ fn member(s: &mut Session, p: &Value) -> Result { } Some(_) => Err(bad(cmd, format!("`lines` must list 1…{} curve ids", frame::MAX_MEMBERS)))?, }; + let continuous = match p.get("continuous") { + None | Some(Value::Null) => false, + Some(_) => bool_(p, "continuous").ok_or_else(|| bad(cmd, "`continuous` must be true or false"))?, + }; + if continuous && lines.is_empty() { + return Err(bad(cmd, "a continuous member needs explicit `lines` in path order")); + } let body_name = match p.get("body_name") { None | Some(Value::Null) => None, Some(_) => Some( @@ -256,8 +268,17 @@ fn member(s: &mut Session, p: &Value) -> Result { Some(_) => return Err(bad(cmd, format!("`names` must map up to {} line ids to names", frame::MAX_MEMBERS))), }; let base = body_name.clone().unwrap_or(default_name); - let mut kind = - FeatureKind::FrameMember { path_sketch: SketchId(path_sketch), lines, profile, anchor, angle, mirror, body_name, names: BTreeMap::new() }; + let mut kind = FeatureKind::FrameMember { + path_sketch: SketchId(path_sketch), + lines, + continuous, + profile, + anchor, + angle, + mirror, + body_name, + names: BTreeMap::new(), + }; // Each member's name is pinned to its line as the feature is made, so deleting or adding a // line later leaves the other members' names alone. let st = s.model.state(); diff --git a/crates/engine/src/cmd/frame_tests.rs b/crates/engine/src/cmd/frame_tests.rs index 5559b909351..2cae93765d2 100644 --- a/crates/engine/src/cmd/frame_tests.rs +++ b/crates/engine/src/cmd/frame_tests.rs @@ -331,7 +331,7 @@ fn bad_members_are_refused() { rectangle_frame(&mut s); run(&mut s, "sketch.create", json!({"plane": "XY", "name": "Arc"})); let arc = run(&mut s, "sketch.arc.three_point", json!({"start": [0, 0], "end": [100, 0], "through": [50, 30]})); - let arc_id = arc["created"]["curves"][0].as_str().unwrap().to_string(); + let _arc_id = arc["created"]["curves"][0].as_str().unwrap().to_string(); run(&mut s, "sketch.finish", json!({})); run(&mut s, "sketch.create", json!({"plane": "XY", "name": "Empty"})); run(&mut s, "sketch.finish", json!({})); @@ -343,7 +343,6 @@ fn bad_members_are_refused() { (json!({"sketch": "Frame", "profile": {"kind": "rect_tube", "width": 10, "height": 10, "wall": 5}}), "wall"), (json!({"sketch": "Frame", "profile": tube(), "lines": []}), "`lines`"), (json!({"sketch": "Frame", "profile": tube(), "lines": ["nope"]}), "nope"), - (json!({"sketch": "Arc", "profile": tube(), "lines": [arc_id]}), "not a straight line"), (json!({"sketch": "Arc", "profile": tube()}), "no lines"), (json!({"sketch": "Empty", "profile": tube()}), "no lines"), (json!({"sketch": "Frame", "profile": tube(), "anchor": "middle"}), "`anchor`"), @@ -638,3 +637,222 @@ fn editing_the_feature_keeps_member_names_until_it_names_them() { run(&mut s, "edit.undo", json!({})); assert_eq!(boxes(&mut s).into_keys().collect::>(), names); } + +/// One 100 mm radius quarter bend between a 200 mm and a 300 mm straight. +fn chassis_path(s: &mut Session) -> Vec { + run(s, "sketch.create", json!({"plane": "XY", "name": "Chassis"})); + let mut ids = Vec::new(); + for (cmd, p) in [ + ("sketch.line", json!({"points": [[100, -200], [100, 0]]})), + ("sketch.arc.three_point", json!({"start": [100, 0], "through": [100.0 / 2f64.sqrt(), 100.0 / 2f64.sqrt()], "end": [0, 100]})), + // Deliberately drawn backwards: selection order, rather than drawing direction, + // decides how the segments connect. + ("sketch.line", json!({"points": [[-300, 100], [0, 100]]})), + ] { + ids.extend(run(s, cmd, p)["created"]["curves"].as_array().unwrap().iter().map(|v| v.as_str().unwrap().to_string())); + } + run(s, "sketch.finish", json!({})); + ids +} + +#[test] +fn explicit_arcs_make_round_and_rectangular_members_without_changing_all_lines() { + for profile in [ + json!({"kind": "round_tube", "diameter": 20, "wall": 2}), + json!({"kind": "rect_tube", "width": 20, "height": 10, "wall": 2, "outer_radius": 0}), + ] { + let mut s = Session::default(); + let ids = chassis_path(&mut s); + run(&mut s, "frame.member", json!({"sketch": "Chassis", "lines": [ids[1]], "profile": profile})); + assert_eq!(bodies(&mut s).len(), 1); + run(&mut s, "edit.undo", json!({})); + run(&mut s, "frame.member", json!({"sketch": "Chassis", "profile": profile})); + assert_eq!(bodies(&mut s).len(), 2, "all lines still selects only straight lines"); + } +} + +#[test] +fn continuous_member_keeps_one_identity_through_reversal_edit_reopen_and_undo() { + let mut s = Session::default(); + let ids = chassis_path(&mut s); + let profile = json!({"kind": "round_tube", "diameter": 20, "wall": 2}); + let params = json!({"sketch": "Chassis", "lines": ids, "continuous": true, "profile": profile, "body_name": "Hoop"}); + let fid = run(&mut s, "frame.member", params)["feature"].clone(); + let bs = bodies(&mut s); + assert_eq!(bs.len(), 1); + assert_eq!(bs[0].0, "Hoop"); + run(&mut s, "edit.undo", json!({})); + assert!(bodies(&mut s).is_empty()); + run(&mut s, "edit.redo", json!({})); + run(&mut s, "body.rename", json!({"body": "Hoop", "name": "Main hoop"})); + run( + &mut s, + "timeline.redefine", + json!({"feature": fid, "command": "frame.member", "params": { + "sketch": "Chassis", "lines": ids, "continuous": true, + "profile": {"kind": "round_tube", "diameter": 20, "wall": 3}, "body_name": "Hoop" + }}), + ); + let bs = bodies(&mut s); + assert_eq!(bs[0].0, "Main hoop"); + let mut reopened = Session::new(solidcraft_doc::Document::from_json(&s.doc.to_json()).unwrap()); + assert_eq!(bodies(&mut reopened).into_iter().map(|b| b.0).collect::>(), ["Main hoop"]); + run(&mut s, "edit.undo", json!({})); + // Reverse the traversal, including the bend, without changing the member identity. + run( + &mut s, + "timeline.redefine", + json!({"feature": fid, "command": "frame.member", "params": { + "sketch": "Chassis", "lines": ids.into_iter().rev().collect::>(), "continuous": true, "profile": profile, "body_name": "Hoop" + }}), + ); + assert_eq!(bodies(&mut s)[0].0, "Main hoop"); +} + +#[test] +fn invalid_continuous_path_selection_is_atomic() { + let mut s = Session::default(); + let ids = chassis_path(&mut s); + let original = s.doc.to_json(); + for (extra, why) in [ + (json!({"continuous": true}), "explicit"), + (json!({"continuous": 1, "lines": ids}), "continuous"), + (json!({"continuous": true, "lines": [ids[0], ids[2]]}), "connected"), + (json!({"continuous": true, "lines": [ids[0], ids[1], ids[1]]}), "twice"), + ] { + let mut p = json!({"sketch": "Chassis", "profile": {"kind": "round_tube", "diameter": 20, "wall": 2}}); + p.as_object_mut().unwrap().extend(extra.as_object().unwrap().clone()); + let err = s.execute("frame.member", &p).unwrap_err().to_string(); + assert!(err.contains(why), "{p}: {err}"); + assert_eq!(s.doc.to_json(), original); + assert!(bodies(&mut s).is_empty()); + } + rectangle_frame(&mut s); + let err = s.execute("frame.member", &json!({"sketch": "Frame", "lines": ["l1", "l2"], "continuous": true, "profile": tube()})).unwrap_err(); + assert!(err.to_string().contains("tangent"), "{err}"); +} + +#[test] +fn curved_member_follows_radius_parameters_and_a_different_component_frame() { + let mut s = Session::default(); + run(&mut s, "parameters.add", json!({"name": "R", "expression": "100 mm"})); + run(&mut s, "sketch.create", json!({"plane": "XY", "name": "Bend"})); + let arc = run( + &mut s, + "sketch.arc.three_point", + json!({ + "start": ["R", 0], "through": ["R * 0.7071067811865476", "R * 0.7071067811865476"], "end": [0, "R"] + }), + )["created"]["curves"][0] + .clone(); + run(&mut s, "sketch.finish", json!({})); + let c = run(&mut s, "component.create", json!({"name": "Bent tube", "grounded": false}))["component"].as_u64().unwrap(); + let o = s.doc.occurrence_of(c).unwrap().id; + run(&mut s, "occurrence.move", json!({"occurrence": o, "translate": [0, 0, 100], "capture": true})); + run( + &mut s, + "frame.member", + json!({"sketch": "Bend", "lines": [arc], "continuous": true, + "profile": {"kind": "round_tube", "diameter": 20, "wall": 2}}), + ); + let b = bodies(&mut s).remove(0); + run(&mut s, "parameters.change", json!({"name": "R", "expression": "150 mm"})); + let after = bodies(&mut s).remove(0); + assert_eq!(after.0, b.0); + // A quarter bend of radius R is R*pi/2 long; the 20 x 2 tube's section is pi*(10^2 - 8^2) = 36*pi. + assert!(rel(b.1, 36.0 * PI * 50.0 * PI) < 1e-6, "{b:?}"); + assert!(rel(after.1, 36.0 * PI * 75.0 * PI) < 1e-6, "{after:?}"); +} + +fn measured(s: &mut Session) -> serde_json::Map { + let m = run(s, "inspect.measure", json!({})); + m["bodies"].as_array().unwrap().iter().map(|b| (b["name"].as_str().unwrap().to_string(), b.clone())).collect() +} + +fn v3(v: &Value) -> [f64; 3] { + [f(&v[0]), f(&v[1]), f(&v[2])] +} + +#[test] +fn a_continuous_round_member_traversed_backwards_has_its_closed_form_mass_properties() { + let mut s = Session::default(); + let ids = chassis_path(&mut s); + let lines: Vec<&String> = ids.iter().rev().collect(); + let profile = json!({"kind": "round_tube", "diameter": 20, "wall": 2}); + run(&mut s, "frame.member", json!({"sketch": "Chassis", "lines": lines, "continuous": true, "profile": profile, "body_name": "Main hoop"})); + // r_o = 10, r_i = 8, R = 100: A = pi*(r_o^2 - r_i^2) = 36*pi along L = 200 + R*pi/2 + 300. + let (area, length) = (36.0 * PI, 500.0 + 50.0 * PI); + let m = measured(&mut s); + assert_eq!(m.len(), 1, "the bend stays one physical member: {m:?}"); + let b = &m["Main hoop"]; + assert!(rel(f(&b["volume_mm3"]), area * length) < 1e-6, "{b}"); + assert!(rel(f(&b["area_mm2"]), 2.0 * PI * 18.0 * length + 2.0 * area) < 1e-6, "{b}"); + // First moments of each straight and of the quarter torus, whose section has I/A = (r_o^2 + r_i^2)/4 = 41. + assert!(near3(v3(&b["center_of_mass"]), [(-15000.0 + 41.0) / length, (20000.0 + 41.0) / length, 0.0]), "{b}"); + assert!(near3(v3(&b["bbox"]["min"]), [-300.0, -200.0, -10.0]) && near3(v3(&b["bbox"]["max"]), [110.0, 110.0, 10.0]), "{b}"); +} + +#[test] +fn a_continuous_rectangular_member_is_its_section_area_times_the_developed_centreline() { + let mut s = Session::default(); + let ids = chassis_path(&mut s); + let profile = json!({"kind": "rect_tube", "width": 20, "height": 10, "wall": 2, "outer_radius": 0}); + run(&mut s, "frame.member", json!({"sketch": "Chassis", "lines": ids, "continuous": true, "profile": profile, "body_name": "Hoop"})); + // A centred 20 x 10 x 2 section, 200 - 16*6 = 104 mm^2, carried round the bend. + let m = measured(&mut s); + assert_eq!(m.len(), 1, "{m:?}"); + assert!(rel(f(&m["Hoop"]["volume_mm3"]), 104.0 * (500.0 + 50.0 * PI)) < 1e-6, "{m:?}"); +} + +#[test] +fn two_compound_spatial_bends_carry_a_rectangular_section_without_restarting_its_up_direction() { + let mut s = Session::default(); + run(&mut s, "sketch.create", json!({"plane": "XY", "name": "Chassis"})); + run(&mut s, "sketch.options", json!({"sketch_3d": true})); + let h = 100.0 / 2f64.sqrt(); + run(&mut s, "sketch.line3d", json!({"points": [[100, -200, 0], [100, 0, 0]]})); + run(&mut s, "sketch.arc3d", json!({"start": [100, 0, 0], "through": [h, h, 0], "end": [0, 100, 0]})); + run(&mut s, "sketch.line3d", json!({"points": [[0, 100, 0], [-200, 100, 0]]})); + run(&mut s, "sketch.arc3d", json!({"start": [-200, 100, 0], "through": [-200.0 - h, 100, 100.0 - h], "end": [-300, 100, 100]})); + run(&mut s, "sketch.line3d", json!({"points": [[-300, 100, 100], [-300, 100, 400]]})); + run(&mut s, "sketch.finish", json!({})); + let profile = json!({"kind": "bar", "width": 20, "height": 10}); + let lines = ["w1", "w2", "w3", "w4", "w5"]; + run(&mut s, "frame.member", json!({"sketch": "Chassis", "lines": lines, "continuous": true, "profile": profile, "body_name": "Hoop"})); + // Two R100 quarter bends, in XY and then XZ, with 700 mm of straight stock: V = 20*10*(700 + 100*pi). + let m = measured(&mut s); + let b = &m["Hoop"]; + assert!(rel(f(&b["volume_mm3"]), 200.0 * (700.0 + 100.0 * PI)) < 1e-6, "{b}"); + // The 10 mm height is carried to X at the vertical end; restarting world up would swap it with the width. + assert!(near3(v3(&b["bbox"]["min"]), [-305.0, -200.0, -5.0]) && near3(v3(&b["bbox"]["max"]), [110.0, 110.0, 400.0]), "{b}"); +} + +#[test] +fn a_tube_wider_than_its_bend_radius_is_refused() { + let mut s = Session::default(); + let ids = chassis_path(&mut s); + let before = s.doc.to_json(); + // The tube radius 125 exceeds the centreline bend radius 100: the swept section would cross the bend axis. + let profile = json!({"kind": "round_tube", "diameter": 250, "wall": 2}); + let p = json!({"sketch": "Chassis", "lines": ids, "continuous": true, "profile": profile, "body_name": "Hoop"}); + let err = s.execute("frame.member", &p).unwrap_err().to_string(); + assert!(err.contains("bend radius is too small"), "{err}"); + assert_eq!(s.doc.to_json(), before); + assert!(bodies(&mut s).is_empty()); +} + +#[test] +fn a_nearly_straight_spline_is_not_accepted_as_straight_tube_stock() { + let mut s = Session::default(); + run(&mut s, "sketch.create", json!({"plane": "XY", "name": "Nearly straight"})); + run(&mut s, "sketch.options", json!({"sketch_3d": true})); + // The middle defining point lies 0.00001 mm off the endpoints' line: every display sample is + // within 0.001 mm of a line, but the curve is not one. + run(&mut s, "sketch.spline3d", json!({"points": [[0, 0, 0], [100, 1e-5, 0], [200, 0, 0]]})); + run(&mut s, "sketch.finish", json!({})); + let before = s.doc.to_json(); + let p = json!({"sketch": "Nearly straight", "lines": ["w1"], "profile": {"kind": "round_tube", "diameter": 40, "wall": 2}}); + let err = s.execute("frame.member", &p).unwrap_err().to_string(); + assert!(err.contains("straight line or an exact circular arc"), "{err}"); + assert_eq!(s.doc.to_json(), before); +} diff --git a/crates/engine/src/schema/frame.rs b/crates/engine/src/schema/frame.rs new file mode 100644 index 00000000000..4cb01f9aba0 --- /dev/null +++ b/crates/engine/src/schema/frame.rs @@ -0,0 +1,61 @@ +//! Contracts for frame member creation. + +use std::collections::BTreeMap; + +use schemars::JsonSchema; +use serde::Deserialize; + +use super::{AngleExpr, FeatureCommon, LengthExpr, ProfilesParam, SketchRef, feature_common}; + +#[cfg(test)] +#[path = "frame_tests.rs"] +mod tests; + +/// A parametric library profile. `frame.profile.list` describes each kind's dimensions. +#[derive(Debug, Deserialize, JsonSchema)] +pub struct ProfileParams { + pub kind: String, + #[serde(flatten)] + pub dimensions: BTreeMap, +} + +/// Structural members on selected sketch lines or circular arcs. Each selected curve makes +/// one member, unless `continuous` requests one open tangent chain. With no selection, +/// only drawn straight lines are used, preserving the existing default. Participants have +/// no effect: this feature creates new bodies. +#[derive(Debug, Deserialize, JsonSchema)] +#[schemars(deny_unknown_fields)] +pub struct MemberParams { + pub sketch: SketchRef, + /// Curve ids, each once, at most 1000. For a continuous member, required in path order; + /// individual curves are reversed as necessary to connect their ends. + #[serde(default)] + pub lines: Option>, + /// One physical member along the selected curves. Default false. The curves must form + /// an open connected tangent line/arc chain, including exact spatial circular arcs. + #[serde(default)] + pub continuous: Option, + /// Library profile, mutually exclusive with `profile_sketch`. + #[serde(default)] + pub profile: Option, + /// Section sketch, mutually exclusive with `profile`. Its nested material must be one piece. + #[serde(default)] + pub profile_sketch: Option, + #[serde(default)] + pub profiles: Option, + /// Profile point on the path: origin (default), center, centroid, top_left, top, + /// top_right, left, right, bottom_left, bottom or bottom_right. + #[serde(default)] + pub anchor: Option, + /// Initial section rotation. Default zero; the section then follows each bend without + /// resetting its orientation to world up at each segment. + #[serde(default)] + pub angle: Option, + #[serde(default)] + pub mirror: Option, + /// Pinned body names by curve id; a continuous member uses the stable key `$path`. + #[serde(default)] + pub names: Option>, + #[serde(flatten, deserialize_with = "feature_common")] + pub common: FeatureCommon, +} diff --git a/crates/engine/src/schema/frame_tests.rs b/crates/engine/src/schema/frame_tests.rs new file mode 100644 index 00000000000..c1bd8d70428 --- /dev/null +++ b/crates/engine/src/schema/frame_tests.rs @@ -0,0 +1,46 @@ +use serde_json::json; + +use super::MemberParams; +use crate::Session; +use crate::schema::features::FeatureResult; +use crate::schema::tests::{assert_keys, conforms}; +use crate::schema::{ParamCheck, input_schema_for, output_schema_for}; + +#[test] +fn schemas_and_the_key_check_agree() { + assert_keys( + input_schema_for::(), + &[ + "anchor", + "angle", + "body_name", + "body_names", + "continuous", + "lines", + "mirror", + "name", + "names", + "participants", + "profile", + "profile_sketch", + "profiles", + "sketch", + ], + ); + let schema = input_schema_for::(); + let p = json!({"sketch": "Chassis", "lines": ["l1", "a1", "l2"], "continuous": true, + "profile": {"kind": "round_tube", "diameter": "20 mm", "wall": 2}, "names": {"$path": "Hoop"}}); + assert!(conforms(schema.as_value(), schema.as_value(), &p)); + assert!(serde_json::from_value::(p).is_ok()); + let mut s = Session { param_check: ParamCheck::Strict, ..Session::default() }; + s.execute("sketch.create", &json!({"plane": "XY", "name": "Line"})).unwrap(); + s.execute("sketch.line", &json!({"points": [[0, 0], [100, 0]]})).unwrap(); + s.execute("sketch.finish", &json!({})).unwrap(); + let p = json!({"sketch": "Line", "lines": ["l1"], "continuous": true, "profile": {"kind": "bar", "width": 10, "height": 5}}); + let result = s.execute("frame.member", &p).unwrap(); + let schema = output_schema_for::(); + assert!(conforms(schema.as_value(), schema.as_value(), &result), "{result}"); + let mut unknown = p; + unknown["typo"] = json!(true); + assert!(s.execute("frame.member", &unknown).unwrap_err().to_string().contains("typo")); +} diff --git a/crates/engine/src/schema/mod.rs b/crates/engine/src/schema/mod.rs index 2981f17f74b..c3c54e55f5b 100644 --- a/crates/engine/src/schema/mod.rs +++ b/crates/engine/src/schema/mod.rs @@ -64,6 +64,7 @@ pub mod diagnostics; pub mod edit; pub mod features; pub mod file; +pub mod frame; pub mod inspect; pub mod joints; pub mod libraries; diff --git a/crates/engine/src/schema/unconverted.txt b/crates/engine/src/schema/unconverted.txt index a1d80a68923..04c3972bbf6 100644 --- a/crates/engine/src/schema/unconverted.txt +++ b/crates/engine/src/schema/unconverted.txt @@ -74,7 +74,6 @@ file.save file.save_as file.save_mesh file.slicers -frame.member frame.profile.insert frame.profile.list frame.profile.properties diff --git a/crates/ui-egui/src/control_job.rs b/crates/ui-egui/src/control_job.rs index 931f7ce4b79..3d6ad7496f5 100644 --- a/crates/ui-egui/src/control_job.rs +++ b/crates/ui-egui/src/control_job.rs @@ -49,6 +49,7 @@ const AHEAD_AREAS: &[&str] = &[ "explode", "expr", "face", + "frame", "joint", "material", "mesh", diff --git a/crates/ui-egui/src/dialogs_frame.rs b/crates/ui-egui/src/dialogs_frame.rs index a45b27d3456..d2f45f34cd9 100644 --- a/crates/ui-egui/src/dialogs_frame.rs +++ b/crates/ui-egui/src/dialogs_frame.rs @@ -1,6 +1,6 @@ -//! Frame Member (`frame.member`): structural members along the lines of a frame sketch. The lines -//! are picked in the view; the section is a built-in profile with its dimensions, or the profiles -//! picked in another sketch. Anchor, angle and mirror place the section on each line. +//! Frame Member (`frame.member`): separate curves or one continuous line/arc path from a frame +//! sketch. The curves are picked in the view; the section is a built-in profile with its +//! dimensions, or profiles picked in another sketch. Anchor, angle and mirror place the section. use serde_json::{Map, Value, json}; use solidcraft_engine::Sel; @@ -33,6 +33,7 @@ const ANCHORS: &[(&str, &str)] = &[ pub struct Member { /// Every line of the frame sketch, now and as lines are added, not only the lines picked. pub all: bool, + pub continuous: bool, /// The built-in profile (an index into `frame::profile_kinds`), used when no section is picked. pub kind: usize, /// Each built-in profile's dimensions, its required ones then its optional ones; kept per @@ -59,7 +60,7 @@ impl Member { .collect(); // A rectangular tube is the most common member. let kind = frame::profile_kinds().iter().position(|k| k.kind == "rect_tube").unwrap_or(0); - Member { all: false, kind, dims, whole: None, anchor: 0, angle: String::new(), mirror: false, name: String::new() } + Member { all: false, continuous: false, kind, dims, whole: None, anchor: 0, angle: String::new(), mirror: false, name: String::new() } } } @@ -77,6 +78,8 @@ fn tr(text: &str) -> &str { pub fn rows(app: &SolveApp, ui: &mut egui::Ui, m: &mut Member, inputs: &[SelInput]) -> bool { let mut enter = false; form_row(ui, "All Lines", |ui| check(ui, &mut m.all)); + let continuous_label = app.tr("ui.frame.continuous").to_string(); + form_row(ui, &continuous_label, |ui| check(ui, &mut m.continuous)); let picked = !crate::selection::items(inputs, 1).is_empty(); if let Some(sketch) = m.whole.filter(|_| !picked) { let name = app.session.doc.feature(sketch).map(|f| f.name.clone()).unwrap_or_default(); @@ -135,6 +138,12 @@ pub fn commands(app: &SolveApp, m: &Member, inputs: &[SelInput], extra: &Map Option<(Kind, Vec, Map)> { - let FeatureKind::FrameMember { path_sketch, lines, profile, anchor, angle, mirror, body_name, .. } = kind else { return None }; + let FeatureKind::FrameMember { path_sketch, lines, continuous, profile, anchor, angle, mirror, body_name, .. } = kind else { return None }; let (_, mut inputs) = start(app, "frame.member")?; let st = app.session.model.state(); let mut m = Member::new(); m.all = lines.is_empty(); + m.continuous = *continuous; let ids = if m.all { frame::member_line_ids(&st, kind).unwrap_or_default() } else { lines.clone() }; if let Some(i) = inputs.get_mut(0) { i.items = ids.into_iter().map(|id| Sel::ExternalSketchCurve { sketch: path_sketch.0, id }).collect(); diff --git a/crates/ui-egui/src/dialogs_frame_tests.rs b/crates/ui-egui/src/dialogs_frame_tests.rs index b231ffd55ad..00e89ba5f2e 100644 --- a/crates/ui-egui/src/dialogs_frame_tests.rs +++ b/crates/ui-egui/src/dialogs_frame_tests.rs @@ -200,3 +200,33 @@ fn picked_lines_stay_in_the_sketch_they_were_picked_in() { d.inputs[0].items.push(Sel::ExternalSketchCurve { sketch: rails, id: ids[0].clone() }); assert!(apply_commands(&app, &d).unwrap_err().contains("one sketch")); } + +#[test] +fn continuous_member_dialog_preserves_path_order_and_edit_intent() { + let d = 100.0 / 2f64.sqrt(); + let mut app = app_with(&[ + ("sketch.create", json!({"plane": "XY", "name": "Chassis"})), + ("sketch.line", json!({"points": [[100, -200], [100, 0]]})), + ("sketch.arc.three_point", json!({"start": [100, 0], "through": [d, d], "end": [0, 100]})), + ("sketch.line", json!({"points": [[0, 100], [-300, 100]]})), + ("sketch.finish", json!({})), + ]); + let id = sketch_id(&app, "Chassis"); + let ids: Vec<_> = app.session.doc.sketch(id).unwrap().curves.iter().map(|c| c.id.clone()).collect(); + let mut d = dialog_on(&mut app, &ids); + member(&mut d).continuous = true; + let commands = apply_commands(&app, &d).unwrap(); + assert_eq!(commands[0].1["continuous"], true); + assert_eq!(commands[0].1["lines"], json!(ids)); + run_all(&mut app, commands); + assert_eq!(body_names(&app).len(), 1); + let fid = app.session.doc.features.last().unwrap().id; + let mut edit = edit_dialog(&app, fid, None).unwrap(); + assert!(member(&mut edit).continuous); + let commands = apply_commands(&app, &edit).unwrap(); + assert_eq!(commands[0].1["params"]["continuous"], true); + run_all(&mut app, commands); + assert_eq!(body_names(&app).len(), 1); + member(&mut edit).all = true; + assert!(apply_commands(&app, &edit).unwrap_err().contains("path order")); +} diff --git a/crates/ui-egui/src/history_off_thread_tests.rs b/crates/ui-egui/src/history_off_thread_tests.rs index 575911d30c2..a28177c219f 100644 --- a/crates/ui-egui/src/history_off_thread_tests.rs +++ b/crates/ui-egui/src/history_off_thread_tests.rs @@ -644,6 +644,51 @@ fn an_agent_design_change_computes_off_the_window_thread() { assert!((v - (12500.0 - holes)).abs() < 1.0, "{v}"); } +/// A continuous member keeps the worker's sweep instead of computing it again on the window thread. +#[test] +fn an_agent_continuous_frame_member_reuses_the_worker_result() { + let mut h = Harness::new(); + h.app.home.open = false; + h.app.run("sketch.create", json!({"plane": "XY", "name": "Chassis"})).unwrap(); + let mut lines = Vec::new(); + for (command, params) in [ + ("sketch.line", json!({"points": [[100, -200], [100, 0]]})), + ("sketch.arc.three_point", json!({"start": [100, 0], "through": [100.0 / 2f64.sqrt(), 100.0 / 2f64.sqrt()], "end": [0, 100]})), + ("sketch.line", json!({"points": [[0, 100], [-300, 100]]})), + ] { + let result = h.app.run(command, params).unwrap(); + lines.extend(result["created"]["curves"].as_array().unwrap().iter().cloned()); + } + h.app.run("sketch.finish", json!({})).unwrap(); + h.app.apply_off_thread = Some(Duration::ZERO); + h.app.preferences.agent_off_thread = true; + let (tx, rx) = std::sync::mpsc::channel(); + h.app.control_rx = Some(rx); + let before = h.app.session.doc.clone(); + let undo = h.app.session.undo.len(); + let member = ask( + &tx, + "engine.execute", + json!({"command": "frame.member", "params": { + "sketch": "Chassis", "lines": lines, "continuous": true, + "profile": {"kind": "round_tube", "diameter": 20, "wall": 2}, "body_name": "Hoop" + }}), + ); + let view = ask(&tx, "ui.inspect", json!({})); + h.frames(1); + assert!(view.try_recv().is_ok_and(|r| r["ok"] == true), "the window answers meanwhile"); + if h.app.agent_computing().is_some() { + assert!(std::sync::Arc::ptr_eq(&before, &h.app.session.doc)); + } + let reply = reply_to(&mut h, &member); + assert_eq!(reply["ok"], true, "{reply}"); + assert_eq!(h.app.session.doc.features.len(), before.features.len() + 1); + assert_eq!(h.app.session.undo.len(), undo + 1); + assert_eq!(h.app.session.model.last_recomputed, 0, "the window reuses the computed member"); + assert_eq!(h.app.session.model.state().bodies.len(), 1); + assert_eq!(h.app.session.model.state().bodies[0].name, "Hoop"); +} + /// A person's edit while the agent's command computes goes first; the agent's command is /// computed again for the design as it is and lands after it, never in between. #[test] diff --git a/docs/book/src/reference/glossary.md b/docs/book/src/reference/glossary.md index fb4948cd863..b3bdaf8cce0 100644 --- a/docs/book/src/reference/glossary.md +++ b/docs/book/src/reference/glossary.md @@ -162,6 +162,16 @@ They are listed together in the browser's *Construction* folder. - **Elsewhere:** construction plane, reference plane, datum plane (and axis, point). - **For translators:** not a sketch's construction entity. +### continuous member + +One physical length of structural stock following a connected tangent path of straight lines +and circular bends. + +- **In SolidCraft:** `frame.member` with `continuous: true`; the selected curves are saved in + path order and produce one body, with its name pinned to the feature's `$path` key. +- **For translators:** a member group can contain several separate stock pieces; selecting a + group does not join those pieces into one length of stock. + ### curve A sketch entity that is not a point: a line, an arc, a circle, an ellipse, a spline or a conic. diff --git a/docs/frames.md b/docs/frames.md index f0655e6d992..b10f942febf 100644 --- a/docs/frames.md +++ b/docs/frames.md @@ -6,15 +6,15 @@ members and their profiles. Corners, trims, end caps, gussets, welds and the cut ## The workflow -1. **Sketch the frame**: lines in a sketch, or a 3D sketch for a frame that leaves one plane - (`sketch.options sketch_3d: true`, then `sketch.line3d`). Drive the sizes with parameters as +1. **Sketch the frame**: lines and circular arcs in a sketch, or a 3D sketch for a frame that leaves one plane + (`sketch.options sketch_3d: true`, then `sketch.line3d` and `sketch.arc3d`). Drive the sizes with parameters as usual; members follow. 2. **Choose a profile**: a built-in one from its dimensions (below), or your own drawn in a sketch (a vendor's extrusion: insert their DXF with `sketch.insert_dxf`). A profile sketch's origin is the point that sits on each line, and its x and y are the profile's. -3. **Add members**: **Frame Member** (WELDMENTS › CREATE, `frame.member`) makes one body per line, - square to it, from its start to its end. Repeat with another profile for the next group of - lines. +3. **Add members**: **Frame Member** (WELDMENTS › CREATE, `frame.member`) makes one body per selected + line or arc. Enable **One Continuous Member** to make a connected tangent line–arc–line run + into one tube. Select its segments in path order. Repeat for another physical member. ```json {"command": "frame.member", "params": {"sketch": "Frame", "profile": {"kind": "rect_tube", "width": 40, "height": 40, "wall": 3}}} @@ -30,8 +30,11 @@ the selected body (or the last body of the active component). ## The Frame Member dialog -- **Lines**: pick the frame sketch's lines in the view (2D or 3D sketch lines). **All Lines** - makes a member on every line of that sketch instead, including lines drawn later. +- **Lines**: pick the frame sketch's lines and circular arcs in the view (2D or 3D). **All Lines** + keeps the existing default: a member on every drawn straight line, including lines drawn later. +- **One Continuous Member**: the selected curves make one body. Keep **All Lines** off and + select curves in connected path order. Curves drawn backwards are reversed automatically. + A sharp corner needs an explicit tangent bend arc; the command does not invent a bend radius. - **Section (optional)**: pick the section's region in another sketch (the ring between two circles makes a tube). With nothing picked, **Profile** chooses a built-in profile and its dimensions follow; optional ones left empty take their defaults. @@ -44,10 +47,16 @@ the selected body (or the last body of the active component). ## frame.member -- `sketch`: the frame sketch. `lines`: the curve ids to lay members on (2D lines or 3D sketch - lines), each once; left out, every straight line drawn in the sketch: not construction, not +- `sketch`: the frame sketch. `lines`: the curve ids to lay members on (2D or 3D sketch + lines and circular arcs), each once; left out, every straight line drawn in the sketch: not construction, not projected or otherwise linked (a sketch on a face projects the face's edges; they are references, not members), and with a length. +- `continuous`: false by default. When true, explicitly selected `lines` form one physical + member, in path order. Their ends must meet within 0.000001 mm and their tangents within + 0.000001 rad. Open line/arc paths are supported; splines and closed members are refused. + The section starts with the orientation below and rotates through each bend, carrying that + orientation into subsequent straights and bends in other planes. A bend whose axis crosses + the anchored section is refused. This models nominal geometry, not tube deformation or springback. - `profile` (a built-in profile) or `profile_sketch` (a sketch), one of them. A profile sketch's section is its material as nested loops alternate (an outline is material, a loop inside it a hole, a loop inside that material again), so two circles make a tube; pick other regions with @@ -68,6 +77,24 @@ the selected body (or the last body of the active component). feature, leaves the other members' names alone; `body.rename` renames a member on its line. `names` (`{line id: name}`) gives names to keep, as Edit Feature (`timeline.redefine`) passes them unless the edit changes `body_name`. + A continuous member uses `names: {"$path": "Main hoop"}` so its name survives reversing + the path or changing the first selected segment. + +### A bent chassis tube + +Draw a line from `(100, -200)` to `(100, 0)`, a quarter-circle arc with centre `(0, 0)` from +`(100, 0)` to `(0, 100)`, and a line to `(-300, 100)`. With those curve ids `l1`, `a1`, `l2`: + +```json +{"command":"frame.member","params":{"sketch":"Chassis","lines":["l1","a1","l2"],"continuous":true,"profile":{"kind":"round_tube","diameter":20,"wall":2},"body_name":"Main hoop"}} +``` + +The result is one tube, with two straight lengths of 200 and 300 mm and a 100 mm centreline +bend radius. Its nominal centreline length is `500 + 50π` mm. Grouping three separate +members or combining their solids does not record this continuous manufacturing path. + +Bend-list output and flattened round-tube cope DXF templates are subsequent fabrication +steps tracked under #4003. A continuous member does not yet produce either export. Every built-in profile is SolidCraft's own parametric definition, built in code (`solidcraft_doc::frame`). SolidCraft ships no vendor's or standard's size table: you give the diff --git a/docs/roadmap-detail.md b/docs/roadmap-detail.md index 9e680e194ca..8e5ea0680d5 100644 --- a/docs/roadmap-detail.md +++ b/docs/roadmap-detail.md @@ -69,7 +69,7 @@ PCB / Package, Render, Animation, Simulation, Manufacture/CAM, Drawings. | M12 | Release: cross-platform packages, verification and deliberate publication implemented; original current-UI demo refreshed. macOS Developer ID signing and notarization are in the release workflow (#5749; they switch on when the Apple secrets exist). Windows installer signing and broader performance work remain | in progress | 16 | | M14 | Configurations: a table of rows (parameter expressions and feature suppressions per row) switched with config.activate (undoable, all or nothing), kept through parameter renames and feature deletes (config.configure, config.table, config.column/row/activate). Per-row body materials and appearances (library looks, custom colour/opacity and clearing overrides), undoable activation and save/reopen: done. Ordered typed configuration rules, atomic validation and structured rule editing: done. Component appearance and certified semantic face style columns, atomic preview/apply and independent-copy remapping: done. Exact constructed sketch-side and immutable imported-face lineage now preserve legacy names and reject retargeting. Left: ambiguous shifted/two-sided caps | in progress | 4 | | M13 | Never lose work: atomic saves (temporary file, flush, rename; a crash at any moment leaves the old file or the new one) with the replaced version kept as `.bak`; autosave of unsaved changes to the recovery folder every 5 minutes (preference) and after big operations, only when something changed; "Recover unsaved design?" on the next launch (`doc.recovery_list`, `doc.recover`, `doc.recovery_discard`); a kill-mid-save test (process killed while saving a 0.5 MB design 25 times). File format: `"format": "solidcraft/12"`, older formats upgraded step by step (`doc::format`), newer ones refused with a message, out-of-range numbers and broken placements refused; a corpus of designs saved by M0, components-era, joints-era and current builds (apps/solidcraft-cli/tests/corpus) that must open and evaluate as saved; damaged and hostile variants (truncation, bit flips, hostile values, removed keys, repeated features, deep nesting) never panic | done | 6 | -| M15 | Frames and weldments (#4003): structural members along 2D and 3D sketch lines, butt and mitre corners, trim to faces and bodies, end caps, gussets, cosmetic welds and a cut list. Done: the profile library (`frame.profile.list`, `frame.profile.properties`, `frame.profile.insert`): bar, round bar, rectangular and round tube, angle, channel and I-beam, each SolidCraft's own parametric definition with exact fillet arcs and exact section properties (area, centroid, second moments), tested against hand-computed values; members (`frame.member`): one body per straight line of a 2D or 3D frame sketch, following parameter edits, with a built-in profile (its dimensions parameter expressions) or a profile sketch (its drawn material by alternating nested loops), anchor, angle and mirror; each member's name kept with its line. Left: corners, trims, end caps, gussets, welds, cut list, FRAME tab and dialogs | in progress | 60 | +| M15 | Frames and weldments (#4003): structural members along 2D and 3D sketch lines, butt and mitre corners, trim to faces and bodies, end caps, gussets, cosmetic welds and a cut list. Done: the profile library (`frame.profile.list`, `frame.profile.properties`, `frame.profile.insert`): bar, round bar, rectangular and round tube, angle, channel and I-beam, each SolidCraft's own parametric definition with exact fillet arcs and exact section properties (area, centroid, second moments), tested against hand-computed values; members (`frame.member`): separate selected 2D/3D lines or circular arcs, or one continuous tangent line/arc path per physical member (#9792), following parameter edits, with a built-in profile (its dimensions parameter expressions) or a profile sketch (its drawn material by alternating nested loops), anchor, angle and mirror; each member's name kept with its line or continuous path. Left: corners, trims, end caps, gussets, welds, cut list, bend lists (#9795), flattened round-tube cope DXF templates (#9796), FRAME tab and dialogs | in progress | 60 | M6 navigation preferences include **Touchpad**: Shift + pointer movement pans, Alt/Option + pointer movement orbits without a mouse button, and vertical scrolling zooms. Other presets