drill module#

Serialize a DrillFile as a Gerber image.

Spec 6.6 recommends Gerber over any NC format for drill and rout data: the copper is already Gerber, mixing formats risks registration errors, and a Gerber drill file carries attributes natively instead of smuggling them through comments the way XNC has to.

A drill file is an ordinary Gerber image under the restrictions 6.6 states. Only circular apertures may appear, and only as a flash for a hole or a non-closed chain of draws and arcs for a slot. The image is the material to remove and the diameter is the finished size after plating, which is exactly what a Tool already means, so nothing is converted here beyond the object types. Drill files must be positive.

This writer therefore builds a GerberFile and hands it to the ordinary emitter rather than reimplementing coordinates, apertures or the attribute state machine. Every property the Gerber emitter already guarantees - D-code assignment, the 1 nm grid, arc splitting over 180 degrees, attribute diffing - holds here for free and cannot drift away from the copper files.

tool_aperture(tool)[source]#

The circular aperture that images one tool.

Tool attributes become aperture attributes unchanged: a tool is an aperture and its TA.AperFunction is the same bare function name in both formats, since plating is a file attribute rather than a tool one.

Return type:

Aperture

Parameters:

tool (Tool)

to_gerber(file)[source]#

The Gerber image of a drill file, hits first and then rout paths.

Object order follows emit_xnc so the two formats produce the same image in the same sequence and a golden test can compare them.

Return type:

GerberFile

Parameters:

file (DrillFile)

emit_drill_gerber(file, meta)[source]#

The complete text of one drill file in Gerber format, M02* included.

Return type:

str

Parameters: