DXF to G-code Conversion Tutorial
The program converts a 2D dxf drawing to CNC machine compatible G-Code.
 Problem Statement
 Start with an Overview Video
In the video, DXF2Gcode is used. Installation Instructions for Linux.
- Note: forget about the installation instructions. Just download the python script, run it, import the DXF, export the g-code file (.ngc). The instructions complicate the issue for novices.
 Generate G-Code from DXF File
- Download python DXF2gcode conversion script onto your desktop.
- Go in to Terminal
- Navigate to the directory where you downloaded the script.
- For Factor e Farm implementation - cd gcode
- Run the script from within the directory where the script is located: python scriptname.py
- For Factor e Farm implementation - python d2g.py
- Bingo. The GUI for DXF2gcode runs.
- Read the DXF from the File menu in the DXF 2 G-Code script.
- Export the DXF into .ngc (G-Code) format.
- The .ngc file is readable by EMC2
In other words: Generate your CAD in QCAd like in this example:
Import the QCad image into DXF 2 G-Code:
Import the g-code file into EMC2:
 Basic Shakedown
 Proper Scaling
- To assure that the object that is being fabricated has the desired dimensions, start with an inch scale in QCad for the USA
- Note: DXF 2 G-Code displays a bunch of import errors when importing Will's sample DXF generated from Solidworks; just click through all the errors, and the image appears at the end.
- Note: Why does DXF 2 G-Code generate the toolpath twice?
- Note: Change G21 to G20 for mm -> inch scale within DXF 2 G-Code
- Eliminate the z feeds since we don't use the z axis for plate torching.
 Complete Shakedown
Note that we are in a 2-hose machine torch configuration with manual cutting gas toggle.
As it stands, the toolchain for open source torch cutting is quite disintegrated. It turns out that the above code, while in principle correct, does not address the practical considerations of piercing metal. For example, when one wants to torch out a hole - one should not pierce the metal right on the cutting line, because piercing is a messy operation. Instead, one wants to pierce inside a hole, and subsequently move to the circle contour. Moreover, one wants to preheat the metal not by standing in place, but oscillate back and forth to heat the metal more evenly.
It further emerges that the fuel flow rate should decrease after metal ignition, as the fuel gas is important primarily in preheating, not in cutting.
Moreover, the width of the cut needs to be considered, so the actual toolpath needs to be modified by about 1/16 smaller diameter size for circles when using a #2 cutting tip. Thus, finetuning is a precise matter - if one is interested in precise cuts such as small bolt holes.
To address the proper piercing issue, Vann Miller has written a correction script. This script does 3 things. First, it takes out the z values generated by the DXF to G-code Converter (not needed in a 2-axis motion system at hand). Second, it starts a pierce by moving towards the center of a hole. Third, it rotates the torch around a small radius (.05") during preheating. The number of rotations is currently 8, but one should be able to modify this.
To run this correction script, download the coverter file - make it executable, and run it from command line. Here's Version 0.22 of vanngcode.php -  . This works based on correct understanding of G2 syntax. It also ignores arcs, and only pierces circles on their interior.
php vanngcode.php <file.ngc>
Where <file.ngc> is the name of the ngc file. The converter will eliminate Z coords and add preheating/piercing to circles.
Also, now the interior offset can be set via the command line, e.g:
php vanngcode.php input.ngc 0.3
... would offset 0.3 inches into the circle before piercing. The default offset is .2 in inch units. For small holes, such as 1/4", the value should be decreased to 0.1, which will pierce just about in the middle.
 Feed Rates
A feed rate of 10 mm/min worked well for 1/2" thick metal. The number of rotations in preheating was __________.
For 3/16" metal, the feed rate is _____ and the preheating rotation number is _______________.