Skip to main content

Module part_mass

Module part_mass 

Source
Expand description

Mass properties of a part: computed from its geometry and the density the PART carries (never per occurrence), and the load-time migration of old occurrence-stored Mass/Material onto the part. MASS PROPERTIES OF A PART — computed from the part’s geometry and the density the PART carries, never typed in and never stored per occurrence.

§One source

Material and density are attributes of the PART definition: the partAttributes record on the part’s own document (see bom.rs), edited in the part’s Properties dialog or the BOM’s part columns. Everything that shows a mass — the BOM row, the Info window, the BOM export, the MCP readers — resolves it here, so they cannot disagree:

  • a solid’s density is its own metadata density when one is set (a multi-material part’s per-body override), else its PART’s Density, else the density of the part’s Material when that names a material this build knows (material_density), else none;
  • a part’s volume is the volume of the solids ONE placement of it produces (every placement is the same rigid copy), from the existing measurement cache (object_info_json), so nothing re-executes the history per frame and a value is simply pending until the runner answers;
  • a part’s mass is Σ volume × density. A part with NO geometry (a purchased or library part with nothing to measure) may carry a stored Mass instead: that is the only time a mass is typed, and it is still a part attribute.

Units: density in g/cm³ (what material tables quote), volume in mm³ (the kernel’s length unit), mass in kg.

§Old documents

A document saved before this rule may hold Mass / Material / Density on its OCCURRENCES (the ACOMP’s bom record, or the occurrenceAttributes key an older batch path wrote). migrate_occurrence_part_attributes lifts them onto the part as the document opens, and says so once.

Structs§

MassReport
One part’s (or one document’s) mass properties.

Enums§

DensitySource
Where a resolved density came from.
MassStatus
What a mass reading is.

Constants§

DENSITY_KEY
The part’s density in g/cm³.
DENSITY_UNIT
MASS_KEY
Computed for a part with geometry; a stored override only without.
MASS_UNIT
MATERIAL_KEY
The part’s material name; resolves a density when no Density is set.
PART_ONLY_KEYS
The part attribute keys that describe the PART’s mass properties. None of them may be stored on an occurrence.
VOLUME_KEY
Derived — computed from geometry, never stored.
VOLUME_UNIT

Functions§

format_derived
The display text of a DERIVED part field (Mass, Volume) with its unit; None for any other field or a non-number.
format_mass_kg
A mass in kg as a reader wants it: kilograms from 1 kg up, grams below.
format_volume_mm3
A volume in mm³ as a reader wants it: cm³ from 1 cm³ up, mm³ below.
material_density
The built-in density (g/cm³) for a material NAME, or None when the name matches nothing this build knows (then the part needs an explicit Density).
migrate_occurrence_part_attributes
Lift part-only attributes (Mass, Material, Density) that an older document stored on its OCCURRENCES onto the PART, in place, before the document is loaded. Returns the notices to show (one per part whose occurrences disagreed or whose part already said otherwise, plus one summary of what moved).
part_density
A part’s density from its attribute record: its Density, else its Material’s built-in density.