* claim: #2987 * Flange on a plain solid says how to start sheet metal (#2987) Flange, Flat Pattern, and Export DXF on a design with no sheet metal body now say how to make one: Flange > Base, or Convert to Sheet Metal on a plate's large flat face. An edge flange checks for a sheet metal body before it adds a feature. The message is in the catalogs, and engine messages that match a catalog entry are shown in the interface language. * Dialogs show a refusal without the engine's parameter prefix (#2987) The Flange dialog showed "invalid parameters for `sheet.flange`: " in front of the new guidance. The dialog already names its command, so the red refusal text leaves that prefix out and follows the interface language when the message is in the catalogs. Create Issue still gets the full text.
This commit is contained in:
1 parent
be87303683
commit
a0fd39a7be
8 files changed
+69
-6
No files matched your search
@@ -206,6 +206,9 @@ fn flange(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
if !matches!(position.as_str(), "inside" | "outside" | "middle") {
|
||||
return Err(bad(cmd, "`position` must be inside, outside or middle"));
|
||||
}
|
||||
if s.model.state().sheets.is_empty() {
|
||||
return Err(no_sheet_body(cmd));
|
||||
}
|
||||
let body = str_(p, "body").map(str::to_string);
|
||||
// The corner relief these flanges make, in place of the rule's; null is not given.
|
||||
let corner_relief_shape = match p.get("corner_relief_shape").filter(|v| !v.is_null()) {
|
||||
@@ -451,11 +454,18 @@ fn list_rules(s: &mut Session, _p: &Value) -> Result<Value> {
|
||||
Ok(json!({"rules": rules, "active": active}))
|
||||
}
|
||||
|
||||
fn no_sheet_body(cmd: &str) -> EngineError {
|
||||
bad(
|
||||
cmd,
|
||||
"there is no sheet metal body: start one with Flange > Base, or turn a plate into sheet metal with Convert to Sheet Metal (pick its large flat face)",
|
||||
)
|
||||
}
|
||||
|
||||
fn sheet_of(s: &Session, p: &Value, cmd: &str) -> Result<SheetBody> {
|
||||
let st = s.model.state();
|
||||
match str_(p, "body") {
|
||||
Some(b) => st.sheets.iter().find(|x| x.body == b).cloned().ok_or_else(|| bad(cmd, format!("`{b}` is not a sheet metal body"))),
|
||||
None => st.sheets.last().cloned().ok_or_else(|| bad(cmd, "there is no sheet metal body")),
|
||||
None => st.sheets.last().cloned().ok_or_else(|| no_sheet_body(cmd)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -816,7 +826,7 @@ fn export_dxf(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
let sheets = &s.model.state().sheets;
|
||||
if sheets.is_empty() {
|
||||
return Err(bad(cmd, "there is no sheet metal body"));
|
||||
return Err(no_sheet_body(cmd));
|
||||
}
|
||||
// Every file is made before the first is written.
|
||||
let texts = sheets
|
||||
|
||||
@@ -37,6 +37,27 @@ fn rectangle_tool(s: &mut Session, name: &str, p0: [f64; 2], p1: [f64; 2]) {
|
||||
run(s, "sketch.finish", json!({}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn plain_solid_sheet_operations_explain_how_to_start_sheet_metal() {
|
||||
let mut s = Session::default();
|
||||
run(&mut s, "solid.box", json!({"length": 100, "width": 60, "height": 2.5}));
|
||||
let before = s.doc.to_json();
|
||||
for (command, params) in [
|
||||
("sheet.flange", json!({"type": "edge", "edges": [[50, 0, 2.5]], "height": 15})),
|
||||
("sheet.flat_pattern", json!({})),
|
||||
("sheet.export_dxf", json!({"per_body": true})),
|
||||
] {
|
||||
let error = s.execute(command, ¶ms).unwrap_err();
|
||||
let crate::EngineError::BadParams { cmd, msg } = error else { panic!("{error}") };
|
||||
assert_eq!(cmd, command);
|
||||
assert_eq!(
|
||||
msg,
|
||||
"there is no sheet metal body: start one with Flange > Base, or turn a plate into sheet metal with Convert to Sheet Metal (pick its large flat face)"
|
||||
);
|
||||
assert_eq!(s.doc.to_json(), before);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn side_edge_flanges_across_a_bend_keep_their_relief_through_rebuild_and_reopen() {
|
||||
use solidcraft_geom::Vec3;
|
||||
|
||||
Reference in new issue
Block a user