How to get Volume of a tet element after mesh?

I want to assign different sections to different elements after meshing. So, I want to have sections of two types assigned according to some pre-described volume fraction for both of them. I am using tet mesh in a cube then I can create two sets by element label, but unable to decide how many tet elements I should assign to section-1 and how many to assign section-2 as I have a constraint that the volume of one type of section should not exceed the pre-described volume fraction.

If I can get the volume of tet elements, then I can run a loop over all the element labels (randomly picked) and storing the sum of all volume of the visited tet elements, then break the loop as soon as the sum of volume reaches or exceeds the volume required for that section.

If there is an elegant way of achieving this, then tell me that as well.