Insert Design on the ASSEMBLE panel and in the File menu (#1240) (#1405)

component.insert_design (a saved part as a linked component) had no button, so an
assembly of separately saved parts looked impossible. It is now on the ASSEMBLE panel
of every tab and in the File menu; it asks for the file, and a STEP or mesh file picked
there is inserted as Insert STEP or Insert Mesh would.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bherbruckandClaude Opus 5.5 authored and GitHub committed 2026-10-15 10:28:02 -04:00
1 parent 4823c293dd
commit b156b5e09c
5 files changed
+64 -3

No files matched your search

+33
View File
@@ -11,6 +11,7 @@ const ASSEMBLE: &[&str] = &[
"component.create",
"joint.create",
"joint.as_built",
"component.insert_design",
"joint.origin",
"joint.rigid_group",
"joint.drive",
@@ -212,4 +213,36 @@ mod tests {
assert!(ids("PLASTIC", "MODIFY").contains(&"solid.shell"));
assert!(panels("PLASTIC").is_some_and(|p| p.first() == Some(&"SETUP")));
}
/// #1240: a saved part reaches an assembly from the ASSEMBLE panel (and the File menu) as a
/// linked component, and a STEP file picked there is inserted as Insert STEP would.
#[test]
fn insert_design_is_on_the_assemble_panel_and_inserts_a_saved_part() {
use serde_json::json;
for tab in ["SOLID", "SHEET METAL", "PLASTIC"] {
assert!(ids(tab, "ASSEMBLE").contains(&"component.insert_design"), "{tab}");
}
assert!(!ids("SOLID", "ASSEMBLE")[..3].contains(&"component.insert_design"), "Component, Joint and As-built Joint keep the big buttons");
let mut h = crate::scenario::Harness::new();
let part = h.dir.join("part1.solidcraft");
let mut s = solidcraft_engine::Session::default();
s.execute("solid.box", &json!({"length": 10, "width": 20, "height": 30})).unwrap();
s.execute("file.save", &json!({"path": part})).unwrap();
s.execute("file.export", &json!({"path": h.dir.join("part2.step")})).unwrap();
h.step(&json!({"choose_file": "part1.solidcraft"})).unwrap();
h.step(&json!({"start": "component.insert_design"})).unwrap();
h.frames(3);
let links = h.app.session.execute("component.links", &json!({})).unwrap();
assert_eq!(links["links"][0]["name"], "part1", "{links}");
assert_eq!(h.app.session.world_state().bodies.len(), 1);
h.step(&json!({"choose_file": "part2.step"})).unwrap();
h.step(&json!({"start": "component.insert_design"})).unwrap();
for _ in 0..600 {
if h.app.session.world_state().bodies.len() == 2 {
break;
}
h.frames(1);
}
assert_eq!(h.app.session.world_state().bodies.len(), 2, "the STEP file's body is inserted");
}
}