Emboss: an emboss or deboss that changes nothing says so (#10940) (#10944)

* claim: #10940

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Emboss: an emboss or deboss that changes nothing says so (#10940)

solid.emboss on a body its tool missed (a sketch on the far side of the
material, a depth that stops short) was recorded as a success with no
warning, so a sheet metal part looked embossed when it was not. The
evaluation now compares the bodies before and after and adds a warning
when none changed. A working emboss or deboss is silent.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Emboss: the changed-nothing warning names what to check, not a cause it can't know (#10940)

CodeRabbit pointed out that an emboss can change nothing for other reasons
than missing the body (for example a profile that lies inside material that
is already there), so the warning no longer claims the profile misses the
body. It says the operation changed nothing and suggests checking where the
profile lies, which side of the face the sketch is on, and the depth.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Emboss test: put the missing sketch below the sheet, since main's sheet metal emboss now cuts from its underside (#10940)

On current main a deboss from the XY plane reaches the sheet (it is changed and gets
the sheet metal flat-pattern warning), so the test no longer showed an emboss that
changes nothing. A sketch 5 mm below the sheet misses it on both bases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: thocsmith <193096300+thocsmith@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
thocsmith
2026-11-05 05:59:00 +00:00
committed by GitHub
parent db20c8be23
commit 70603de654
3 changed files with 52 additions and 3 deletions
+1 -1
View File
@@ -7266,7 +7266,7 @@ fn eval_feature(
| FeatureKind::Rib { .. }
| FeatureKind::ReplaceFace { .. }
| FeatureKind::Align { .. }
| FeatureKind::Remove { .. } => more::eval(doc, vals, f, st),
| FeatureKind::Remove { .. } => more::eval(doc, vals, f, st, warning),
FeatureKind::Sketch { plane, sketch } => {
let anchor = crate::face_anchor::plane_face_anchor(plane);
let fst = match anchor {
+15 -2
View File
@@ -8,7 +8,7 @@ use crate::sheet;
use solidcore_record::{Loop2, Seg2};
use solidcraft_geom::{Aabb3, Ring};
pub(super) fn eval(doc: &Document, vals: &BTreeMap<String, Value>, f: &Feature, st: &mut ModelState) -> Result<()> {
pub(super) fn eval(doc: &Document, vals: &BTreeMap<String, Value>, f: &Feature, st: &mut ModelState, warning: &mut Option<String>) -> Result<()> {
match &f.kind {
FeatureKind::Emboss { sketch, profiles, depth, deboss, targets, face } => {
let ss = st.sketch(sketch.0).ok_or_else(|| DocError::Unknown(format!("sketch {sketch}")))?;
@@ -59,7 +59,20 @@ pub(super) fn eval(doc: &Document, vals: &BTreeMap<String, Value>, f: &Feature,
if st.bodies.is_empty() {
return Err(DocError::Invalid("there is no body to emboss".into()));
}
apply_op(doc, st, f, tools, if *deboss { Operation::Cut } else { Operation::Join }, &crate::plain(targets))
// #10940: an emboss or deboss whose tool lies clear of the body (a sketch on the far
// side of the material, a depth that stops short) used to report success and change
// nothing. Say so: the body is compared before and after, as the command's reply does.
let before: Vec<Body> = st.bodies.iter().map(|b| b.body.clone()).collect();
apply_op(doc, st, f, tools, if *deboss { Operation::Cut } else { Operation::Join }, &crate::plain(targets))?;
let unchanged = st.bodies.len() == before.len() && st.bodies.iter().zip(&before).all(|(b, old)| old.same(&b.body));
if unchanged {
let what = if *deboss { "deboss" } else { "emboss" };
append_warning(
warning,
format!("the {what} changed nothing; check where its profile lies, which side of the face the sketch is on, and the depth"),
);
}
Ok(())
}
FeatureKind::Rib { .. } => {
let tools = rib_tools(vals, st, f, None)?;
@@ -2668,3 +2668,39 @@ fn align_axes_are_world_axes_on_a_placed_component() {
assert!(near(after.min.y, before.min.y + 20.0) && near(after.max.y, before.max.y + 20.0), "y: {after:?}");
assert!(near(after.min.z, before.min.z) && near(after.max.z, before.max.z), "z: {after:?}");
}
/// #10940: an Emboss or Deboss whose tool misses the body was recorded as a success that changed
/// nothing, with no warning. It now says that it changed nothing; one that works says nothing.
#[test]
fn an_emboss_that_changes_nothing_says_so() {
let mut s = Session::default();
run(&mut s, "sheet.manage_rules", json!({"name": "T1", "thickness": "0.8 mm", "k_factor": "0.5", "bend_radius": "0.8 mm", "active": true}));
run(&mut s, "sketch.create", json!({"plane": "XY", "name": "Base"}));
run(&mut s, "sketch.rectangle.two_point", json!({"p0": [0, 0], "p1": [60, 40]}));
run(&mut s, "sketch.finish", json!({}));
run(&mut s, "sheet.flange", json!({"sketch": "Base"}));
let before = volume(&mut s);
// A sketch 5 mm below the sheet: a deboss goes down, away from the sheet, and misses it.
run(&mut s, "sketch.create", json!({"plane": {"origin": [0, 0, -5], "x_dir": [1, 0, 0], "y_dir": [0, 1, 0]}, "name": "Logo"}));
run(&mut s, "sketch.rectangle.two_point", json!({"p0": [10, 10], "p1": [20, 20]}));
run(&mut s, "sketch.finish", json!({}));
let reply = run(&mut s, "solid.emboss", json!({"sketch": "Logo", "depth": 0.6, "mode": "deboss"}));
let warning = reply["warning"].as_str().unwrap_or_default();
assert!(warning.contains("deboss changed nothing"), "{reply}");
assert!(reply["changed_bodies"].as_array().is_some_and(Vec::is_empty), "{reply}");
assert!(rel(volume(&mut s), before) < 1e-9);
}
#[test]
fn an_emboss_that_works_has_no_warning() {
let mut s = Session::default();
run(&mut s, "solid.box", json!({"length": 40, "width": 30, "height": 10}));
run(&mut s, "sketch.create", json!({"plane": {"face": [20, 15, 10]}, "name": "Logo"}));
run(&mut s, "sketch.rectangle.two_point", json!({"p0": [5, 5], "p1": [15, 15]}));
run(&mut s, "sketch.finish", json!({}));
for mode in ["emboss", "deboss"] {
let reply = run(&mut s, "solid.emboss", json!({"sketch": "Logo", "depth": 2, "mode": mode}));
assert!(reply["warning"].is_null(), "{mode}: {reply}");
run(&mut s, "edit.undo", json!({}));
}
}