Skip to content

piece_segments

Python reference for nagasim.appearance.piece_segments. Provisional: it may change between minor versions, see Appearance.

A conveyor piece's path as straight and arc segments, in metres.

The segments are laid end to end from piece_start. A straight has its length; an arc has its radius, the angle it sweeps in degrees and its turn, left (counter-clockwise on screen, the heading falls) or right (clockwise, the heading rises), and its length is the arc's. The lengths and radii are in metres whatever the belt's length unit.

Parameters:

Name Type Description Default
document ModelDocument

The model, ModelDocument.load(path).

required
name str

The CONVEYOR block's name.

required

Returns:

Type Description
list of Segment or None

Segment(kind, length, radius, angle, turn) per piece of path, kind "straight" or "arc"; None in the cases piece_start returns None.

See Also

nagasim.appearance.piece_start : Where the first segment starts. nagasim.appearance.piece_length_m : The segments' total length.

Examples:

>>> from nagasim.appearance import ModelDocument, piece_segments
>>> doc = ModelDocument({"simulation": {"length_unit": "millimeters"}, "blocks": [
...     {"name": "Belt", "type": "CONVEYOR", "params": {"type": "belt",
...      "path": [{"straight": 2000}, {"arc": {"radius": 500, "angle": 90, "turn": "left"}}]}}]})
>>> [(s.kind, round(s.length, 3), s.radius, s.turn) for s in piece_segments(doc, "Belt")]
[('straight', 2.0, 0.0, ''), ('arc', 0.785, 0.5, 'left')]