pyrobopath.toolpath.toolpath_core.Toolpath#

class pyrobopath.toolpath.toolpath_core.Toolpath(contours: List[Contour] | None = None)[source]#

Bases: object

A container for a list of Contour objects, representing a complete toolpath.

Parameters:

contours (list of Contour, optional) – A list of Contour instances. Defaults to an empty list.

Methods

combine

Combine multiple Toolpath objects into a single toolpath.

from_gcode

Construct a Toolpath from a sequence of G-code lines.

scale

Uniformly scale all waypoints in each contour by a scalar value.

tools

Return a unique list of tools in the toolpath

classmethod combine(toolpaths: List[Toolpath]) Toolpath[source]#

Combine multiple Toolpath objects into a single toolpath.

Parameters:

toolpaths (list of Toolpath) – A list of Toolpath instances to be merged.

Returns:

A new Toolpath containing all contours from the input toolpaths.

Return type:

Toolpath

classmethod from_gcode(gcode: List[GcodeLine]) Toolpath[source]#

Construct a Toolpath from a sequence of G-code lines.

Parses linear motion (G1) and tool change (T) commands to generate a set of extruding paths grouped as contours.

Parameters:

gcode (list of GcodeLine) – A list of parsed G-code lines from which to generate the toolpath.

Returns:

A new Toolpath object constructed from the G-code input.

Return type:

Toolpath

Notes

  • Only extrusion movements (with positive delta E) are considered part of a contour.

  • Tool changes are captured using T commands.

scale(value: float)[source]#

Uniformly scale all waypoints in each contour by a scalar value.

Parameters:

value (float) – The scale factor to apply to each point in all contours.

tools() List[int | Enum][source]#

Return a unique list of tools in the toolpath

Returns:

A list of unique tool identifiers used across all contours

Return type:

list of int or Enum