Expand description
Import of bills of materials exported by CAD programs (see
crate::bomtable) and of the product structure of STEP assemblies (see
crate::stepbom).
An import creates the items that are not in TeamCraft yet and the
multi-level BOM below an assembly: a new top-level assembly or a revision
the user has checked out. The preview and the import use the same planning
code, so the preview shows exactly what the import does; the import runs in
one transaction (all or nothing) and writes the usual audit entries per
item and BOM line plus one import.bom summary.
Rules (defaults in brackets):
- rows with the same part number (or, without one, the same name) are one item; repeated rows below the same parent are merged (quantities added),
match_existing[on]: a part number that is an item number in TeamCraft uses that item – its own BOM is never changed by an import,numbers[file]: new items get the part number of the file when it is a valid, unused item number, otherwise a generated one (the CAD number is then kept in the description);generatealways generates numbers,- a sub-assembly takes its children from its first occurrence; when the rows below it are skipped there (e.g. below an existing item) or come later, they are read at the occurrence that creates the sub-assembly,
- components already in the BOM of the target revision are not added again, so importing the same table twice does not duplicate lines.
A STEP file is attached to the new top-level assembly it creates, so its 3D
preview shows the whole assembly. Web uploads wait in staged_imports
until the user confirms the preview – tables in the row, STEP files in the
vault.
Structs§
- Attribute
Column - A column of the file that fills a custom attribute.
- Created
Item - Import
Options - Import
Result - What an import did.
- Plan
- What an import would do.
- Planned
Attribute - A custom attribute value a new item gets from the file.
- Planned
Item - An item the import uses or creates.
- Planned
Line - A BOM line the import adds.
- Staged
- An upload waiting for the user’s confirmation.
Enums§
- Number
Source - Where the numbers of new items come from.
Constants§
- MAX_
STEP_ BYTES - Largest STEP assembly accepted.
- MAX_
TABLE_ BYTES - Largest BOM table accepted.
- STAGED_
HOURS - Staged uploads older than this are removed by the housekeeping task.
Functions§
- discard
- Discards a staged upload; returns its options (to go back to the target).
A table goes at once. A STEP file is only marked expired: its row is
unusable from now on, and
purge_staleremoves it together with its blob once the blob is past the grace period of the vault clean-up. - max_
bytes - Largest import file accepted with this name.
- plan
- Plans an import. Used for the preview (any connection) and by
run(inside its transaction, the target revision stays locked). - preview
- The preview of a staged upload.
- purge_
stale - Removes staged uploads older than
STAGED_HOURSand discarded ones (housekeeping), the blobs of STEP files with them – unless something else refers to the blob (a file made from the same content, another staged upload) or it was stored again withinretention::IN_FLIGHT_GRACE; such a staged upload stays (expired) until the next run. Returns the number of staged uploads removed. - read_
table - Reads an uploaded BOM table or STEP assembly (format and size checks included).
- run
- Runs an import in one transaction.
source(the STEP file, seestep_file) is attached to a new top-level assembly. - run_
staged - Runs a staged import and removes the upload (a second click finds nothing).
- stage
- Stores an upload for the preview; fails right away if the file cannot be read. STEP files go to the vault, tables into the row.
- staged
- A staged upload of the actor.
- step_
file - Stores an uploaded STEP assembly in the vault, ready to be attached to the
assembly it creates;
Nonefor tables. - too_
large - “Tables (BOM, result values) can be at most 20 MiB.” / “STEP files …”