Skip to main content

Module imports

Module imports 

Source
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); generate always 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§

AttributeColumn
A column of the file that fills a custom attribute.
CreatedItem
ImportOptions
ImportResult
What an import did.
Plan
What an import would do.
PlannedAttribute
A custom attribute value a new item gets from the file.
PlannedItem
An item the import uses or creates.
PlannedLine
A BOM line the import adds.
Staged
An upload waiting for the user’s confirmation.

Enums§

NumberSource
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_stale removes 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_HOURS and 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 within retention::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, see step_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; None for tables.
too_large
“Tables (BOM, result values) can be at most 20 MiB.” / “STEP files …”