network_polylines

compas.datastructures.network_polylines(network, splits=None)[source]

Join network edges into polylines.

The polylines stop at points with a valency different from 2 in the network of line. Optional splits can be included.

Parameters:
networkNetwork

A network.

splitssequence[[float, float, float] | compas.geometry.Point], optional

List of point coordinates for polyline splits.

Returns:
list[list[[float, float, float]]]

The joined polylines. If a polyline is closed, the two extremities are the same.

Examples

Joining the lines (a, b), (b, c), (c, d), (c, e) and (e, f), where a … f are different point coordinates. This will result in the following polylines (a, b, c), (c, d) and (c, e, f).

>>> from compas.datastructures import Network
>>> a = [0., 0., 0.]
>>> b = [1., 0., 0.]
>>> c = [2., 0., 0.]
>>> d = [2., 1., 0.]
>>> e = [3., 0., 0.]
>>> f = [4., 0., 0.]
>>> lines = [(a, b), (b, c), (c, d), (c, e), (e, f)]
>>> network = Network.from_lines(lines)
>>> len(network_polylines(network)) == 3
True