feat(product): multi-body parts: a Part holds one Solid or several named bodies

Spike of design-docs/multi-solid-design.md. make_part_rpart(bodies={id: solid})
keeps several solids apart in one Part (not an assembly): Body values with
stable ids, Part.bodies / get_body / body_ids; Part.body raises on a multi-body
part instead of returning one body. Recorded and replayed, pickled for the cell
cache, previewed as one node per body (node/<part>/body:<id>), packaged with a
BRep and topology snapshot per body (solid_cache.bodies; one-body manifests are
byte-identical), drawn as solid child nodes in the package scene, exported to
STEP as one product holding every solid, flattened into assemblies, and weighed
per body by the new measure_part_mass_rmassreport.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
NiJingzhe
2026-11-04 03:57:27 +08:00
parent 093ef71e53
commit b607c85248
41 changed files with 1162 additions and 99 deletions
+7 -3
View File
@@ -79,14 +79,18 @@ void bind_structure(py::module_& m) {
m.def(
"make_part_rpart",
[](const py::object& part_id, const py::object& body, const py::object& name) {
[](const py::object& part_id, const py::object& body, const py::object& name, const py::object& bodies) {
return guard_operation("make_part_rpart", [&] {
if (body.is_none() == bodies.is_none())
throw scad::TypeError("give exactly one of body (a Solid) or bodies (several named solids)");
if (!bodies.is_none())
return sp::make_part_rpart(text(part_id, "part_id"), body_list(bodies), optional_name(name));
return sp::make_part_rpart(text(part_id, "part_id"), typed<Solid>(body, "body must be a Solid"),
optional_name(name));
});
},
py::arg("part_id"), py::arg("body"), py::arg("name") = py::none(),
"Wrap exactly one Solid as a semantic single-body Part.");
py::arg("part_id"), py::arg("body") = py::none(), py::arg("name") = py::none(), py::arg("bodies") = py::none(),
"Wrap one Solid (body) or several named solids (bodies) as a semantic Part.");
m.def(
"assign_material_rpart",
[](const py::object& part, const py::object& material) {