Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

Measure: open surface bodies report no volume or mass (#4257) (#4268)

raykholoc3dd40405d76
diff --git a/assets/locales/pending/open-surface-measurements.json b/assets/locales/pending/open-surface-measurements.json
new file mode 100644
index 0000000000..22f9f93ad2
--- /dev/null
+++ b/assets/locales/pending/open-surface-measurements.json
@@ -0,0 +1,14 @@
+{
+ "en": {
+ "Open bodies (no volume)": "Open bodies (no volume)",
+ "Open surface — no volume": "Open surface — no volume"
+ },
+ "ja": {
+ "Open bodies (no volume)": "開いたボディ(体積なし)",
+ "Open surface — no volume": "開いたサーフェス — 体積なし"
+ },
+ "zh": {
+ "Open bodies (no volume)": "未闭合实体(无体积)",
+ "Open surface — no volume": "未闭合曲面 — 无体积"
+ }
+}
diff --git a/crates/engine/src/cmd/component.rs b/crates/engine/src/cmd/component.rs
index f9d1e972e4..15e6ebd976 100644
--- a/crates/engine/src/cmd/component.rs
+++ b/crates/engine/src/cmd/component.rs
@@ -40,10 +40,10 @@ pub static COMMANDS: &[CommandSpec] = &[
),
CommandSpec::new("component.properties", "Component Physical Properties", properties::component)
.icon("measure").noundo()
- .params("component?: id or name (default active); descendants?: bool (default true). Measures the first placement, or all placements for root, including pending moves; material-aware mass and center of mass in world coordinates"),
+ .params("component?: id or name (default active); descendants?: bool (default true). Measures the first placement, or all placements for root, including pending moves; material-aware mass and center of mass in world coordinates; volume, density, mass and center of mass only for closed, consistently oriented bodies; total.open_bodies_skipped counts open bodies excluded from volume/mass totals"),
CommandSpec::new("occurrence.properties", "Occurrence Physical Properties", properties::occurrence)
.icon("measure").noundo()
- .params("occurrence: id or name; path?: [occurrence ids] (required if nested under multiple instances); descendants?: bool (default true). Physical properties of this placement in world coordinates, including pending moves"),
+ .params("occurrence: id or name; path?: [occurrence ids] (required if nested under multiple instances); descendants?: bool (default true). Physical properties of this placement in world coordinates, including pending moves; volume, density, mass and center of mass only for closed, consistently oriented bodies; total.open_bodies_skipped counts open bodies excluded from volume/mass totals"),
CommandSpec::new("component.rename", "Rename Component", rename).icon("rename").params("component, name"),
CommandSpec::new("component.delete", "Delete Component", delete).icon("delete").params("component: deletes it, its subcomponents, occurrences and features"),
CommandSpec::new("component.unlock", "Unlock Contents", unlock).icon("rigid_group").params(
diff --git a/crates/engine/src/cmd/component_properties.rs b/crates/engine/src/cmd/component_properties.rs
index 226f5d03f3..dd8033474d 100644
--- a/crates/engine/src/cmd/component_properties.rs
+++ b/crates/engine/src/cmd/component_properties.rs
@@ -93,6 +93,7 @@ fn properties(s: &Session, doc: &Document, selected: &[u64], descendants: bool,
let mut bounds = Aabb3::EMPTY;
let (mut faces, mut edges, mut vertices) = (0, 0, 0);
let mut placement_count = 0;
+ let mut skipped = 0;
let selected_placements = if selected.is_empty() {
if descendants { placements(doc, cmd)? } else { vec![(0, Vec::new(), solidcraft_doc::IDENTITY)] }
} else {
@@ -121,18 +122,24 @@ fn properties(s: &Session, doc: &Document, selected: &[u64], descendants: bool,
let measured = solidcraft_kernel::measure(&placed)?;
let density = doc.density(&body.name);
let body_mass = measured.volume * density / 1000.0;
- volume += measured.volume;
+ let closed = crate::cmd::inspect::encloses_volume(&placed);
+ if closed {
+ volume += measured.volume;
+ mass += body_mass;
+ moment += measured.centroid * body_mass;
+ } else {
+ skipped += 1;
+ }
area += measured.area;
- mass += body_mass;
- moment += measured.centroid * body_mass;
bounds = bounds.union(&measured.bbox);
faces += measured.merged.faces;
edges += measured.merged.edges;
vertices += measured.merged.vertices;
bodies.push(json!({"name": body.name, "component": component, "path": path,
"material": doc.body_material(&body.name),
- "density_g_cm3": density, "mass_g": body_mass, "volume_mm3": measured.volume,
- "area_mm2": measured.area, "center_of_mass": measured.centroid,
+ "closed": closed, "density_g_cm3": closed.then_some(density),
+ "mass_g": closed.then_some(body_mass), "volume_mm3": closed.then_some(measured.volume),
+ "area_mm2": measured.area, "center_of_mass": closed.then_some(measured.centroid),
"bbox": {"min": measured.bbox.min, "max": measured.bbox.max}}));
}
}
@@ -146,7 +153,7 @@ fn properties(s: &Session, doc: &Document, selected: &[u64], descendants: bool,
let bbox = if bodies.is_empty() { Value::Null } else { json!({"min": bounds.min, "max": bounds.max}) };
Ok(json!({"path": selected, "coordinate_frame": "world", "descendants": descendants,
"placement_count": placement_count, "body_count": bodies.len(), "bodies": bodies,
- "total": {"volume_mm3": volume, "area_mm2": area, "mass_g": mass,
+ "total": {"open_bodies_skipped": skipped, "volume_mm3": volume, "area_mm2": area, "mass_g": mass,
"center_of_mass": centroid, "bbox": bbox, "faces": faces, "edges": edges, "vertices": vertices}}))
}
diff --git a/crates/engine/src/cmd/inspect.rs b/crates/engine/src/cmd/inspect.rs
index 4905525fe5..60b404a5b2 100644
--- a/crates/engine/src/cmd/inspect.rs
+++ b/crates/engine/src/cmd/inspect.rs
@@ -13,7 +13,7 @@ pub static COMMANDS: &[CommandSpec] = &[
.icon("measure")
.key("I")
.noundo()
- .params("bodies?: [names] (default all); or items: [1-2 selections] (face/edge: type, body, point; index optional) → length/area/volume; diameter, radius, circumference or arc_length/angle_deg of circles, arcs and cylinders; slot sizes; min (distance_mm, from, to), max, center_distance (centre to centre, or from an axis) and angle"),
+ .params("bodies?: [names] (default all) → closed per body; volume_mm3, center_of_mass, density_g_cm3 and mass_g only for closed, consistently oriented bodies; area, bbox and counts for all; total.open_bodies_skipped counts bodies excluded from volume/mass totals; or items: [1-2 selections] (face/edge: type, body, point; index optional) → length/area/volume; diameter, radius, circumference or arc_length/angle_deg of circles, arcs and cylinders; slot sizes; min (distance_mm, from, to), max, center_distance (centre to centre, or from an axis) and angle"),
CommandSpec::new("document.inspect", "Inspect Design", inspect).icon("inspect").noundo().params("measure?: bool (include body measurements)"),
CommandSpec::new("sketch.inspect", "Inspect Sketch", sketch_inspect).icon("inspect").noundo().params("sketch?: id|name (default active)"),
CommandSpec::new("model.edges", "List Edges", model_edges).icon("inspect").noundo().params("body: name"),
@@ -53,20 +53,33 @@ pub static COMMANDS: &[CommandSpec] = &[
.params("command: a command id. Returns {id, label, params, input, output} (and param_warnings in the warn parameter-check mode): the command's parameter documentation and, once the command has a typed contract, the JSON Schemas (2020-12) of its parameters and of a successful result (null otherwise). Read-only."),
];
+/// Does `body` enclose a volume? A B-rep body does when every shell is closed and consistently
+/// oriented (not a surface body), a mesh body when every triangle side is shared by exactly two
+/// triangles. Only that is asked: other findings of a full validity check (faces that don't
+/// mesh, tolerance gaps of an imported solid) don't take a closed body's volume away, and the
+/// check stays cheap for designs with many bodies.
+pub(crate) fn encloses_volume(body: &solidcraft_kernel::Body) -> bool {
+ if body.is_mesh() { body.is_closed_mesh() } else { !body.is_surface() }
+}
+
pub fn measure_json(b: &solidcraft_doc::ModelBody) -> Value {
match b.measure() {
- Ok(m) => json!({
- "name": b.name,
- "volume_mm3": m.volume,
- "area_mm2": m.area,
- "center_of_mass": m.centroid,
- "bbox": {"min": m.bbox.min, "max": m.bbox.max},
- "faces": m.merged.faces,
- "edges": m.merged.edges,
- "vertices": m.merged.vertices,
- "face_types": m.merged.face_types,
- "kernel": {"faces": m.faces, "edges": m.edges, "vertices": m.vertices, "shells": m.shells},
- }),
+ Ok(m) => {
+ let closed = encloses_volume(&b.body);
+ json!({
+ "name": b.name,
+ "closed": closed,
+ "volume_mm3": closed.then_some(m.volume),
+ "area_mm2": m.area,
+ "center_of_mass": closed.then_some(m.centroid),
+ "bbox": {"min": m.bbox.min, "max": m.bbox.max},
+ "faces": m.merged.faces,
+ "edges": m.merged.edges,
+ "vertices": m.merged.vertices,
+ "face_types": m.merged.face_types,
+ "kernel": {"faces": m.faces, "edges": m.edges, "vertices": m.vertices, "shells": m.shells},
+ })
+ }
Err(e) => json!({"name": b.name, "error": e.to_string()}),
}
}
@@ -112,12 +125,13 @@ fn measure(s: &mut Session, p: &Value) -> Result<Value> {
// and the area (both faces minus the holes, plus the bores).
let open = sh.perforated_area();
if open > 0.0 {
- let v = b["volume_mm3"].as_f64().unwrap_or(0.0);
- let nv = v - open * sh.t;
- if let Some(m) = b["mass_g"].as_f64().filter(|_| v > 0.0) {
- b["mass_g"] = json!(m * nv / v);
+ if let Some(v) = b["volume_mm3"].as_f64() {
+ let nv = v - open * sh.t;
+ if let Some(m) = b["mass_g"].as_f64().filter(|_| v > 0.0) {
+ b["mass_g"] = json!(m * nv / v);
+ }
+ b["volume_mm3"] = json!(nv);
}
- b["volume_mm3"] = json!(nv);
let bores: f64 = sh
.perforations
.iter()
@@ -127,6 +141,7 @@ fn measure(s: &mut Session, p: &Value) -> Result<Value> {
}
}
}
+ let skipped = bodies.iter().filter(|b| b["closed"] == false).count();
let tv: f64 = bodies.iter().filter_map(|b| b["volume_mm3"].as_f64()).sum();
let ta: f64 = bodies.iter().filter_map(|b| b["area_mm2"].as_f64()).sum();
let tf: u64 = bodies.iter().filter_map(|b| b["faces"].as_u64()).sum();
@@ -134,7 +149,7 @@ fn measure(s: &mut Session, p: &Value) -> Result<Value> {
let tvx: u64 = bodies.iter().filter_map(|b| b["vertices"].as_u64()).sum();
let tm: f64 = bodies.iter().filter_map(|b| b["mass_g"].as_f64()).sum();
Ok(
- json!({"body_count": bodies.len(), "bodies": bodies, "total": {"volume_mm3": tv, "area_mm2": ta, "mass_g": tm, "faces": tf, "edges": te, "vertices": tvx}}),
+ json!({"body_count": bodies.len(), "bodies": bodies, "total": {"open_bodies_skipped": skipped, "volume_mm3": tv, "area_mm2": ta, "mass_g": tm, "faces": tf, "edges": te, "vertices": tvx}}),
)
}
diff --git a/crates/engine/src/cmd/measure_sel.rs b/crates/engine/src/cmd/measure_sel.rs
index 7ab108d8e3..0d2fb2d6dd 100644
--- a/crates/engine/src/cmd/measure_sel.rs
+++ b/crates/engine/src/cmd/measure_sel.rs
@@ -335,10 +335,12 @@ fn describe(s: &Session, sel: &Sel) -> Option<Item> {
Some(Item { geo: Geo::Tris(tris), dir: planar.map(Vec3::from), json, shape, slot })
}
Sel::Body { name } => {
- let m = st.body(name)?.mesh();
+ let body = st.body(name)?;
+ let closed = crate::cmd::inspect::encloses_volume(&body.body);
+ let m = body.mesh();
let tris: Vec<[Vec3; 3]> = m.triangles.iter().filter_map(|t| m.tri(t)).collect();
let v = m.measure().volume;
- plain(Geo::Tris(tris), None, json!({"type": "body", "name": name, "volume_mm3": v}))
+ plain(Geo::Tris(tris), None, json!({"type": "body", "name": name, "closed": closed, "volume_mm3": closed.then_some(v)}))
}
Sel::SketchCurve { id } => sketch_curve(sketch_of(s, &st, None, |sk| sk.curve_index(id).is_some())?, id),
Sel::ExternalSketchCurve { sketch, id } => sketch_curve(sketch_of(s, &st, Some(*sketch), |_| true)?, id),
diff --git a/crates/engine/src/measure_centre_tests.rs b/crates/engine/src/measure_centre_tests.rs
index 06fd112b3a..9c87130a87 100644
--- a/crates/engine/src/measure_centre_tests.rs
+++ b/crates/engine/src/measure_centre_tests.rs
@@ -423,3 +423,108 @@ fn box_edges_measure_by_point_only() {
assert!(s.execute("inspect.measure", &json!({"items": [pick]})).is_err());
}
}
+
+fn open_revolve(s: &mut Session) {
+ run(s, "sketch.create", json!({"plane": "XY", "name": "Profile"}));
+ run(s, "sketch.line", json!({"points": [[30, 0], [30, 40]], "ids": ["side"]}));
+ run(s, "sketch.finish", json!({}));
+ run(s, "surface.revolve", json!({"sketch": "Profile", "curves": ["side"], "axis": "y", "angle": "270 deg", "body_name": "OpenTube"}));
+}
+
+#[test]
+fn open_surface_measurements_have_no_volume_properties() {
+ let mut s = Session::default();
+ open_revolve(&mut s);
+ let r = run(&mut s, "inspect.measure", json!({"bodies": ["OpenTube"]}));
+ let b = &r["bodies"][0];
+ assert_eq!(b["closed"], false);
+ for key in ["volume_mm3", "center_of_mass", "density_g_cm3", "mass_g"] {
+ assert!(b[key].is_null(), "{key}: {b}");
+ }
+ assert!(b["area_mm2"].as_f64().unwrap() > 0.0);
+ assert!(b["bbox"].is_object() && b["faces"].as_u64().unwrap() > 0);
+ assert_eq!(r["total"]["open_bodies_skipped"], 1);
+ assert_eq!(r["total"]["volume_mm3"], 0.0);
+ assert_eq!(r["total"]["mass_g"], 0.0);
+ let document = run(&mut s, "document.inspect", json!({"measure": true}));
+ assert_eq!(document["bodies"][0]["closed"], false);
+ assert!(document["bodies"][0]["center_of_mass"].is_null());
+ let picked = run(&mut s, "inspect.measure", json!({"items": [{"type": "body", "name": "OpenTube"}]}));
+ assert_eq!(picked["items"][0]["closed"], false);
+ assert!(picked["items"][0]["volume_mm3"].is_null());
+ let props = run(&mut s, "component.properties", json!({"component": "root"}));
+ assert_eq!(props["total"]["open_bodies_skipped"], 1);
+ assert!(props["bodies"][0]["mass_g"].is_null());
+ assert!(props["total"]["center_of_mass"].is_null());
+}
+
+#[test]
+fn volume_totals_skip_open_surfaces_and_keep_closed_box_properties() {
+ let mut s = Session::default();
+ run(&mut s, "solid.box", json!({"length": 10, "width": 20, "height": 30, "body_name": "Box"}));
+ let before = run(&mut s, "inspect.measure", json!({}));
+ let b = &before["bodies"][0];
+ assert_eq!(b["closed"], true);
+ assert!(close(&b["volume_mm3"], 6000.0, 1e-9));
+ assert!(close(&b["mass_g"], 6.0 * s.doc.density("Box"), 1e-9));
+ for (axis, expected) in [5.0, 10.0, 15.0].into_iter().enumerate() {
+ assert!(close(&b["center_of_mass"][axis], expected, 1e-9));
+ }
+ let props_before = run(&mut s, "component.properties", json!({"component": "root"}));
+ open_revolve(&mut s);
+ let after = run(&mut s, "inspect.measure", json!({}));
+ assert_eq!(after["body_count"], 2);
+ assert_eq!(after["total"]["open_bodies_skipped"], 1);
+ for key in ["volume_mm3", "mass_g"] {
+ assert_eq!(before["total"][key], after["total"][key]);
+ }
+ assert!(after["total"]["area_mm2"].as_f64().unwrap() > before["total"]["area_mm2"].as_f64().unwrap());
+ let props_after = run(&mut s, "component.properties", json!({"component": "root"}));
+ assert_eq!(props_after["total"]["open_bodies_skipped"], 1);
+ for key in ["volume_mm3", "mass_g", "center_of_mass"] {
+ assert_eq!(props_before["total"][key], props_after["total"][key]);
+ }
+}
+
+/// An ASCII STL of the tetrahedron (0,0,0), (10,0,0), (0,10,0), (0,0,10), outward facing; `open`
+/// leaves its slanted face out.
+fn tetra_stl(open: bool) -> String {
+ let faces: &[[[i32; 3]; 3]] = &[
+ [[0, 0, 0], [0, 10, 0], [10, 0, 0]],
+ [[0, 0, 0], [10, 0, 0], [0, 0, 10]],
+ [[0, 0, 0], [0, 0, 10], [0, 10, 0]],
+ [[10, 0, 0], [0, 10, 0], [0, 0, 10]],
+ ];
+ let mut stl = String::from("solid t\n");
+ for f in &faces[..if open { 3 } else { 4 }] {
+ stl += "facet normal 0 0 0\nouter loop\n";
+ for [x, y, z] in f {
+ stl += &format!("vertex {x} {y} {z}\n");
+ }
+ stl += "endloop\nendfacet\n";
+ }
+ stl + "endsolid t\n"
+}
+
+#[test]
+fn a_watertight_mesh_keeps_its_volume_and_an_open_mesh_has_none() {
+ let dir = std::env::temp_dir().join(format!("solidcraft-measure-open-mesh-{}", std::process::id()));
+ let _ = std::fs::remove_dir_all(&dir);
+ std::fs::create_dir_all(&dir).unwrap();
+ let mut s = Session::default();
+ for (name, open) in [("Closed", false), ("Open", true)] {
+ let path = dir.join(format!("{name}.stl"));
+ std::fs::write(&path, tetra_stl(open)).unwrap();
+ run(&mut s, "file.insert_mesh", json!({"path": path.to_string_lossy()}));
+ }
+ let _ = std::fs::remove_dir_all(&dir);
+ let r = run(&mut s, "inspect.measure", json!({}));
+ let bodies = r["bodies"].as_array().unwrap();
+ let by = |n: &str| bodies.iter().find(|b| b["name"] == n).unwrap_or_else(|| panic!("{n}: {r}"));
+ assert_eq!(by("Closed")["closed"], true);
+ assert!(close(&by("Closed")["volume_mm3"], 1000.0 / 6.0, 1e-6), "{r}");
+ assert_eq!(by("Open")["closed"], false);
+ assert!(by("Open")["volume_mm3"].is_null() && by("Open")["mass_g"].is_null(), "{r}");
+ assert_eq!(r["total"]["open_bodies_skipped"], 1);
+ assert!(close(&r["total"]["volume_mm3"], 1000.0 / 6.0, 1e-6), "{r}");
+}
diff --git a/crates/ui-egui/src/design_properties.rs b/crates/ui-egui/src/design_properties.rs
index a1ff144c41..3fa2d8b198 100644
--- a/crates/ui-egui/src/design_properties.rs
+++ b/crates/ui-egui/src/design_properties.rs
@@ -135,13 +135,22 @@ pub fn show_object(app: &mut SolveApp, ctx: &egui::Context) {
let mut rows: Vec<(&str, String)> = Vec::new();
let total = &v["total"];
let bodies = v["bodies"].as_array().cloned().unwrap_or_default();
- if let [b] = bodies.as_slice() {
- // The engine names every body's material, measured or not: nothing to guess here.
+ let skipped = total["open_bodies_skipped"].as_u64().unwrap_or(0);
+ if let [b] = bodies.as_slice()
+ && b["closed"] == true
+ {
rows.push(("Material", b["material"].as_str().unwrap_or_default().to_string()));
rows.push(("Density", format!("{:.3} g/cm³", number(b, "density_g_cm3"))));
}
- rows.push(("Mass", format!("{:.3} g", number(total, "mass_g"))));
- rows.push(("Volume", crate::prefs::show_mm(app, number(total, "volume_mm3"), 3)));
+ if !bodies.is_empty() && skipped == bodies.len() as u64 {
+ rows.push(("", crate::i18n::tr_label("Open surface — no volume").to_string()));
+ } else {
+ rows.push(("Mass", format!("{:.3} g", number(total, "mass_g"))));
+ rows.push(("Volume", crate::prefs::show_mm(app, number(total, "volume_mm3"), 3)));
+ }
+ if skipped > 0 && skipped < bodies.len() as u64 {
+ rows.push(("Open bodies (no volume)", skipped.to_string()));
+ }
rows.push(("Area", crate::prefs::show_mm(app, number(total, "area_mm2"), 2)));
let geometry = if total.get("center_of_mass").is_some() { Some(total) } else { bodies.first().filter(|_| bodies.len() == 1) };
if let Some(b) = geometry {
@@ -175,6 +184,35 @@ mod tests {
use crate::scenario::Harness;
+ #[test]
+ fn open_surface_properties_show_area_without_volume_rows() {
+ let mut h = Harness::new();
+ for (command, params) in [
+ ("sketch.create", json!({"plane": "XY", "name": "Profile"})),
+ ("sketch.line", json!({"points": [[30, 0], [30, 40]], "ids": ["side"]})),
+ ("sketch.finish", json!({})),
+ ("surface.revolve", json!({"sketch": "Profile", "curves": ["side"], "axis": "y", "angle": "270 deg", "body_name": "OpenTube"})),
+ ] {
+ h.app.run(command, params).unwrap();
+ }
+ let measured = h.app.run("inspect.measure", json!({"bodies": ["OpenTube"]})).unwrap();
+ h.app.menu.props = Some(("OpenTube".into(), measured));
+ h.frames(2);
+ assert!(h.widget("Open surface — no volume").is_some());
+ assert!(h.widget("Area").is_some());
+ for label in ["Volume", "Density", "Mass", "Center of mass"] {
+ assert!(h.widget(label).is_none(), "{label} must not be shown for an open surface");
+ }
+ assert!(h.widget("Open bodies (no volume)").is_none());
+ h.app.run("solid.box", json!({"length": 10, "width": 20, "height": 30, "body_name": "Box"})).unwrap();
+ let both = h.app.run("inspect.measure", json!({})).unwrap();
+ h.app.menu.props = Some(("2 bodies".into(), both));
+ h.frames(2);
+ for label in ["Volume", "Mass", "Open bodies (no volume)"] {
+ assert!(h.widget(label).is_some(), "{label} is shown for a solid with an open surface");
+ }
+ }
+
#[test]
fn the_window_edits_properties_in_one_undo_step_and_keeps_other_tools_data() {
let mut h = Harness::new();
diff --git a/docs/mcp.md b/docs/mcp.md
index 10f6f24568..2baf550394 100644
--- a/docs/mcp.md
+++ b/docs/mcp.md
@@ -257,7 +257,7 @@ The `skill_reference` tool returns these documents from the copies built into So
| `execute` | `command`, `params?`, `verbose?` (default true) | Run any command with JSON parameters (`list_commands` shows them). Failures leave the design unchanged. A feature command replies with the feature (`feature`, `name`), every body (`bodies`) and the bodies it created, changed and removed (`created_bodies`, `changed_bodies`, `removed_bodies`). `verbose: false` uses the same compact reply as `batch`. |
| `batch` | `commands: [{command, params}]`, `rollback?` (default true), `verbose?` (default true), `timings?`, `profile?`, `coalesce_parameters?` (default false) | Run steps in order, stop at the first error and undo the completed steps. The reply names the failing step (`failed.index`, `failed.command`, `failed.error`), every result before it, `rolled_back` (true only when the design really went back to where the batch started), `undone`, `applied` (the indices of the steps whose changes are in the design) and `not_run` (the steps never sent). A step may name a tool instead of a command, with that tool's arguments as `params`: `set_parameter` (runs `parameters.change`; `value` or `expression`), `list_commands` (`engine.commands`, filtered by `filter` as the tool filters it), `describe_command` (`engine.describe`), `execute` (`{command, params}`), `measure`, `inspect_design` (`document.inspect`: each sketch as its counts, not its full contents, and no joints), `undo`, `redo`, `export`, `save`, `open`, `new_design` and `crash_reports`. `screenshot`, `body_topology` (use `model.edges` and `model.faces`), `batch`, `pending`, `running` and `skill_reference` can't be steps: such a batch fails before anything is sent. `verbose: false` keeps the reply small in large designs: feature steps leave out the full body list (`created_bodies`, `changed_bodies`, `removed_bodies` stay) and sketch steps the ids they repeat outside `created`. Bridged to an app that has `engine.batch`, the whole batch is one control request (one frame of the app). Older apps, and apps showing the agent cursor, get the steps one by one. `timings: true` adds `timings: [{index, command, ms}]` for every step run, the failing one included, and `total_ms`. `profile: true` also adds each step's `profile: {boolean_ms, tessellate_ms, other_ms}`, its time in kernel booleans, in tessellation and the rest. Steps are timed where they run: in the app when bridged. An app without `engine.batch` is timed step by step, without `profile`. `coalesce_parameters: true` sets each run of consecutive plain parameter edits (`parameters.change` or `set_parameter` with a name and a value, or `changes`) together, so the design rebuilds once per run instead of once per edit. Steps between runs see the design up to date. Each step keeps its own result (`coalesced`: the run's length), and the run is one undo step. The run skips the states between its edits, so an edit refused on its own can go through with the run's later ones. A refused run goes step by step, naming the refused step. |
| `inspect_design` | `measure?` (default true), `sketches?` (default true), `joints?` (default true) | Design properties (`metadata`: project, author… and other tools' keys; set them with `execute` `document.metadata.set`), parameters, timeline (type, suppressed, rolled back, error, warning, timing), bodies (volume, area, centre of mass, bbox, face/edge/vertex counts, visible; `removed_later: true` while a sketch is being edited on a rolled-back timeline and a later feature deletes the body, which is then not shown), sketches (curves, points, constraints, profiles, DOF, solve status, visible), joints when the design has any (as `joint.inspect` gives them: each origin's occurrence, component and path, the snap as saved, the feature, face, edge or sketch curve (`sketch: {id, name, curve}`) its persistent names refer to, `resolves` and the `error` when it is lost; kind, offset, angle, flip, values, limits, expressions, motion links; `execute` `joint.inspect {joint}` gives one joint), selection, undo depth. Hide helper sketches, bodies or construction planes with `execute` `browser.visibility` (`{items, visible}` or `{folder, visible}`), and joint glyphs with `{joints: [id or name], visible}` or `{folder: "joints", visible}` (a hidden joint still constrains and drives; `joint.list` reports each joint's `visible`). |
-| `measure` | `body?` or `items?` | Volume (mm³), area (mm²), centre of mass, bbox and topology counts per body, with totals. With `items` (one or two selections as `execute` takes them: `face`, `edge`, `vertex`, `sketch_curve`, `profile`), the picked geometry instead: faces and edges need only `type`, `body` and `point`; `index` is optional. See below. |
+| `measure` | `body?` or `items?` | Area (mm²), bbox, topology counts and `closed` per body. Volume (mm³), volume centre of mass, density and mass are reported only for closed, consistently oriented bodies (null or omitted for open surfaces). Volume/mass totals skip open bodies; `total.open_bodies_skipped` gives their count. Area and topology totals include all bodies. With `items` (one or two selections as `execute` takes them: `face`, `edge`, `vertex`, `sketch_curve`, `profile`), the picked geometry instead: faces and edges need only `type`, `body` and `point`; `index` is optional. See below. |
| `body_topology` | `body` | Edges (index, midpoint, length, ends) and faces (index, name, area, centroid, normal, `point`, and for a cylindrical face its `cylinder`: `origin`, `axis`, `radius`). An edge midpoint is the `[x,y,z]` that picks that edge for fillet and chamfer. A face's `point` lies on it and picks it (its centroid may not: that of a face with a hole is in the hole); a face's `name` picks it for the commands that take faces (`face.delete`, `solid.shell`, `solid.draft`, `solid.offset_face`, `solid.split_face`, `solid.replace_face`, and `face` of `sheet.convert`). |
| `set_parameter` | `name`, `value` or `expression` (number or expression), `unit?`, `comment?` | Create or change a user parameter and recompute. `expression` is another name for `value` (the one `parameters.change` uses): give one of them, or both only when they agree; neither, or two that differ, is an error. Reports `recomputed` (features rebuilt), `restored` (features whose earlier result for the same inputs was reused, e.g. a value set back) and features that now fail. |
| `screenshot` | `view?` (iso, top, front, back, bottom, left, right, home, fit, or a named view saved with `view.save`), `camera?` (`{target, yaw, pitch, distance, fov?}`, as `view.apply`), `path?`, `width?`, `height?`, `source?` (window, model), `grid?`, `axes?` | A PNG image content block. Headless: a render with the viewport's pipelines on a headless GPU device (see `solidcraft-cli gpu`; with no adapter, the CPU rasterizer, without analysis colours), fitted to the model, or from the named view or camera; the reply's `renderer` says which (`gpu`, `gpu-software`, `cpu`, with a `warning` for `cpu`). Bridged: the app window (default) or a model render with the app's camera; a named view or camera moves the app's viewport there first (`execute` `view.apply` does the same without a screenshot). `grid: false` and `axes: false` leave the ground grid (it lies on Z 0 and cuts through a part that straddles it) and the origin's axes out of a model render; axes hidden with `browser.visibility` stay out whatever `axes` says. Bridged, a screenshot that gives `grid` or `axes` is a model render, which follows the app's Grid and Origin switches for what it does not give; `source: "window"` with either is an error. A window that is minimised or on another macOS Space presents no frame: with no `source` the reply is a model render and says so (`fallback`); `source: "window"` is an error saying why, at once. Agents that don't need the app's chrome can ask for `source: "model"`. |