This is a patch to add automatic calculation of zone volumes. The algorithm is found in InputFile.rb on lines 780-786 in the NBDM implementation for SketchNBDM (derivative work). Submitted by CSTB thanks to Werner Keilholz and Bruno Hilaire.
The algorithm is Ostrogradsky's flow-divergence theorem. Iterating over the base surfaces for a zone, the volume is found as follows:
area = base_surface.gross_area
# Volume calculation
h = center.distance_to_plane(base_surface.entity.plane)
# Surface's normal
n = base_surface.entity.normal
cc = base_surface.get_surfaceCenter
v = v + (n.x * cc.x + n.y * cc.y + n.z * cc.z) * area / 3
Further work is required to massage this patch into code that can write the zone volume in Object Info and write to the Zone object.
InputFile.rb (SketchNBDM)