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
  • network (Network) – A network.

  • splits (list, optional) – List of point coordinates for optional splits. Default is ‘’None’’.

Returns

polylines (list) – The joined polylines. If the 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