Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Niels-IO opened this issue Feb 9, 2024 · 3 comments
Open

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

Niels-IO opened this issue Feb 9, 2024 · 3 comments

Comments

@Niels-IO
Copy link
Contributor

Niels-IO commented Feb 9, 2024

Hi @sgenoud,

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

Thanks a lot!

@kriho
Copy link

kriho commented Apr 2, 2024

I would also like to know if this is possible!

@sgenoud
Copy link
Owner

sgenoud commented Apr 2, 2024

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!

@kriho
Copy link

kriho commented Apr 4, 2024

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants