merge research/multi-solid: a Part holds one Solid or several named bodies; a cut that splits a body gives its pieces
On top of the merge: the bindings it touched (cut_rsolid on_split, make_part_rpart body/bodies) take the typed signature vocabulary; a kind = "part" notebook's implicit Part is made of all its open bodies (named by their variables, the pieces of a split cut <name>_1..n) and is recorded in the definition (one result node, so its content hash is stable across cache hits); product values are walked through their own children, not as plain dataclasses; the skill says how bodies and the implicit Part work; the editor marks every body of the implicit Part as the product. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -38,6 +38,12 @@ SCAD_SIGNATURE_NAME(DirectionOrNone, scad::pybind::DirectionTag::name + kOrNone)
|
||||
SCAD_SIGNATURE_NAME(Directions, const_name("dict[str, ") + scad::pybind::DirectionTag::name + const_name("] | None"));
|
||||
SCAD_SIGNATURE_NAME(Weights, const_name("dict[str, float | Expr] | None"));
|
||||
SCAD_SIGNATURE_NAME(Solid, type_name<scad::Solid>());
|
||||
// make_part_rpart: one Solid, or the pieces of a split cut (each a body), or several named bodies.
|
||||
SCAD_SIGNATURE_NAME(SolidOrPieces, type_name<scad::Solid>() + kOr + const_name("collections.abc.Sequence[") +
|
||||
type_name<scad::Solid>() + const_name("] | None"));
|
||||
SCAD_SIGNATURE_NAME(Bodies, const_name("dict[str, ") + type_name<scad::Solid>() + kOr +
|
||||
const_name("collections.abc.Sequence[") + type_name<scad::Solid>() +
|
||||
const_name("]] | None"));
|
||||
SCAD_SIGNATURE_NAME(Face, type_name<scad::Face>());
|
||||
SCAD_SIGNATURE_NAME(Edge, type_name<scad::Edge>());
|
||||
SCAD_SIGNATURE_NAME(Vertex, type_name<scad::Vertex>());
|
||||
@@ -69,6 +75,8 @@ using DirectionOrNoneArg = AnyOf<names::DirectionOrNone>;
|
||||
using DirectionsArg = AnyOf<names::Directions>;
|
||||
using WeightsArg = AnyOf<names::Weights>;
|
||||
using SolidArg = AnyOf<names::Solid>;
|
||||
using SolidOrPiecesArg = AnyOf<names::SolidOrPieces>;
|
||||
using BodiesArg = AnyOf<names::Bodies>;
|
||||
using FaceArg = AnyOf<names::Face>;
|
||||
using EdgeArg = AnyOf<names::Edge>;
|
||||
using VertexArg = AnyOf<names::Vertex>;
|
||||
@@ -145,14 +153,27 @@ void bind_structure(py::module_& m) {
|
||||
|
||||
m.def(
|
||||
"make_part_rpart",
|
||||
[](const TextArg& part_id, const SolidArg& body, const NameArg& name) {
|
||||
[](const TextArg& part_id, const SolidOrPiecesArg& body, const NameArg& name, const BodiesArg& 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));
|
||||
if (is_pieces(body) && py::len(body) > 1) { // a split cut: its pieces are bodies body_1 .. body_n
|
||||
std::vector<sp::Body> pieces;
|
||||
add_bodies(pieces, sp::kDefaultBodyId, body);
|
||||
return sp::make_part_rpart(text(part_id, "part_id"), pieces, optional_name(name));
|
||||
}
|
||||
if (is_pieces(body))
|
||||
return sp::make_part_rpart(text(part_id, "part_id"),
|
||||
typed<Solid>(py::reinterpret_borrow<py::object>(body.value[py::int_(0)]), "body"),
|
||||
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 PartArg& part, const MaterialArg& material) {
|
||||
|
||||
Reference in New Issue
Block a user