Skip to content

compas_cnc.toolpath_2d_surfacing.toolpath_2d_surfacing ¤

toolpath_2d_surfacing(line0, line1, radius, safe_z=None, stepover=None, incline=False, direction=None, contour=True)

Zigzag (boustrophedon) milling tool-path that clears the rectangle bounded by two parallel edges, then runs a finishing contour around the full boundary.

Sequence of the path:

  1. Plunge -- a vertical line from safe_z straight down onto the start corner.
  2. Zigzag -- back-and-forth sweeps clearing the inside. The tool-CENTRE path is inset from both edges by radius so a tool of that radius stays WITHIN the rectangle, and the spacing between passes is forced <= stepover (ceil on the pass count) so passes overlap.
  3. Contour -- trace the FULL inset perimeter (all four edges) and return to the start corner, leaving a clean wall all the way round. The connecting move from the zigzag end retraces one edge, so it goes round a little more than once -- which is fine for a finishing pass.
  4. Retract -- a vertical line back up to safe_z at the start corner.

Parameters:

  • line0 (:class:`compas.geometry.Line`) –

    The two (roughly) parallel edges to fill between. Passes sweep across the gap and step along their length, so the choice of edges sets the zigzag orientation.

  • line1 (:class:`compas.geometry.Line`) –

    The two (roughly) parallel edges to fill between. Passes sweep across the gap and step along their length, so the choice of edges sets the zigzag orientation.

  • radius (float) –

    Tool radius. Used as the boundary inset and, by default, the max spacing.

  • safe_z (float, default: None ) –

    Plunge/retract height. Clamped up to at least :data:MIN_CLEARANCE above the tool-path plane. Defaults to toolpath_z + MIN_CLEARANCE.

  • stepover (float, default: None ) –

    Distance between passes. Defaults to radius; actual spacing is always <= stepover (the pass count is rounded up).

  • direction ((None, climb, conventional), default: None ) –

    Milling direction for hard materials (assumes a CW / M3 tool; on M4 pick the opposite label). When set, the finishing contour is wound to match (the rectangle is a pocket wall) and the zig-zag goes one-directional (every pass cut the same way, lift + rapid between). None (default) is the faster bidirectional zig-zag, fine for soft materials.

  • contour (bool, default: True ) –

    Add the finishing lap around the full inset perimeter after the zig-zag. True (default) walks the boundary and returns to the start corner before retracting. False skips that lap and retracts STRAIGHT UP from wherever the last cutting pass ended -- use it where the perimeter lap would otherwise swing the tool around into neighbouring material.

Attributes:

  • path (:class:`compas.geometry.Polyline`) –

    The full tool-centre path: plunge, zigzag, then either the finishing contour and a retract at the start corner (contour=True) or a straight retract up from the last cutting point (contour=False).

  • zigzag, contour (:class:`compas.geometry.Polyline`) –

    The cutting zigzag and the finishing perimeter loop, separately.

  • passes (int) –
  • spacing (float) –
  • safe_z (float) –

from_mesh_face classmethod ¤

from_mesh_face(mesh, face_id, radius, safe_z=None, stepover=None, flip=False, incline=False, direction=None, start=None, contour=True)

Build a tool-path from the face face_id you choose on a mesh.

flip/incline/start/contour -- see :meth:from_quad. Returns None if that face is not a quad.

from_plate classmethod ¤

from_plate(mesh, radius, safe_z=None, stepover=None, top=False, flip=False, incline=False, direction=None, start=None, contour=True)

Build a tool-path from a plate-like cutter's large face.

A plate's two LARGEST faces are its top and bottom (both quads); the thin side faces are ignored. Coplanar triangles (from a triangulated cutter) are first merged back into quads, so this is robust to triangulation -- no need to clean the cutter mesh first. Uses the LOWER face by default, or the upper one with top=True. flip (boolean) sets the zigzag direction and incline shifts the path for tilted faces (see :meth:from_quad). Returns None if no quad face is found.

from_quad classmethod ¤

from_quad(points, radius, safe_z=None, stepover=None, flip=False, incline=False, direction=None, start=None, contour=True)

Build a tool-path that fills a 4-corner face.

points are the face's 4 corners in order -- as an open list/polyline of 4 points, OR a CLOSED polyline of 5 (the repeated closing corner is dropped), so the same outline you draw can be passed straight in. Returns None if it is not 4 corners.

flip -- the zigzag direction (boolean): False (default) sweeps along the LONGER side (fewer, longer passes); True sweeps the PERPENDICULAR way (the other subdivision direction).

incline -- if the face is tilted, shift the whole tool-path by radius up-slope along the subdivision direction, so the FLAT tool's edge rides the surface instead of its centre digging into the material (see _build).

start -- where the sweep BEGINS (it becomes line0.start): None (default) starts at the HIGHEST corner, so a tilted face is cut from the top downhill; an integer 0-3 selects that corner of the face outline by index (the order points are given / the mesh face's corner loop); or pass a point (x, y, z) to start at the corner nearest it. On a flat face None keeps the flip start. Re-orients the rails only; the zigzag is unchanged.