Guide · Programming
From DXF Drawing to G-Code: A Clean 2D Workflow
How to prepare a DXF drawing for CNC milling, plasma or laser: units, closed contours, duplicates, cutting order, compensation and tabs, with a free converter that runs in the browser.
On this page
A DXF is the most common way to hand over a flat part. It is also the source of many small problems: wrong units, gaps between lines and hidden duplicates. Ten minutes of cleaning saves an hour at the machine.
Clean the drawing
- Scale: measure one known dimension. DXF files do not reliably store units.
- Delete everything that is not cut: dimensions, title block, centre lines.
- Join the lines: every outline must be a closed chain. Gaps larger than a few hundredths of a millimetre break it.
- Remove duplicates: two lines on top of each other are cut twice. Most CAD programs have an OVERKILL or similar command.
- Convert splines to polylines with arcs. Thousands of tiny lines make a machine stutter.
Choose the cutting order
Cut inside shapes first and the outer contour last. Once the outside is cut, the part can move. The DXF to G-code converter does this automatically.
Compensation
The tool has a width, so a hole cut on the line becomes too large and the outside too small. There are three ways to handle this:
- Draw an offset contour in CAD. Works on every machine.
- Use G41 with the radius in the offset table. Best on industrial controls because you can correct the size at the machine.
- Cut on the line. Correct for engraving and scoring.
Keep the part from flying away
When the last pass goes through the sheet, the part is free. Use double-sided tape, vacuum, screws in the waste area, or leave a thin skin of 0.1 to 0.2 mm and cut it by hand. Tabs of 3 to 5 mm width are the usual choice on routers.
Before you start
Open the program in the G-code viewer and check three things: the size in X and Y, the position of zero, and the lowest Z.
More guides
- End Mill Deflection: Why Stick-Out Matters More Than Anything Else
- Tolerance Stack-Up Explained with a Bearing Housing Example
- How to Cut a Spur Gear on a CNC Mill with a 4th Axis
- How to Machine a Keyway in a Shaft and a Hub
- Hard Milling 45 to 62 HRC: Tools, Speeds and Strategy
- Fanuc Macro B for Beginners: Variables, IF, WHILE and Your First Useful Macro