* Bill of materials types on one occurrence (#3874)
An occurrence can count in the bill of materials as another type than its
component, for that occurrence only: `bom_type` on the occurrence, set with
occurrence.bom_type (one undo step; it changes no geometry, so nothing is
evaluated). An occurrence without it counts as its component, so older
designs need no step; the format change is one pending file
(occurrence-bom-type.rs).
assembly.bom counts each placement by its own type: a purchased placement of
a kit part is one row without the kit's contents, a phantom placement lists
what it holds where it sits, and one component placed as two types gives a
row for each. Paste New keeps the types; Paste Instance counts as the
component. The compact list and the locales (en, de, ja, ko, zh) carry it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Bill of materials rows: material, and mass when asked (#3874)
Every row of assembly.bom (and every part folded into a row) names the
physical materials of its definitions' own bodies, each once, with "; "
between several. An unassigned body's is Default. A subassembly or an
empty component has none of its own.
With mass: true each row also carries mass_g, what one of its parts
weighs as the row stands for it, so the rows of any list add up to the
assembly once:
- at the top level, all it holds;
- in parts only, its own bodies, because what it holds is listed beside
it; but a folded part's row is the kit (all it holds), a purchased part
is all it holds, and an inseparable one all but its purchased parts;
- a reference placement adds nothing, nor does anything inside it.
It is null when nothing in the part has a body, a body can't be
measured or measures a negative volume (inside out, such as an open mesh
facing the origin), or the definitions sharing the row's part number
weigh differently.
Measuring runs the kernel, so it is asked for: the Bill of Materials
window re-runs assembly.bom after every change and doesn't ask (0.2 ms
without mass, 135 ms with it on a bolted bracket). Placements are rigid,
so each definition is weighed once however often it is placed, and each
body is measured once with measure_mass (the same volume as measure,
without the topology counts' tessellation).
A body's material and its density now follow one rule:
Document::body_material (new, beside Document::density) is the material
its mass is worked out with, named as the library or the design spells
it: the assigned one when it is known and has a usable density, else
DEFAULT_MATERIAL (new, beside DEFAULT_DENSITY). Document::density is
that material's density, with the same values as before. So a damaged
file's unknown or broken material reads as Default, as it weighs, and a
hand-edited "steel" reads as Steel. The bill of materials uses both; the
other places that read a body's material or spell "Default"
(component.properties, inspect and others) move to them in a separate
cleanup PR for #4783, which brings the same two functions to main.
Document::body_owners returns each body's owner in order, so the rows
find their bodies in one pass. It no longer repeats the owner rule:
model_body_component, legacy_body_component and body_owners go through
the rule written once, given how to find a feature's component (the
timeline for one body; body_owners still builds its map once). The CSV
columns are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Physical properties: a reference placement adds nothing (#3874)
component.properties and occurrence.properties now leave out a placement
that counts as a reference in the bill of materials (its occurrence's
bom_type, else its component's: a fixture shown for context), and
everything inside it: no body entry, mass, volume, area, centre of mass
or bounding box, and it isn't in placement_count. That is the bill of
materials' rule, so a reference part is in neither the parts list nor
the assembly's mass, and every bill of materials list still adds up to
the assembly's Properties. The placement asked for counts whatever its
type: a reference fixture's own Properties still measure it and what it
holds, as a component's own bill of materials lists what it holds.
Only the totals change. The placements walk that face picking, sketches
on placed faces and the occurrence path lookup use stays complete, so a
reference fixture's faces can still be picked.
The type an occurrence counts as is now written once:
Document::occurrence_bom_types (new, beside BomType) gives each
occurrence's type in their order, looking each component up once. The
bill of materials, occurrence.bom_type's reply and the physical
properties use it, in place of the two copies in the bill of materials.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Bill of materials: one module of typed rows in doc (#3874)
The bill of materials now lives in solidcraft_doc::bom as the typed rows
of a bill of materials view. assembly.bom's JSON and CSV and the Bill of
Materials window present those rows; parts lists, item numbers and
balloons are to read them too.
- list(tree, request) walks the placements below the assembly once. One
rule (classify) decides for each placement whether it is counted in a
row, how what it holds is walked and what its row stands for when
weighed, from the type it counts as, the view and the component's
shape. "An inseparable part's purchased parts are listed beside it" is
written there once, and the mass walk reads it.
- A row carries its identity (RowKey: the rows it is listed under and
its lowest member, a component and the type it counts as), its item,
count, each, the placements it counts by occurrence path, what it
stands for (Holds), its part properties, materials, mass and children.
- Mass is a Mass: not asked, grams, or unknown with the reason (nothing
to weigh, unmeasurable, the definitions differ). Each definition is
weighed once for each kind of row and kept in the Tree. The assembly's
total is weighed from the design the same way, not added up from rows,
so it is known even when a row's definitions weigh differently.
- Bom::row_of(tree, path) finds the row a placement is counted in (a nut
inside a purchased bolt is in the bolt's), or says why there is none:
no such placement, a reference, or no row of its own.
- rows_deep() lists each row followed by its children (1, 1.1, 1.2, 2);
Request::default() is assembly.bom {}; View and Group carry the
commands' words.
What changes, beside that the output is otherwise the same:
- One placement budget (100,000) and one depth limit (64 levels) cover
the whole list. A folded part's contents used to be walked under a
budget of their own, so a design past the limit was listed with
group_children; it is refused now, as it already was without it.
- Kits are compared by what they hold (part, type and count), not as
text: a part without a part number whose id is 12 no longer reads as a
part numbered "#12", nor a part numbered "P×1\nQ" as a P and a Q. Kits
holding the same parts through different definitions (two bolt
definitions, each with its own nut definition of one part number) are
one row, and its children count every bolt's placements, where they
showed the first bolt's definitions only.
- A folded part's row always stands for all it holds. It used to stand
for its own bodies when nothing inside it was listed, which differs
only for a phantom with bodies of its own inside it.
- An inseparable part's row in parts only names the material of what it
stands for (its steel blocks read Steel) where it was blank, and a
subassembly whose parts share one material names it at the top level.
- A damaged file's component placed inside itself is refused at the first
level too, since naming a row's material walks inside it, as weighing
it already did.
- A row's body count saturates, so a compact assembly with more placed
bodies than a count holds (a block placed 2^64 times) is weighed
instead of overflowing.
Materials follow Cameron's rule for a row that stands for an assembly
(C3, 2026-10-23): a part's row lists its own bodies' materials, as before;
a row that weighs what is placed inside it (a subassembly at the top level,
a purchased or inseparable part with parts inside it, a folded part) names
a material only when everything it stands for shares it, else none. A frame
of steel and aluminium parts reads blank, and a bought bearing of steel
parts reads steel. One walk (adding) decides what is placed inside a row's
part for both its mass and its materials, and each definition's materials
are read once.
Components are looked up by id once per list; they were searched for
each row and each kit. The window reads the rows directly instead of
running assembly.bom after every change, so it no longer adds an entry
to the crash journal each time it refreshes. The engine keeps the
command, its parameters and the files.
Tests check rows. The module's own: an empty assembly, one part, a row
named by its lowest member through part-number edits, one part number
of two types, a phantom in a phantom, a reference at the root and its
own list, the 64-level limit, the budget hit exactly with and without
folding, kits told apart by what they hold and the types they hold it as, a folded part's contents not
folded again, row_of for every type, every placement in one row or
none, a damaged file's missing component and cycle, the mass agreement
rule (moved from the engine with row_mass) and what adds to a row. In
the engine: the material rule for every kind of row, the JSON against the
rows for every option, why a mass is
unknown, the total against component.properties in every view, what a
row stands for and its placements, and the overflow. The assembly.bom
tests from #1888 on pass unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Bill of materials: structured, all levels (#3874)
P4: `assembly.bom {levels: "all"}` lists the assembly's direct contents, each subassembly a row with
its own rows listed under it, to any depth (items 1, 1.1, 1.1.1), each child counted `each` per one
of its parent and `count` in all.
- `doc::bom::View::AllLevels` goes through the one rule (`classify`) the other views use: a
normal subassembly is a row holding what it holds, listed under it as all levels again; a
phantom has no row and what it holds joins the level it sits in, merged with the same parts
there; a purchased part is a row with nothing under it unless `show_purchased_contents`
(Request::purchased_contents) asks for its contents; an inseparable part is a row with nothing
under it; a reference counts nowhere.
- The rows under a row are the folded-part rows already built (kits), so subassemblies with one
part number and different contents are different rows, and no second nested builder is written.
All levels gathers every level as it gathers the first; a folded part's contents are still
gathered by part number in the other views.
- The JSON and CSV already nest to any depth; `show_purchased_contents` is echoed with the other
options. Each row's mass still adds up to the assembly at the top.
Tests, worked by hand: four bolts and a two-bolt subassembly placed twice (8 bolts in parts only;
in all levels the subassembly twice with 2 bolts each, 4 in all, beside the top's 4); three levels
deep (2 x 3 x 2: counts 2, 6, 12, items 1, 1.1, 1.1.1, the CSV in that order); each type (a
phantom's bolt merged into its subassembly's, purchased with and without its contents,
inseparable, reference); two subassemblies of one part number with different contents as two
rows; `levels: "deep"`, a flag that isn't one, and an assembly over 100,000 placements refused.
D's test that a folded part's contents are listed as parts only lists them now names the two views
it holds for, and checks all levels' nested rows (the subassembly inside the folded part a row with
its own rows).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Bill of materials: parts with one part number are one row only when they hold the same to any depth (#3874)
The kit compare looked one level down: two parts with one part number whose contents differed two
levels below merged into one row, and the children that only one of them held came out at each 0.
Each placement now has a kit, a number interned from what it holds (each child's part, type and
own kit), built in one pass from the last entry back: an entry's children come after it in the
walk, so their kits are known first. Rows are told apart by that number.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Bill of materials: a phantom's own bodies are a row of their own (#3874)
A phantom had no row, and its own bodies were weighed in the assembly's total but in no row, so
the rows didn't add up. Its own bodies, when it has any, are now a row of the phantom's type that
stands for them alone, as a subassembly's own bodies are in parts only; what it holds still counts
where it is placed. Inside an inseparable part in parts only, nothing changes: the part's row
weighs them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Bill of materials: the assembly's total mass in assembly.bom (#3874)
`list` weighed the assembly as a whole (from the design, not added up from rows) and the command
dropped it. `assembly.bom` now gives it as `total_mass_g`, and so does a JSON file it writes, only
when `mass: true` (null when it isn't known).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Bill of materials: all levels as JSON lists its rows one after another (#3874)
All levels nested each level's rows in the row above it: two JSON containers a level, so the
64 levels a list may hold came to 129, past the 128 that serde_json (and so the MCP server and
the control channel) reads. In all levels `assembly.bom` now gives the rows one after another,
each followed by the rows under it (items 1, 1.1, 1.1.1), as its CSV does; a row listed under
another still reads its item as text and gives `each`. A folded part's contents, one level, stay
inside its row as `children`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Bill of materials: a row whose definitions weigh something and nothing differs (#3874)
A row gathering a definition with bodies and one with none (one part number on a steel block and
on an empty assembly) said there was nothing to weigh. Their masses differ, so it says so; only a
row where none of them has a body has nothing to weigh.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Bill of materials: definitions agree on a mass within the measurement accuracy (#3874)
A row's definitions had to weigh the same to 1e-9, but the kernel measures a volume from
tessellations, and one part modelled another way is tessellated differently: a pin made as a
cylinder and as a revolved rectangle measured 1.05e-5 apart, so it read as two masses. The bill of
materials now has its own `bom::MEASURE_ACCURACY` (1e-4: ten times that gap, with its doc on what
it follows: the kernel's `measure` gives one solid's volume to about that, relative, however the
solid was modelled), and a row's definitions agree within it. A pin 0.1% wider (0.2% heavier) still
differs. The kernel is unchanged: its work is paused while it is being replaced.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Bill of materials guide: all levels, purchased contents and this round's changes (#3874)
The guide had no `levels: "all"` or `show_purchased_contents`. It now has both, with how all
levels tells subassemblies apart and lists its rows as JSON, a phantom's own bodies as a row, the
assembly's `total_mass_g`, and definitions that agree on a mass within the measurement.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Bill of materials: materials are bodies', as the code says (#3874)
The rule stays as built (a row that stands for an assembly names a material only when everything
in it shares one), but its comment and the guide said a material set on a component is set on
all its bodies. `material.assign` takes bodies only: a component has no material of its own yet.
The module notes now say so, and where component materials will join the rule.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Bill of materials: a body's volume measured once with the evaluated model (#3874)
`assembly.bom` measured each definition's bodies anew for every list, and `component.properties`
measured each placed body again. A body's measure depends on nothing but the body, so the evaluated
model keeps its volume (`ModelBody::volume`, shared by clones, as its outline box is), and both
commands weigh that one measurement: the same grams to the bit. A body offset scales it by the size
of its determinant (`mat_volume_scale`) instead of copying the B-rep to measure it. The physical
properties still measure the placed body for its area, centre, box and counts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Bill of materials: row keys, what rows stand for, members and row_of stay in doc (#3874)
Nothing outside `doc` reads them yet: `RowKey`, `Unlisted`, `Holds`, a row's `key`, `stands_for`
and `members`, and `Bom::row_of` are crate-private until item numbers and balloons need them, so
they can still change without breaking another crate. The engine test that read them is covered
by doc's own (`row_of_finds_the_row_a_placement_is_counted_in`, `every_placement_is_in_one_row_or_none`).
`Unknown` stays public: `Mass::Unknown` carries it, and a public enum can't carry a private type.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Assemblies: one fallible placement walk for totals that cover the whole assembly (#3874)
The physical properties walked the placements twice in their own code, with the 64 levels and
100,000 placements written as literals, and the bill of materials gave the same refusal in words
of its own. `Document::placements_below` is that walk once, from any placement, refusing what is
past `MAX_PLACEMENT_DEPTH` or `MAX_PLACEMENTS` (never walking it in part), and both use its
refusal: "the assembly is deeper than 64 levels or has more than 100000 placements". The physical
properties now allow 100,000 placements below the start, as the bill of materials does (they
stopped at 99,999).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Bill of materials: the same rows for less work (#3874)
- Part numbers are borrowed from their definitions (`Part<'a>::Number(&'a str)`) instead of copied
for every placement grouped and every kit.
- A row's members, the placements' paths, are built only when the list is asked for them
(`list_with`, for item numbers, balloons and `row_of`): the walk then keeps paths and moves each
into its one row instead of copying it. A list made for its rows alone builds no paths at all.
- `row_of` reads an index of member paths, built once with the list, instead of scanning every
row's members for each placement asked about.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* occurrence.bom_type: input and output schemas (#3874, #4035)
`OccurrenceBomTypeParams` takes the occurrence (an id or a name), its path when given and the
type (one of the five, `same_as_component` or null), each read by the handler's own reader: the
path through `cmd::path_ids`, split out of `occurrence_path`, the type through
`cmd::occurrence_bom_type`, split out of the handler. The handler builds its reply from
`OccurrenceBomTypeResult` ({occurrence, bom_type, effective, changed}).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Bill of materials tests: all levels presented at every depth, and its caps (#3874)
- `assembly_bom_presents_the_typed_rows` now covers all levels (with mass, purchased contents and
by definition) and the total mass, on a three-level design with a purchased gearbox holding a
gear, comparing every field of every row down to 1.1.1.1.
- All levels lists 100,000 placements and 64 levels, and refuses 100,001 and 65.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Bill of materials: static materials, typed in for a component (#3874)
A value the bill of materials works out can now be typed in by hand for a component (a static
value, Cameron's choice of word). Material comes first:
`component.metadata.set {component, material}` takes any text up to MAX_TEXT_BYTES, and
`component.metadata` reads it back as `material`. It is shown wherever the component is listed,
at every level and in every view, over the materials worked out from its own bodies or an
assembly's blank, and the row carries `static: ["material"]`. Clearing it (empty text or null)
brings the worked-out material back.
It is kept the way `bom_type` is: a part property in the component's metadata (`material`), so
there is no format change and older releases keep it. `PART_ONLY` names both keys in one place:
Design Properties doesn't list them and `document.metadata.set` refuses them. Another tool's
non-text value is kept and reads as no static material.
The bill of materials says one thing about the part everywhere: a static material also stands for
the part in the one material an assembly around it shares (two parts typed in as S355 make their
frame read S355; S355 beside plain steel reads blank). A phantom's row is its own bodies, so its
static material names those only, and what it holds keeps its own. A row gathering several
definitions takes the first one's that has a static material, as its description does. It only
names: mass still comes from the bodies.
The CSV gets a `material` column at the end, so the other columns keep their places: what the row
shows, the static material or the worked-out ones joined with "; ".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Bill of materials: stable item numbers, saved with the design (#3874, P5a)
A numbered parts list keeps each row's item number under the row's key in
`assembly.item_numbers`, so a row keeps its number when others are added,
removed or reordered. New rows take the next number after the highest at
their level; Renumber restarts a view in list or item order and leaves
locked rows alone; duplicates are marked; numbers change no geometry and
are part properties in the undo history.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>