When computing the volume of a compound that itself contains an empty compound, a StopIteration exception is raised.
However the volume of the inner empty compound itself is computed to be 0.0 as expected.
To Reproduce
from cadquery.occ_impl.shapes import compound
empty_compound = compound()
empty_volume = empty_compound.Volume() # returns 0.0
print("empty compound volume:", empty_volume)
bad = compound(empty_compound) # top-level non-empty, first child empty
volume = bad.Volume() # raises StopIteration
print("bad compound volume:", volume) # this line is never reached
Output:
empty compound volume: 0.0
Traceback (most recent call last):
File "/tmp/cq _vol_test.py", line 9, in <module>
volume = bad.Volume() # raises StopIteration
File "/home/john/src/klu/.venv/lib/python3.14/site-packages/cadquery/occ_impl/shapes.py", line 1118, in Volume
return Shape.computeMass(self, tol)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^
File "/home/john/src/klu/.venv/lib/python3.14/site-packages/cadquery/occ_impl/shapes.py", line 824, in computeMass
calc_function = Shape._mass_calc_function(obj)
File "/home/john/src/klu/.venv/lib/python3.14/site-packages/cadquery/occ_impl/shapes.py", line 804, in _mass_calc_function
child = next(iter(child))
StopIteration
Environment
OS: Arch Linux
Was CadQuery installed using Conda?: No, installed with pip
Version: 2.8.0, Python 3.14.6
When computing the volume of a
compoundthat itself contains an emptycompound, aStopIterationexception is raised.However the volume of the inner empty
compounditself is computed to be0.0as expected.To Reproduce
Output:
Environment
OS: Arch Linux
Was CadQuery installed using Conda?: No, installed with pip
Version: 2.8.0, Python 3.14.6