# piece_length_m

Python reference for `nagasim.appearance.piece_length_m`. Provisional: it may change between minor versions, see [Appearance](../../appearance.md).

`nagasim.appearance.piece_length_m`

```python
piece_length_m(document: ModelDocument, name: str)
```

A conveyor piece's length along its path, in metres.

It is the sum of `piece_segments`' lengths, whatever the belt's length unit;
`guide_runs(length, openings, side)` and the placement rules of the Appearance page take
it.

Parameters
----------
document : ModelDocument
    The model, `ModelDocument.load(path)`.
name : str
    The CONVEYOR block's name.

Returns
-------
float or None
    The length in metres; None in the cases `piece_start` returns None.

See Also
--------
nagasim.appearance.piece_segments : The segments it sums.
nagasim.appearance.guide_runs : The guide stretches over this length.

Examples
--------
>>> from nagasim.appearance import ModelDocument, piece_length_m
>>> doc = ModelDocument({"simulation": {"length_unit": "millimeters"}, "blocks": [
...     {"name": "Belt", "type": "CONVEYOR",
...      "params": {"type": "belt", "path": [{"straight": 2500}]}}]})
>>> piece_length_m(doc, "Belt")
2.5
