Save as G-code

<< Click to Display Table of Contents >>

Navigation:  Conversion and Print >

Save as G-code

Ribbon:  Output -> CAD to G-code

The program allows creating a control program (CP) in the G-code file format for CNC machines. G-code files are generated directly from DWG/DXF drawings. The following entities can be converted to G-code: lines, polylines, circles, arcs, ellipses, splines, texts, multiline texts and hatch.

To convert a file to G-code use the following instruction:

1.Open a DWG/DXF file and edit it if required.

2.On the Output tab in the Conversion group select the CAD to G-code command.

3.By default all drawing contours are converted. If you do not need to convert any particular contours, open the Processing queue window and uncheck them.

4.By default ABViewer generates a control program for a milling machine. To generate G-code for a laser machine select the required machine type in the G-code settings window on the General tab.

5.Click the Convert button. G-code will be generated automatically.

6.Click the Save G-code button. In the opened window enter the output file name and click Save. The file will be saved with the NC extension.



There is a toolbar under the G-code window name:

G-code settings. Opens the G-code settings window.

Save G-code. Opens the window to save the *.nc file.

Set a start point. Sets a new start point on the selected contour. To set a point, select a contour in the preview pane. The option is available only for closed contours.

Processing queue. Enables to change the order of contour processing.

Convert to G-code. Generates a control program from the drawing in the G-code format.

Close G-code. Closes the G-code mode.


Contour selection


You can indicate the sequence in which the contours will be processed in the Processing queue window. To change the contour position use the context menu or move the contour to the required position with the mouse. Only contours selected with a check mark in the contour list will be converted.


Preview pane


The opened drawing, the workpiece zero point, the start point of the tool movement, tool direction, the tool lead in/lead out method and the tool are displayed in the preview pane. The display of elements in the preview pane can be adjusted on the Color legend tab of the G-code settings window.

The user can select the required contour by clicking on it in the preview pane. The context menu is called with the right mouse button.




The tab includes additional tool settings: tool direction, lead in/lead out method, tool radius compensation. These settings are displayed in the preview pane.


Includes a contour in the G-code precessing list.

Reverse contour

Changes tool direction from the start point along the selected contour.

Shape type

Defines a contour type.

Radius compensation

Tool radius compensation. The Off (G40) option discards tool radius compensation. The Leftward (G41) option compensates tool radius on the left of the trajectory. The Rightward (G42) option compensates tool radius on the right of the trajectory.

Lead in

Sets the tool lead in method. The user can select one of the following lead in methods: tangent, normal, arc. Changes of the lead in method are displayed in the preview pane.

To change the tool lead in direction tick the Reverse lead in checkbox.

Reverse lead in

Lead out

Sets the tool lead out method. The user can select one of the following lead out methods: tangent, normal, arc. Changes of the tool lead out method are displayed in the preview pane.

To change the tool lead out direction tick the Reverse lead out checkbox.

Reverse lead out

Tool params

The drop-down list includes the tool and its parameters. The list is completed with the data from the Tools tab of the G-code settings window.


G-code settings


The G-code settings window includes the following tabs with settings: General, Milling machine, Laser (cutting) machine, Workpiece zero point, Tools, Color legend, Advanced, Dispencer (Skyglass), GRBL.



Color legend


Additional elements that will be displayed in the preview pane are selected by checking the corresponding element in the Color legend tab. To change the element color the user needs to click the corresponding color square. After it the standard Color window in which the user can select the required color will be opened.



Code Example




Forward direction

The tool moves in the direction pointed by the arrow in the preview pane.


Both directions alternately

At first the tool moves in the pointed direction and then backwards.


Machine type

Sets the machine type: Milling/Cutting.



Sets the number of digits after the decimal point.


Drawing units

Sets drawing units.


Machine units

Sets machine units are set. If units do not coincide, they are converted.


Feed along XY

Speed of XY-direction cutting feed. If it is equal to 0, this value is ignored.


Add block numbering

Adds numbering of blocks in the control program code.



Starting number

Initial number of block numbering (default value: 5).

Step of numbering

Step of numbering.

Add program name

Adds program name to the control program code.


Show comments

Shows commentaries in the control program code.

(Layout "Model"), (Contour 0), (Contour 1)

Show percent sign (%)

Adds the sign % to the control program code.


Optimize code

Enables the code optimization - repetitive commands and coordinates are not duplicated.



Milling machine


Feed along Z

Speed of Z-direction cutting feed.


Spindle speed

Rotation frequency of the spindle.


Feed depth along Z

Depth of penetration into a workpiece.

G1 Z-2

Retract height

Shifting of the tool from the workpiece in Z-direction.

G0 Z5

Pass depth

Depth of penetration per one pass. The number of passes is calculated automatically.


Full-depth path

Feed depth for the full penetration depth.


Number of passes

The number of passes calculated on the basis of the feed-pass ratio.



Laser (cutting) machine


ON command

Command used to turn on the laser. Default value: M3.


OFF command

Command used to turn off the laser. Default value: M5.


Dwell (G4)

Delay of the program run.

G04 P100

Add power commands (M10, M11)

Turns on/off power commands.

M10 Q128/M11

Number of passes

The number of tool passes along the contour.


Laser turning off before G0

Turns off the laser before a rapid move.



Workpiece zero point


Drawing zero point

Setting the workpiece zero point.


Top left point


Top right point


Bottom left point


Bottom right point


Additional offset

Additional offset in X- and Y-directions.






Number of the tool.

T1 M6

Diameter, mm

Diameter of the tool.

Length, mm

Length of the tool.




Add program name

Adds the program name to the title.


Show percent sign (%)

Adds the special sign (%) in the beginning and in the end of the file.


Trailing zeros

Fills the coordinate with zeros taking into account the number of digits.


Show contour name

Adds a contour name.

(Contour 0)

Show layer name

Adds a layer name.


Convert an arc to lines

Uses the G1 commands instead of G2/G3.


Start at the position X0 Y0

Start from the position 0. 0.





CNC type

Selection of the CNC machine type.



Dispenser (Skyglass)


ON command

Turns on the dispensing CNC machine. Default value: M7.


OFF command

Turns off the dispensing CNC machine. Default value: M9.


Turn off the pump before

Turns off the pump in the specified number of mm before the contour end.


Straighten contour

Uses the most straight trajectory while creating a contour.


Merge points

Merges contour points in the specified radius.


Pump ON

Turns on the pump.


Pump OFF

Turns off the pump.


Go to ABViewer