# Library and standard parts

Some parts of a machine are designed; most of the rest is bought: linear rails and carriages, motors, couplings, lead screws, pulleys and belts, sensors, profiles, screws, nuts, washers and bearings. Moket keeps the bought ones in two places, so they are never modeled twice.

Read [Assemblies](assemblies.md) first for inserting components.

## Standard parts

Screws, nuts, washers, ball bearings and O-rings of ISO and ANSI standards are built in. `find_standard_part` (`{"query":"ISO 4762 M4"}` or `"608 bearing"`) works on any document and gives each part's id, standard, units, material, where its origin is, its parameters, and the rows that match with their configuration ids and dimensions. Insert one with `component.insert` `{"part":<id>,"configuration":<row id>}`; standard parts are never copied into the project. How to fasten a hole with them is in [Assemblies](assemblies.md).

## The component library

The user's component library holds bought parts someone modeled once, by maker, series and part number, in versions.

1. Before modeling a bought part, call `find_library_part` with its maker, series, part number or size. It lists matching library items with their versions, and the matching standard parts too.
2. Insert a library item with `component.insert` `{"part":<version.part>,"configuration":<a size's configuration>}`. The component keeps that version: `inspect_assembly` shows `part.library {item, version}` on library components, and `component.replacePart` moves components of an older version to the latest one `find_library_part` returns.
3. Set what changes per use on the component (a rail's length): `component.update` `parameters`. A library version keeps the project values it was published with.

## Modeling a bought part

When the library has no such component, model it as a part of the project from the maker's datasheet:

- The outline, the mounting holes and the faces other parts attach to, at the datasheet's dimensions. Ask the user for the datasheet or its link when you do not have it; never guess the size of a real product.
- Its sizes as configurations, one row per size, named as the maker names them (see [Parts](parts.md), configurations), and the maker's part number in its name.
- Put its origin where it mounts (a rail's bottom face at its first hole, a motor's flange at its shaft axis), so joints are easy.
- Detail nothing attaches to can stay simple.

Then offer to publish it with `publish_to_library` (maker, series, part number, the datasheet link, a note on where the sizes come from), so the next project inserts it instead of modeling it again. Publish only after the user agreed; a later change of the same part becomes the item's next version.
