diff --git a/src/simplecadapi/_glue/session.py b/src/simplecadapi/_glue/session.py index 7b0fa38b..7d5cd9d3 100644 --- a/src/simplecadapi/_glue/session.py +++ b/src/simplecadapi/_glue/session.py @@ -54,8 +54,7 @@ _PRODUCT_KINDS = frozenset({"Part", "Assembly", "Component", "Connector"}) def _children(item: Any) -> Iterable[Any]: kind = type(item).__name__ if kind == "Part": - for body in item.bodies: # one Solid, or every body of a multi-body part - yield body.solid + yield item.body yield from item.connectors if item.material is not None: yield item.material diff --git a/src/simplecadapi/_glue/values.py b/src/simplecadapi/_glue/values.py index 010d6f95..8b027c36 100644 --- a/src/simplecadapi/_glue/values.py +++ b/src/simplecadapi/_glue/values.py @@ -95,21 +95,18 @@ def _token_for(key: str, item: Any) -> str: def _plain_body(part: Any) -> bool: - """A one-body Part whose body is just its Solid: no name, colour or opacity, and the default id.""" + """A Part whose body is just its Solid: no name, colour or opacity, and the default id.""" - if part.multi_body: - return False body = part.bodies[0] return body.body_id == "body" and body.name is None and body.color is None and body.opacity is None -# Constructor arguments that are not read back by the attribute of the same name. A Part holds one ``body`` or -# several ``bodies``, and is rebuilt from exactly one of them (``Part.body`` raises for a multi-body Part). A one-body -# Part whose body carries a name or an appearance is rebuilt from its ``Body`` so they survive. +# Constructor arguments that are not read back by the attribute of the same name. A Part holds exactly one ``body`` +# (a Solid); a body that carries a name or an appearance is rebuilt from its ``Body`` (which ``Part(body=...)`` also +# takes) so they survive. _ARGUMENTS: Dict[str, Dict[str, Any]] = { "Part": { - "body": lambda value: value.body if _plain_body(value) else None, - "bodies": lambda value: None if _plain_body(value) else value.bodies, + "body": lambda value: value.body if _plain_body(value) else value.bodies[0], }, } diff --git a/src/simplecadapi/recording/serializer.py b/src/simplecadapi/recording/serializer.py index b29e6adb..79979014 100644 --- a/src/simplecadapi/recording/serializer.py +++ b/src/simplecadapi/recording/serializer.py @@ -31,7 +31,6 @@ from ..errors import raise_harness_error from simplecadapi._cpp import ( AnyShape, Assembly, - Body, Compound, Connector, ConnectorRef, @@ -3449,23 +3448,13 @@ def _execute_graph( ctx.require_params(node.node_id, op_name, params, ("part_id",)) body_outputs = _feature_input_shapes(ctx, graph, outputs, node, params) rows = params.get("bodies") - if body_outputs and isinstance(rows, list) and len(rows) > 1: - # a multi-body part: one recorded input per body, in the order of the rows - if len(body_outputs) != len(rows): - raise ValueError( - f"make_part_rpart node {node.node_id}: {len(rows)} bodies recorded, " - f"{len(body_outputs)} inputs resolved" - ) - result = ops.make_part_rpart( - str(params["part_id"]), - name=cast(Optional[str], params.get("name")), - bodies=[ - Body(str(row["body_id"]), cast(Solid, shape), row.get("name")) - for row, shape in zip(rows, body_outputs) - ], + if isinstance(rows, list) and len(rows) > 1: + # a model recorded while a Part could hold several solids (SDK 2.2.8 development builds) + raise ValueError( + f"make_part_rpart node {node.node_id}: it recorded {len(rows)} solids for one Part; " + "a Part holds exactly one solid. Make one Part per solid and put them in an Assembly" ) - _store_outputs(node, result) - elif body_outputs: + if body_outputs: result = ops.make_part_rpart( str(params["part_id"]), cast(Solid, body_outputs[0]),