diff --git a/crates/engine/src/cmd/sketch_modify.rs b/crates/engine/src/cmd/sketch_modify.rs index 846dfddc5..77e7a6a72 100644 --- a/crates/engine/src/cmd/sketch_modify.rs +++ b/crates/engine/src/cmd/sketch_modify.rs @@ -608,6 +608,10 @@ fn break_cmd(s: &mut Session, p: &Value) -> Result { doc.prune_model_params(); return Ok(r["curves"].as_array().map(|a| a.iter().filter_map(|x| x.as_str().map(str::to_string)).collect()).unwrap_or_default()); } + // Its new ends would follow the source curves as trim's and extend's would: a broken + // offset arc came out in three pieces that went the long way round, and the solve + // moved curves the break never touched. + refuse_offset_ends(sk, ci, "break", cmd)?; let sh = sk.shape(ci).ok_or_else(|| bad(cmd, "curve"))?; let (ts, cutters): (Vec, Vec>) = if let Some(list) = &points { let mut v: Vec = list.iter().map(|q| sh.param(sh.project(*q))).collect(); diff --git a/crates/engine/src/cmd/sketch_modify_tests.rs b/crates/engine/src/cmd/sketch_modify_tests.rs index d29cdeda9..aa29a3c9a 100644 --- a/crates/engine/src/cmd/sketch_modify_tests.rs +++ b/crates/engine/src/cmd/sketch_modify_tests.rs @@ -2935,7 +2935,7 @@ fn trim_piece_is_what_a_trim_there_takes_away() { /// refused (the trim used to report success and leave the curve whole). Trimming away a whole /// offset curve still works, and once the association is broken the trim cuts it. #[test] -fn trim_and_extend_refuse_an_offsets_ends_until_its_association_is_broken() { +fn trim_extend_and_break_refuse_an_offsets_ends_until_its_association_is_broken() { let mut s = new_sketch(); run(&mut s, "sketch.rectangle.two_point", json!({"p0": [0, 0], "p1": [40, 30]})); let out = ids(&run(&mut s, "sketch.offset", json!({"curves": ["l1", "l2", "l3", "l4"], "distance": "2 mm", "side": [-5, -5]}))["curves"]); @@ -2946,6 +2946,10 @@ fn trim_and_extend_refuse_an_offsets_ends_until_its_association_is_broken() { assert!(e.contains("offset") && e.contains("break the offset association"), "{e}"); let e = s.execute("sketch.extend", &json!({"curve": "l5", "at": [42, -2]})).unwrap_err().to_string(); assert!(e.contains("offset"), "{e}"); + for params in [json!({"curve": "l5", "at": [30, -2]}), json!({"curve": "l5", "points": [[20, -2]]})] { + let e = s.execute("sketch.break", ¶ms).unwrap_err().to_string(); + assert!(e.contains("offset") && e.contains("break the offset association"), "{params}: {e}"); + } assert_eq!(serde_json::to_value(sketch(&s)).unwrap(), before, "a refused trim changes nothing"); run(&mut s, "sketch.offset.break", json!({"curve": "l5"}));