Persistent naming for sheet metal: base panel edges are named after the base sketch line they lie on, flange edges after their flange (F<feature>.<k>) and side (far / side0 / side1, top or bottom face); flanges and hems store edge names and pick by name first (a name that is gone keeps the point with a warning)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AS5Tn3xieewUSg3uxrMVdL
This commit is contained in:
1 parent
c6cb3dd1e6
commit
05b38e0f5f
5 files changed
+185
-6
No files matched your search
@@ -263,6 +263,10 @@ pub(super) fn add_feature(s: &mut Session, p: &Value, kind: FeatureKind) -> Resu
|
||||
let st = s.model.state();
|
||||
(solvecraft_doc::edge_refs(&st, body, edges), solvecraft_doc::edge_names_for(&st, body, edges))
|
||||
}
|
||||
// Sheet metal edges are named by the sheet model.
|
||||
FeatureKind::SheetFlange { edges, .. } | FeatureKind::SheetHem { edges, .. } => {
|
||||
(Vec::new(), solvecraft_doc::sheet::sheet_edge_names(&s.model.state(), edges))
|
||||
}
|
||||
_ => (Vec::new(), Vec::new()),
|
||||
};
|
||||
let face_names = {
|
||||
|
||||
@@ -298,3 +298,32 @@ fn fold_through_cut_outs() {
|
||||
let e = c.execute("SheetMetalFoldCmd", &json!({"sketch": "FoldLine", "curve": "fl"})).map(|_| ()).unwrap_err().to_string();
|
||||
assert!(e.contains("not supported yet"), "{e}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn flange_edges_are_named_and_follow_the_base_sketch() {
|
||||
let mut s = Session::default();
|
||||
run(&mut s, "SketchCreate", json!({"plane": "XY", "name": "Base"}));
|
||||
run(&mut s, "ShapeRectangleTwoPoint", json!({"p0": [0, 0], "p1": [100, 60]}));
|
||||
let d = run(&mut s, "SketchDimension", json!({"entities": ["l1"], "value": 100}));
|
||||
run(&mut s, "SketchStop", json!({}));
|
||||
run(&mut s, "FusionSheetMetalFlangeCommand", json!({"sketch": "Base"}));
|
||||
run(&mut s, "FusionSheetMetalFlangeCommand", json!({"edges": [[100, 30, 2.5]], "height": 20, "name": "Side"}));
|
||||
let side = s.doc.find_feature("Side").cloned().unwrap();
|
||||
assert_eq!(side.edge_names, vec!["base:l2:top".to_string()]);
|
||||
let v0 = volume(&mut s);
|
||||
// Narrower base: the flange stays on the right edge (now at x = 40).
|
||||
let name = d["param"].as_str().or_else(|| d["name"].as_str()).map(str::to_string).unwrap_or_else(|| "d1".into());
|
||||
run(&mut s, "ChangeParameterCommand", json!({"name": name, "expression": "40"}));
|
||||
let b = run(&mut s, "MeasureCommand", json!({}))["bodies"][0]["bbox"].clone();
|
||||
let w = b["max"][0].as_f64().unwrap_or(0.0) - b["min"][0].as_f64().unwrap_or(0.0);
|
||||
assert!((w - 40.0).abs() < 1e-3 && b["max"][2].as_f64().unwrap_or(0.0) > 19.0, "{b}");
|
||||
assert!(volume(&mut s) < v0);
|
||||
let id = side.id;
|
||||
assert_eq!(s.model.result(id).and_then(|r| r.warning.clone()), None);
|
||||
// A hem on the flange's far edge is named after the flange.
|
||||
let top = b["max"][2].as_f64().unwrap_or(0.0);
|
||||
let x = b["max"][0].as_f64().unwrap_or(0.0);
|
||||
run(&mut s, "FusionSheetMetalHemFlangeCommand", json!({"edges": [[x, 30, top]], "length": 6, "name": "H"}));
|
||||
let h = s.doc.find_feature("H").cloned().unwrap();
|
||||
assert!(h.edge_names[0].starts_with(&format!("F{id}.0:far")), "{:?}", h.edge_names);
|
||||
}
|
||||
Reference in new issue
Block a user