Move, copy & delete bodies
MoveBody(shape, translation, rotation_angle=…, rotation_axis=…, rotation_origin=…) rotates a solid (degrees, about an axis through
rotation_origin) and then translates it.
There is no separate “copy” operation: union a body with moved versions of
itself, as the pegs above do with
BooleanOperation(peg, [shifted, tipped], BooleanOp.UNION).
Delete & keep bodies
A part can hold several separate bodies: features that don’t touch stay separate solids, and a cut can split one body in two. Pick which survive explicitly (Onshape: Delete part):
self.delete_bodies(bodies)(DeleteBodies) removes every body of the part built so far that shares volume with one ofbodies;self.keep_bodies(bodies)(KeepBodies) keeps only those bodies.
bodies is one operation or a list — usually features added to the part
earlier (the value self.extrude(...) returns). A selector does not have to be
in the part: any solid sharing volume with a body selects it, which is how the
example below picks one half of the sawn ring. Bodies that a later feature
merged are one body: deleting it deletes the whole merged solid. Later
operations still apply on top of what is left.
A selector that touches no body, or a delete that would leave the part empty, is reported as an error.