Skip to content

Latest commit

 

History

History
77 lines (58 loc) · 2.82 KB

volume.md

File metadata and controls

77 lines (58 loc) · 2.82 KB
title volume
description Read the volume occupied by solid material, excluding holes and cavities.
sourceReview
packageVersion sources
0.0.1-alpha.16
path sha256
packages/core/src/library/runtime.ts
dcee3d2388a9b7b3819bb4897edd894463daa0e5b519e832a3349fac98c3bff8
path sha256 commit
packages/core/src/library/topology.ts
f9f0d048fe30cc80046a25123aa8101ca51e85cdb5b2e66260c6a68f43f84715
67228dd8559d584852df7bfbd47ed89f1d8003e9
sidebar
hidden
true
head
tag content
title
volume — Code3D TypeScript API reference

Read the volume occupied by solid material, excluding holes and cavities.

Example

import {box, group, tube} from '@code3d/core';

const block = box(20, 30, 10);
const pipe = tube(15, 10, 40).originOffset(-60, 0, 0);

// Select .volume to inspect the solid and the space occupied by its material.
const blockVolume = block.volume; // 6000
const pipeVolume = pipe.volume; // 5000 * Math.PI; the bore is excluded.
const enlargedVolume = block.scaled(2).volume; // 48000

export default group([block, pipe]);

Read the volume occupied by solid material, excluding holes and cavities.

Complete example: measurement example.

Signature

solidModel.volume: number;
solidReference.volume: number;

Import the functions and named types from @code3d/core.

Receivers and units

SolidModel and an exposed Solid reference provide readonly volume in cubic model units. It measures material occupancy. Through-holes, bores and enclosed cavities are excluded. The example's block has volume 6000; the tube has volume 5000 * Math.PI, and scaling the block by 2 produces 48000.

Faces, edges, vertices, infinite anchors and groups do not have this property. Summing group-member volumes counts overlapping parts separately. Use union first when measuring the fused occupied region is intended.

Transforms and measurement lifetime

Rotations, origin edits and placement preserve volume. Positive uniform scaled multiplies volume by the cube of the scale factor. An exposed solid reference includes the scale of its selected geometry.

This getter returns an ordinary number computed now. Creating a cut, shell or other new model later does not update an old numeric result. Read the property from the result you intend to measure. Kernel integration uses floating-point arithmetic, so comparisons should allow a suitable tolerance.

Inspection

Select .volume in App to show the solid and its volume label at the volume centroid. The display uses the recorded result and does not create an editable dimension. Use area for total boundary surface and bounds for axis-aligned extents; their product is generally not the material volume.