Milling, turning, and cutting
Overview
Subtractive manufacturing removes material until only the part remains. This chapter covers the subtractive strategies in Rasmah: milling a planar pocket or a free-form surface, turning on a lathe, and cutting with a wire or a beam. Every strategy produces the same ToolPath you met in Manufacturing, so the post-processing and simulation stages are shared.
2.5D milling: pockets, profiles, faces, holes
A 2.5D part is one whose surface is a set of flat floors at different depths — a pocket, a step, a hole. The tool moves in x and y, and plunges to a depth. The input is a region: a list of loops (first outer, the rest holes) at a given height, as produced by slice_contours/region_at.
Rasmah.pocket_zigzag — Function
Clear a planar region by zig-zag raster, stepping down by stepdown to depth. region is a list of loops (first outer, rest holes) at z = 0; the floor is z = -depth. A finishing pass around the outer contour is appended when finish=true (tool center offset inward by the tool radius).
Rasmah.pocket_offset — Function
Clear a planar region by contour-parallel offset rings, stepping down by stepdown to depth.
Rasmah.adaptive_clearing — Function
Adaptive (offset-spiral) clearing: cut the region by spiralling inward with a constant stepover, stepping down by stepdown to depth.
Rasmah.rest_machining — Function
Rest machining: run tool_big's pocket on the stock, recover the material it left behind (corners/fillets), and clear the residual region with tool_small. Returns the small-tool clearing ToolPath.
Rasmah.profile_milling — Function
Side-mill a closed planar contour (a single loop at z = 0) down to depth, stepping by stepdown. The tool center rides on the contour; pass offset=radius (the default) so the tool periphery cuts the wall. Returns a ToolPath.
Rasmah.facing — Function
Face a region (list of loops at z = 0) to depth with a zig-zag pass at the given stepover. stock_only=true fills the region's bounding box instead of the region itself (a conventional facing pass over the raw stock).
Rasmah.drill — Function
Drill a set of holes holes (each a 3-vector, at z = 0) to depth. When peck > 0, the plunge is broken into peck-deep advances with full retracts between them. Returns a ToolPath.
Rasmah.drill_hole — Function
Drill a single hole at position (alias for a one-entry drill).
region = [[[0.0, 0.0, 0.0], [20e-3, 0.0, 0.0], [20e-3, 20e-3, 0.0], [0.0, 20e-3, 0.0]]]
tp = pocket_zigzag(region, EndMill(2e-3); depth=1e-3, stepover=1e-3)
num_motions(tp)89round(ustrip(toolpath_length(tp)); digits=4)0.928Clearing a 20 mm square pocket 1 mm deep with a 2 mm tool at a 1 mm stepover takes 89 motions totalling about 0.93 m of travel.
3-axis surfacing
When the surface is curved, a flat-end tool cannot follow it; a ball-nose tool rides the surface directly. Two finishing strategies cover the common cases:
Rasmah.parallel_finish — Function
Parallel (raster) finishing: zig-zag scan lines across the XY extent of the surface, with the ball-nose tip at surface_height - radius so the cutter flank contacts the surface. angle rotates the raster.
Rasmah.waterline_finish — Function
Waterline (constant-Z) finishing: slice the surface at successive Z levels and profile each contour with a ball-nose tool (center offset by the radius).
4- and 5-axis
Rotating the workpiece (or the head) lets a tool reach faces a 3-axis machine cannot. These build on the same tool path model with extra orientation:
Rasmah.transform_toolpath — Function
Rotate a tool path's motion targets by R about origin (for indexed 3+2).
Rasmah.indexed_3plus2 — Function
Indexed 3+2: plan a 3-axis pocket for each of a set of part orientations (rotation matrices about the part origin), returning one toolpath per index.
Rasmah.swarf_milling — Function
Swarf milling along a ruled surface given by two guide curves top and bottom (same number of points). The tool side (a flat-end mill, axis tilted) rides the ruling between the curves, with the tool axis parallel to the ruling. Returns a ToolPath whose axis is carried in the motion metadata.
Rasmah.five_axis_finish — Function
Continuous 5-axis finishing: raster over the surface with a ball-nose tool oriented by lead/tilt angles (gouge/clearance control), returning the tool path and the per-cutting-move tool-axis directions.
Rasmah.tool_orientation — Function
Tool-axis orientation for continuous 5-axis finishing: start with the tool axis aligned to the surface normal normal, then tilt it by lead (in the feed direction, about cross(normal, feed_dir)) and by tilt (across the feed, about feed_dir). Returns a unit vector pointing from the tool tip toward the shank. With lead = tilt = 0 the axis is the surface normal.
Turning
On a lathe the workpiece spins and a single tool follows a [radius, z] profile. Turning follows the same idea — a profile in, a tool path out:
Rasmah.turning_finish — Function
Finish a lathe profile in a single pass (the tool follows the profile).
Rasmah.turning_roughing — Function
Roughing: remove the stock between the cylinder and the profile by horizontal strip passes at stepdown radius increments, then a finishing pass along the profile (plus finish_allowance).
Rasmah.turning_facing — Function
Face the free end of a stock cylinder: skim the end down to depth.
Rasmah.turning_groove — Function
Cut a groove (recess) of width and depth at axial position z.
Rasmah.turning_thread — Function
Cut a single-point thread of pitch over length, starting at axial z, by successive helical passes to depth.
Wire EDM and beam cutting
For sheet material or very hard parts, a wire or a beam cuts a contour:
Rasmah.wire_edm — Function
Cut a closed planar contour with a wire, at the given thickness (blank height). The wire follows the contour at successive depths is unnecessary for wire (a single pass); taper tilts the wire by the given angle per side, so the top and bottom contours differ by 2·thickness·tan(taper). Returns the top and bottom ToolPaths (XY plane).
Rasmah.laser_profile — Function
Cut a closed (or open) planar contour with a beam of width kerf. The beam center rides the contour inset by kerf/2 so the cut edge lands on the contour. Adds a pierce point and lead-in when pierce=true.
Rasmah.nest_rectangles — Function
Pack rectangular parts onto a sheet using a bottom-left shelf packing: sort by height descending, place each part at the lowest y it fits at its current x, advancing x across the sheet width and wrapping to a new shelf. Returns the list of placed rectangles (x, y, w, h) and the sheet height used.
Next steps
The subtractive side ends with the tool path. The additive side — Additive manufacturing — reuses the same pipeline for 3D printing, and the post-processing and stock simulation live with them. To see how the whole pipeline ends in controller code, continue there.
