replicad icon indicating copy to clipboard operation
replicad copied to clipboard

How to get the volume and surface area of a shape?

Open Niels-IO opened this issue 1 year ago • 3 comments

Hi @sgenoud,

Is there any way to get the volume and surface area of a solid shape with Replicad?

Thanks a lot!

Niels-IO avatar Feb 09 '24 14:02 Niels-IO

I would also like to know if this is possible!

kriho avatar Apr 02 '24 01:04 kriho

You could use opencascade directly to do this:

const {  getOC} = replicad;

export function measureVolume(shape) {
  const oc = getOC();
  const properties = new oc.GProp_GProps_1();
  oc.BRepGProp.VolumeProperties_1(
    shape.wrapped,
    properties,
    false,
    false,
  );

  const volume = properties.Mass();
  properties.delete();
  return volume;
}

Not very user friendly. So I added a set of measure helper to do that measureVolume, measureArea and measureLength. Make sure to have the latest version of the studio and use it on shapes!

sgenoud avatar Apr 02 '24 07:04 sgenoud

Thanks a lot for implementing this directly! I tried using measureVolume() but the function never returned (maybe I was too impatient and it just takes minutes).

kriho avatar Apr 04 '24 05:04 kriho