Edit Offset Plane: keep a face base, refuse a plane on itself (#3567) (#3889)

* claim: #3567

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019Yz6dHZiXcgTgrxjVNC6hx

* Edit Offset Plane: keep a face base, refuse a plane on itself (#3567)

Reopening an Offset Plane built on a face looked the face up at the
plane's origin, which can lie off the face, so the Plane input came up
empty. Look it up at the point picked on the face. A redefine that
builds a feature on itself is refused with a plain message instead of
failing with "plane offsets nested too deeply".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019Yz6dHZiXcgTgrxjVNC6hx

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Loohi
2026-10-22 18:30:02 +00:00
committed by GitHub
parent 46f80b769f
commit aaa110218b
5 changed files with 60 additions and 1 deletions
+5
View File
@@ -1253,6 +1253,11 @@ fn redefine(s: &mut Session, p: &Value) -> Result<Value> {
if std::mem::discriminant(&new.kind) != std::mem::discriminant(&old.kind) && !(boundary(&new.kind) && boundary(&old.kind)) {
return Err(bad(cmd, format!("{} is not a {} feature", old.name, cid)));
}
// The trial still holds the old feature, so a plane offset from its own name was made there,
// and once swapped in it would be built on itself (#3567).
if new.kind.names_feature(&old.name) {
return Err(bad(cmd, format!("{} can't be built on itself: pick another plane or face", old.name)));
}
// Optional inputs can move other inputs' positions (e.g. Distance 2 goes before Taper).
// Keep each existing model parameter attached to its semantic input, rather than its
// old index. Constructor-assigned names for new inputs cannot reuse the old dimensions.
@@ -80,3 +80,22 @@ fn offset_plane_rejects_bad_face_picks_without_panicking() {
assert_eq!(s.doc.features.len(), features, "{base}");
}
}
/// #3567: an Offset Plane redefined with itself as its base was accepted while the old plane
/// stood beside the new one, and then failed with "plane offsets nested too deeply". It is
/// refused with a plain message, and the plane is left as it was.
#[test]
fn offset_plane_redefined_on_itself_is_refused() {
let mut s = Session::default();
run(&mut s, "solid.box", json!({"length": 40, "width": 30, "height": 20, "corner": [10, 0, 0]}));
run(&mut s, "construct.plane.offset", json!({"base": {"face": [30, 0, 10]}, "offset": 10, "name": "Side"}));
assert!((plane(&s, "Side").origin.y + 10.0).abs() < 1e-9, "{:?}", plane(&s, "Side"));
let saved = s.doc.to_json();
let redefine = |base: Value| json!({"feature": "Side", "command": "construct.plane.offset", "params": {"base": base, "offset": "7"}});
let e = s.execute("timeline.redefine", &redefine(json!("Side"))).unwrap_err().to_string();
assert!(e.contains("can't be built on itself"), "{e}");
assert_eq!(s.doc.to_json(), saved);
// The same edit on the face it was built on works.
run(&mut s, "timeline.redefine", redefine(json!({"face": [30, 0, 10]})));
assert!((plane(&s, "Side").origin.y + 7.0).abs() < 1e-9, "{:?}", plane(&s, "Side"));
}