G-code Files
G-code is the language of CNC machines: routers, mills, laser and plasma cutters, water jets and drag knives. Import a program with File › Import › Import… to see what it cuts, and write one with File › Export › Export…, choosing G-code Files.
Import
ParametrIQ CAD reads the program and follows its moves:
- Each continuous cut comes in as a polyline of lines and arcs. A path cut again deeper (in depth passes) comes in once, at its deepest depth (unless Merge depth passes is off in the import options).
- Drilled holes (canned cycles G81 to G89, or, with Plunges as holes, a plunge straight down and back up) come in as circles the size of the drill, when the program says what it is, or as points (and always as points with Holes as circles off).
- Each tool gets a layer of its own, in its own colour: tool n on layer 100 + n (Tool layers start at). Switch off A layer for each tool to have everything on the Cut layer.
- Rapid moves (G0) can come in too, as lines on a layer of their own, if you switch them on.
- Every path and hole keeps the tool settings it was cut with: tool number and description, diameter, spindle speed, feed rate, depth, step down, coolant and cutter compensation; for holes, the peck depth and dwell. Export the drawing again and they are cut the same way.
- A feed move cuts at or below the Cutting height (0 unless you give another). Programs that never go below zero (lasers, plasma, drag knives) count a move as cutting when the spindle or beam is on.
What is understood: G0, G1, G2 and G3 (arcs by I and J or by R, full circles and helices), G17, G20 and G21 (inches and
millimetres), G90 and G91, G80 to G89, G40 to G42, tool changes (T, M6), spindle (S, M3 to M5), coolant (M7 to M9),
feed (F), comments in brackets or after a semicolon, line numbers and block delete (lines starting with / are
skipped unless Skip block-delete lines is off). Files ending .g, .mpt and .eia are read as G-code too. Tool sizes are taken from
comments such as (T1 D=6) where the program has them. Expressions, parameters (#), subroutines and loops are not
run: lines that use them are skipped.
Export
Each element is cut with its own tool settings, if it has them (from an imported program, or saved with the drawing); anything it leaves out takes its layer's settings (set in Production › Tool Options and saved with the drawing), and anything those leave out takes the defaults below, which the export options let you change, with the cutter compensation (on the line, inside or outside) and coolant. So give each layer its tool once (a 6 mm end mill outside the line for Cut, a drill for a Holes layer), and only the elements that differ need settings of their own. A shop's layer settings can be exported to a tooling file and imported into other drawings, or made the default for new drawings (see Reusing tooling). Lines on the Dimension and Tape layers, unless they or their layer have tool settings (or Leave out dimensions and glue is off), and points that are not drill holes, are left out.
| Setting | Millimetres | Inches |
|---|---|---|
| Tool diameter | 3 | 0.125 |
| Spindle speed (rpm) | 12000 | 12000 |
| Feed rate (per minute) | 1000 | 40 |
| Plunge rate (per minute) | 300 | 12 |
| Depth of cut | −1 | −0.04 |
| Safe height | 5 | 0.2 |
The program, unless you choose otherwise in the export options:
- is written in your drawing's units (G21 or G20), named after the file, between
%lines, without line numbers; - groups the cuts by tool, drilling first, then pockets, then profiles, with a tool change (T… M6) between tools (or an M0 pause, for a machine without a changer; G43 tool length offsets if you want them), and cuts each tool's paths nearest first;
- cuts arcs as G2 and G3, and other curves as lines and arcs within 0.01 mm (0.0005");
- cuts in passes no deeper than the tool's step down, with any cutter compensation worked into the path, plunging straight in (or ramping or in a helix, as Entry says) and with no lead in or out (or an arc or line from the waste side);
- drills holes with G81, G82 (with a dwell) or G83 (pecking), and bores holes bigger than the drill with a helix;
- ends back at X0 Y0.
For a 2D machine (laser, plasma, water jet, knife), switch off Z axis: there are no Z moves, and M3 and M5 switch the beam or torch on and off round each cut.
Pocketing
A pocket clears the inside of a closed shape down to a depth, instead of cutting along its line: a recess for an insert, a lowered panel, lettering cut into a sign. Three ways say what is pocketed:
- A layer's pocket style: in Production › Tool Options, give a layer a Pocket style
(and its depth, step down and step over). Every closed shape on the layer is pocketed, every time the drawing is
exported, since the setting is saved with the drawing (
LAYER …,TOOL POCKET="SPIRAL",DEPTH=-2). - A pocket layer for one export: in the export options' Pocketing group, choose a Pocket layer. Every closed shape on that layer is pocketed, in the Pocket style chosen, to the Pocket depth in passes no deeper than the Pocket step down (both left at their automatic setting: the tool's own depth and step down, as for any other cut). The layer's own settings from Tool Options win over these. Open lines on the layer are cut along the line, with a warning.
- An element's own tool settings:
TOOL POCKET="SPIRAL"(or"ZIGZAG","CONTOUR") after a closed element pockets it, to its ownDEPTHin steps of its ownSTEP, andSTEPOVER=gives the distance between passes (see element settings). These win over the layer's.
Islands: a closed shape inside a pocketed shape, with the same pocket settings (on the same pocket layer, say), is an island: it is left standing, and the tool keeps clear of it. A shape inside an island is pocketed again, and so on.
| Style | How the pocket is cleared |
|---|---|
| Zigzag | Straight passes back and forth, joined wherever the link stays inside, then a pass round every wall. |
| Spiral | One path from the outside in, turn by turn; where the shape divides or has islands, each part on its own. |
| Contour | Rings one step over apart, each a pass of its own, from the outside in. |
The Step over, the distance between passes, is a share of the tool diameter (50% unless you choose another; 40 to 60% suits most router work), for every pocket whose tool settings don't give a distance of their own. It is never more than the diameter, so no ribs are left between passes.
The tool's centre stays a tool radius from every wall and island, so the cutter just touches them: corners inside the pocket keep the tool's radius, and gaps narrower than the tool aren't reached (a pocket narrower than the tool is left out, with a warning; one without a tool diameter too). At each depth the passes are cut in turn, lifting to the rapid clearance between them and plunging at the plunge rate into the next. Climb milling is kept: round the walls the other way for a spindle turning anticlockwise.
Order: the program drills first, then cuts every pocket, then the profiles (so no part is cut free before it is pocketed), each tool's pockets nearest first. The profiles start with the tool the last pocket was cut with, so no tool is changed more often than needed.
Post-processors built on the built-in G-code (base: "gcode") get the pockets with the rest; those that write the
program themselves see each element's pocket and stepOver in its tool settings (its own over its layer's; see
Post-processors).
Imported drawings often have shapes that don't quite close, or lines drawn twice: Clean Up Drawing first, so their shapes can be pocketed.
Check a program in your machine's own software, or a G-code viewer, before you run it.