How to Convert DWG to G-Code

Convert DWG to G-code

If you are a regular user of machining tools and 3D printers, you may already know that they cannot read or interpret the DWG file format. This is despite the fact that DWG is a popular format used in the computer-aided design (CAD) and computer-aided manufacturing (CAM) worlds. In fact, it is the native file format of one of the most popular software products. But given the inability of CNC routers and 3D printers to read this format, it is necessary to convert DWG to G-code. This article explores how to complete a DWG to G-code conversion and how to do it with accurate scaling.

What is a DWG File Format?

History of DWG

Maintained and updated by Autodesk, the DWG file format is a popular vector file format used as the default file format in the AutoCAD software. Unfortunately, it is a proprietary file format whose specifications Autodesk always guards, much to the chagrin of some developers and players in the CAD industry. The ensuing disagreements have even resulted in some legal battles. To use the DWG format, developers must pay license fees, which gives them access to the RealDWG library, or reverse engineer the format. 

The RealDWG library gives the developers access to code developed by Autodesk, which enables their respective software to read and write DWG. It is noteworthy that Autodesk previously sought to trademark the DWG file format but failed, because it is widely used by other CAD software companies. In order to protect or dissuade reverse engineering, AutoCAD displays an error message notifying users when a DWG file has been created by unauthorized software, i.e., one that does not use the RealDWG toolset.  

Despite the proprietary status as well as the efforts made to close off the software, however, Autodesk was not the format’s original designer. Instead, the DWG format was developed by Mike Riddle, a programmer behind the Interact CAD software, in the 1970s. The Interact program would eventually form the basis for creating the first version of AutoCAD. Autodesk later bought the royalty rights to DWG in the early 1980s, making it the de facto owner of the format. (More on this in our round-up of 7 things you need to know about DWG files.)

About DWG

DWG, an abridged version of the word Drawing, is a binary format that stores 2D and 3D data and metadata using a cluster of zeros and ones. The use of binary makes it hard to read the data stored therein, but it is advantageous because it minimizes the file size. This is particularly evident when compared to the alternative ASCII format. 

Typically, a DWG file comprises several sections, namely:

  • Header: it identifies the DWG format version, default units and styles used, coordinate systems, drawing size limits, date and time of creation or modification, and more
  • Classes: They contain information about application-defined or custom objects that appear in other sections
  • Objects: These include graphical objects such as lines, circles, vertices, shapes, and splines, just to mention a few, as well as non-graphical objects, including settings and dictionaries that facilitate the drawing and rendering functions of the software
  • Handles or object maps: They detail the location of each object in the file

Uses of DWG

DWG is primarily used for the following:

  • To create 2D drawings and 3D models
  • Rendering 2D designs and 3D models. 
  • Collaboration; this is aided by the fact that multiple other CAD applications, besides AutoCAD, support DWG

There are plenty of reasons why people convert files into DWG, from collaboration and quality to vectorizing sketches. However, DWG is not always ideal in all 2D and 3D modeling/design scenarios, with one such scenario being 3D printing. This is why it is important to convert DWG to G-code.

What is G-code?

G-code is a computer numerical control (CNC) programming language. It is generated by applications known as 3D slicers or CAM software. In addition, you can use conversion programs such as Scan2CAD to convert DWG to G-code or DXF to G-code. Alternatively, you can write G-code from scratch, provided you have prior knowledge of what it entails. The code is then stored in files using extensions such as .gcode, .mpt, .nc, .cnc, .tap, .mpf, and many others.

At its core, G-code is primarily used to control CNC machines, milling and cutting tools (in conjunction with CAM software), or 3D printers. G-code controls these machines or devices because it is simply a collection of commands and instructions that specify the movement of the machines’ motors along the three-dimensional planes that make up the cartesian coordinate system. 

When it comes to 3D printing, the G-code contains instructions covering several parameters. For instance, given that 3D printing involves extruding a molten material (thermoplastic), whose temperature must fall within a given range, the G-code must contain a temperature specification. Additionally, the code must detail the speed of movement, the thickness of the walls, infill patterns and more. 

Similarly, CNC machines, which use cutting tools or routers, must follow precise steps in order to avoid wastage that comes with mistakes. These steps should be concretized in the G-code and must detail the movements the cutting tool must take along the various axes.

Given the myriad considerations that go into creating a 3D object through 3D printing or CNC machining, software applications are preferred when creating G-code. For one, they simplify the process. Secondly, they promote accuracy.

Why Convert from DWG to G-code?

As stated, Autodesk has previously made attempts to stonewall the usage of the DWG format. But unfortunately, this means that only a handful of software applications can read and write DWG files using Autodesk’s RealDWG code. It, therefore, goes without saying that 3D printers or CNC routers would not be equipped with the capability to read DWG. But this is not even the main reason.

By default, CNC routers and 3D printers are designed to only read G-code; they cannot read file formats such as DWG or DXF. To get around this issue, you must first convert DWG to G-code. The need to convert to G-code also applies to other file formats such as OBJ and STL, two of the most common formats in 3D printing. It is also applicable in cases where the manufacturers of 3D printers list raster input files such as BMP, PNG, or JPEG. Such 3D printers rely on built-in slicing software such as Ultimaker Cura that converts the raster formats into G-code. This explains why you will likely encounter G or Gx as the output file format. However, given that these raster formats mainly store 2D images, the printer will not print the file’s content as a 3D object. 

2D Image Printed Using a 3D Printer

2D Image Printed Using a 3D Printer (source)

How to Convert DWG Files to G-code

Scan2CAD is a leading conversion software that enables you to, among others, convert DWG to G-code. This capability is anchored in the fact that Scan2CAD can read the DWG file format. Secondly, it supports a number of G-code file extensions, namely .tap, .cnc, and .nc. This implies that you can save the converted file using any of these file extensions. 

The process of converting DWG files to G-code using Scan2CAD is relatively straightforward. For one, you do not have to create or make any changes to the drawing as that is the reserve of software such as AutoCAD, which you can use to create the drawing. Secondly, DWG is a vector file format, meaning you do not have to convert it from raster to vector in a process known as vectorization. (Scan2CAD enables you to convert raster file formats such as JPG, BMP, TIFF, PNG, and raster PDFs to various vector formats such as DXF and DWG.)

To convert DWG to G-code with Scan2CAD, follow the procedure below:

  1.  Launch Scan2CAD 
  2. Click the Open a file button to import the DWG file
    Doing so will open the file explorer, enabling you to browse to the location of the file – click Open to import the file into Scan2CAD. As you will observe, Scan2CAD will automatically categorize the drawing as a vector file – you can check this by looking at the title of the tab containing the drawing.
  3. Click the Export button to convert the file to G-code
  4. Save the G-code file
    On the Save vector to file window, enter your preferred file name and then choose one of the three G-code file formats, i.e., .cnc, .nc., or .tap, from the Save as type drop-down menu. Finally, click Save to finalize the DWG to G-code conversion.

We have also prepared a video to help you easily convert to G-code.

Importance of Converting DWG to G-code with Accurate Scaling

Scan2CAD not only enables you to convert DWG to G-code, but also offers additional tools that ensure you could do so with great accuracy. The scale of the model is a prime consideration when it comes to CNC machining and 3D printing. This is because you only get one chance to do everything right. Failure to do it correctly on the first try will end up being a big waste of time, resources, and money. If you cut or print a component that is smaller or larger than the desired size, for example, you might have to redo everything from scratch. 

This is why Scan2CAD enables you to convert DWG to G-code with accurate scaling. This feature lets you maintain the original scale of the drawing or model in the DWG file even after converting to G-code. Scan2CAD achieves this using a reference dimension or line in DWG drawing. 

Scan2CAD lets you measure the length of a particular line, whose actual length you know, using built-in measurement tools. Next, Scan2CAD requires you to stipulate what the measured length – which is measured in terms of pixels – equals. This means you have to physically input the actual length of the line, which tells Scan2CAD what the drawing’s actual scale is. 

How to Convert DWG to G-code with Accurate Scaling: Step-by-Step Guide

To convert DWG to G-code with accurate scaling, follow the procedure below:


  1. Launch Scan2CAD
    Measure and Scale Section on Scan2CAD

    Measure and Scale Section on Scan2CAD

  2. Import the DWG file by clicking the Open a file button
  3. Delete unnecessary elements from the DWG file, such as dimensions
    However, ensure that you do not delete all the lines, instead leaving a single line to be used as the reference line
  4. Click the File tab
    On the resulting drop-down menu, click on Scale Options, which displays the Scale Options window. Here, you can change the drawing’s unit of measurement. 
  5. Click Measure to measure the dimension of the reference line
    For added accuracy, check the Snap to Endpoints box under the Measure & Scale section. Next, drag the cursor along the reference line from the start to the endpoint to enable Scan2CAD to measure the line’s length. Notably, the software measures the length in terms of the number of pixels. To set the scale, input the actual size of the line in the Is equal to box.
  6. Finally, click Calibrate to set the scale
  7. Export the file to finish the DWG to G-code conversion

You can check out our video on how to convert to G-code with accurate scaling.


A leading conversion software, Scan2CAD enables you to convert DWG to G-code. This conversion process solves a fundamental challenge that can be found in all CNC routers and 3D printers: they cannot read or interpret DWG files. Scan2CAD also goes a step further by promoting accuracy. It achieves this by enabling you to convert DWG to G-code with accurate scaling. Specifically, the software lets you measure the length of a reference line and subsequently stipulate its actual size based on the dimension indicated in the drawing. 

scan2cad advert for free trial