Hi Zbyněk,
Here is a version that does not modify the Assembly.obj - only the locations.
import cadquery as cq
from typing import Union, Literal, Optional
from cadquery.occ_impl.geom import VectorLike
def mirrorassy(
assy: cq.Assembly,
plane: Union[Literal["XY", "YX", "XZ", "ZX", "YZ", "ZY"], VectorLike] = "XY",
point: VectorLike = (0, 0, 0),
loc: Optional[cq.Location] = None,
):
loc = assy.loc * loc if loc else assy.loc
if assy.obj:
if isinstance(assy.obj, cq.Shape):
obj = assy.obj
else:
obj = cq.Compound.makeCompound(
s for s in assy.obj.vals() if isinstance(s, cq.Shape)
)
c0 = obj.Center()
obj = obj.moved(loc)
obj = obj.mirror(plane, point)
assy.loc = cq.Location(obj.Center() - c0)
else:
assy.loc = cq.Location()
for ch in assy.children:
mirrorassy(ch, plane, point, loc)
Note that it is not optimal. Better to cache compounds as in the toCAF method. Another idea is to cache compounds on the Assembly itself. Then if exported to say both STEP and glTF (or mirrored then exported) the compounds can be reused.