A lip kept its rim face as a plain point, so it got no persistent face
name. When a parameter made the box taller, the point stayed below the new
rim and the lip failed ("the plastic feature's placement is no longer on
its body face"). The face is now a face pick, as a boss's is, and the lip
names its body like the other placed plastic features. Both are saved as
the same [x, y, z], so files don't change.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1487,7 +1487,7 @@ pub enum FeatureKind {
|
||||
},
|
||||
/// Plastic lip (raised band) or groove (recess) along the rim face picked at `face`.
|
||||
Lip {
|
||||
face: Position,
|
||||
face: FacePick,
|
||||
#[walk(length = "Width")]
|
||||
width: Expr,
|
||||
#[walk(length = "Height")]
|
||||
|
||||
@@ -67,6 +67,7 @@ impl FeatureKind {
|
||||
| FeatureKind::ReplaceFace { body, .. }
|
||||
| FeatureKind::SurfaceOffset { body, .. }
|
||||
| FeatureKind::Boss { body, .. }
|
||||
| FeatureKind::Lip { body, .. }
|
||||
| FeatureKind::SnapFit { body, .. }
|
||||
| FeatureKind::Rest { body, .. } => body.as_deref(),
|
||||
FeatureKind::SheetConvert { body, .. } | FeatureKind::SurfaceRuled { body, .. } => Some(body.as_ref()),
|
||||
|
||||
@@ -150,6 +150,7 @@ boss
|
||||
face points: [0, 0, 0]
|
||||
lip
|
||||
moves: face[0], face[1], face[2]
|
||||
face points: [0, 0, 0]
|
||||
snap_fit
|
||||
moves: direction[0], direction[2], hook[0], hook[1], position[0], position[1], position[2]
|
||||
face points: [0, 0, 0]
|
||||
|
||||
@@ -6,7 +6,7 @@ use solidcraft_doc::BodyName;
|
||||
use solidcraft_doc::FeatureKind;
|
||||
use solidcraft_doc::expr::Kind;
|
||||
use solidcraft_doc::plastic::PlasticRule;
|
||||
use solidcraft_doc::{Dir, FacePick, Position};
|
||||
use solidcraft_doc::{Dir, FacePick};
|
||||
use solidcraft_geom::prelude::*;
|
||||
|
||||
use super::CommandSpec;
|
||||
@@ -237,7 +237,7 @@ fn lip(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
Some(o) => return Err(bad(cmd, format!("unknown side `{o}` (inside or outside)"))),
|
||||
};
|
||||
let kind = FeatureKind::Lip {
|
||||
face: Position(face),
|
||||
face: FacePick(face),
|
||||
width: required(s, p, "width", Kind::Length, cmd)?,
|
||||
height: required(s, p, "height", Kind::Length, cmd)?,
|
||||
groove,
|
||||
@@ -343,6 +343,27 @@ mod tests {
|
||||
assert!(g.execute("plastic.lip", &json!({"face": [40, 25, 0], "width": 1, "height": 2})).is_err(), "a face without an inner edge");
|
||||
}
|
||||
|
||||
/// A lip follows its rim face when a parameter moves it (#11209): it was kept by a point
|
||||
/// only, so a taller box left the point below the rim and the lip failed.
|
||||
#[test]
|
||||
fn a_lip_and_a_groove_follow_their_rim_when_a_parameter_moves_it() {
|
||||
for groove in [false, true] {
|
||||
let mut s = Session::default();
|
||||
run(&mut s, "parameters.add", json!({"name": "h", "expression": "30 mm"}));
|
||||
run(&mut s, "solid.box", json!({"length": 80, "width": 50, "height": "h"}));
|
||||
run(&mut s, "solid.shell", json!({"faces": [[40, 25, 30]], "thickness": 2}));
|
||||
let kind = if groove { "groove" } else { "lip" };
|
||||
run(&mut s, "plastic.lip", json!({"face": [1, 25, 30], "width": 1, "height": 2, "type": kind}));
|
||||
let before = volume(&mut s);
|
||||
run(&mut s, "parameters.change", json!({"name": "h", "expression": "40 mm"}));
|
||||
let failing: Vec<String> = s.model.results.iter().filter_map(|r| r.error.clone()).collect();
|
||||
assert!(failing.is_empty(), "{kind}: {failing:?}");
|
||||
// 10 mm more of the shell's walls: (80·50 − 76·46) · 10, and the same band on top.
|
||||
let walls = (80.0 * 50.0 - 76.0 * 46.0) * 10.0;
|
||||
assert!(rel(volume(&mut s) - before, walls) < 1e-6, "{kind}: {} {walls}", volume(&mut s) - before);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn round_rim_lips_and_grooves_keep_curved_walls() {
|
||||
for (obround, tilted) in [(false, false), (true, false), (true, true)] {
|
||||
|
||||
Reference in New Issue
Block a user