fix(extrude): a sketch on an inserted part joins and cuts it, through all too (#5115)

A STEP file inserted into a new design sits in its own component under the
empty root, and a sketch on its face must join that part going out and cut it
going in rather than make a separate body beside it. With a distance, main
already resolves this; Through All with no distance gave `auto` no reach to
probe, so it fell back to New Body and cut nothing. Through All now reaches
past every body in its direction, and `auto` reads it as a cut (#1234).

Co-authored-by: Steven <steven2021067613@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
sthifen
2026-10-23 13:43:14 +00:00
committed by GitHub
parent 96679f3e2b
commit 8b68eb7eac
2 changed files with 122 additions and 1 deletions
+21 -1
View File
@@ -208,7 +208,13 @@ fn auto_operation_in(s: &Session, p: &Value, world_faces: bool) -> Option<&'stat
} else {
extrude_base(s, p)?
};
let d = if grouped.is_some() && p.get("to").is_some() { (p.get("to").and_then(vec3)? - base).dot(n) } else { extrude_reach(s, p)? };
let d = if grouped.is_some() && p.get("to").is_some() {
(p.get("to").and_then(vec3)? - base).dot(n)
} else if let Some(d) = extrude_reach(s, p) {
d
} else {
through_all_reach(&st, p, base)?
};
if st.bodies.is_empty() || !d.is_finite() {
return Some("new");
}
@@ -245,6 +251,20 @@ fn auto_operation_in(s: &Session, p: &Value, world_faces: bool) -> Option<&'stat
}
}
/// How far a Through All extrude with no distance reaches from `base`, signed by its
/// direction: past every body of the model. Without it `auto` could not tell a cut through
/// a part from an addition and made a separate body.
fn through_all_reach(st: &solidcraft_doc::ModelState, p: &Value, base: Vec3) -> Option<f64> {
let through_all = bool_(p, "through_all").unwrap_or(false) || str_(p, "extent").is_some_and(|e| e.eq_ignore_ascii_case("through_all"));
if !through_all {
return None;
}
let reach =
st.bodies.iter().map(|b| b.mesh().bounds()).map(|bb| bb.center().dist(base) + bb.diagonal()).filter(|r| r.is_finite()).fold(1.0, f64::max);
let dir = str_(p, "direction").map(str::to_ascii_lowercase);
Some(if matches!(dir.as_deref(), Some("negative" | "reverse" | "flip")) { -reach } else { reach })
}
pub(super) fn operation(p: &Value, cmd: &str) -> Result<Operation> {
match str_(p, "operation") {
None => Ok(Operation::NewBody),