xnc module#

Serialize a DrillFile to XNC text.

XNC is a strict Excellon subset (spec 2021.11). The header is M48, the unit, the tool table and %; the body is drill sections (G05, a tool, its hits) and rout sections (G00 to the start, tool down, the path, tool up), and M30 ends the file.

Attributes ride in standard comments (; #@! TF…), with Gerber X2 semantics: a tool is an aperture and a hole is an object. So this writer carries the same attribute state machine emit.py does, which is easy to overlook precisely because the attributes look like comments.

Tool diameters are finished sizes, after plating. Nothing here compensates in either direction: the fabricator picks the bit.

MAX_TOOLS = 99#

Tool numbers are two digits, 01 to 99 (3.4).

MAX_COMMENT = 255#

A comment’s content is at most 255 characters (3.1).

exception XncError[source]#

Bases: ValueError

A drill file cannot be expressed in XNC.

emit_xnc(file, meta)[source]#

The complete text of one XNC file, M30 included.

Raises:

XncError – the file needs more distinct tools than XNC can number.

Return type:

str

Parameters: