G-code Visualizer: view a G-code program and step through it

Check a CNC program before you run it - step through the commands, animate the tool and simulate milling of a work piece

5 min read
In the app
  • ToolpathG-code Visualizer

The G-code Visualizer (Toolpath › G-code Visualizer) shows a CNC program as a toolpath in the viewport. Use it to check a program before it goes to a machine: step through the commands line by line, animate the tool and simulate how it mills a work piece.

To take a quick look at a program in the browser, without installing MeshInspector, use the online G-code viewer.

Open a G-code Program

  1. Click Open Files and pick the program. MeshInspector opens G-code files with the extensions .gcode, .nc and .txt; the program appears in the scene as a G-code object. You can also build a program yourself: select a mesh and run Toolpath.
  2. Select the G-code object and click Toolpath › G-code Visualizer.

Two panels open: G-code Visualizer with the program text and Simulation with the tool animation and the milling simulation.

G-code Visualizer with a 2D contour program, wolf.nc: line 11 is selected in the program list and drawn in green in the viewport; Start, End, Length and Feedrate of this move are shown under the list, the Simulation panel is open below the viewport

Step Through the Program

The G-code Visualizer panel lists the program line by line. Click a line, or click a move in the viewport, to select it: the move is drawn in the Selected Color and the tool jumps to the start of the move. Under the list you see:

  • Start and End: the coordinates where the selected move begins and ends;
  • Length: the length of the move;
  • Feedrate: the feed rate of the move;
  • Fit selected: zooms the view to the selected move.

The visualizer moves the tool for linear moves (G00, G01), arcs (G02, G03 with I, J, K or R) and the rotary axes A, B and C. It also follows the plane (G17–G19), inch or millimeter units (G20, G21), absolute or incremental coordinates (G90, G91), G28, G50/G51 and the feed rate F. Commands it does not know are ignored, but coordinates on such a line still move the tool in the last motion mode: after G01, a line G81 X20 Z-5 is drawn as a straight move, not as a drilling cycle. The rotary axes and the feed rate of rapid moves come from CNC Machine Settings.

Settings

Expand Settings at the bottom of the panel to change how the program is drawn and picked.

Parameter What it does
Line Width Thickness of the toolpath lines, 1–15 pixels.
Work Color, Selected Color, Highlighted Color Colors of the program, of the selected move and of the move under the mouse pointer.
Feedrate as Gradient Colors the moves by their feed rate instead of one Work Color.
Search Closest by Screen Picks the move closest to the pointer on the screen, so thin lines are easier to hit.
Accuracy How far from a line (1–25) a click still picks it, used with Search Closest by Screen.
Show Error Adds an Error field under Feedrate with the warning of the selected line, for example Missing parameters. or Wrong radius for an arc.

Animate the Tool

The Tool Animation section of the Simulation panel moves the tool along the program.

Parameter What it does
Show tool Shows or hides the tool in the viewport.
Tool Mesh The tool shape: Default (a simple cylinder sized to the program) or a tool from your library. Here you also create a tool or load one from a file or from a mesh in the scene, see Tool shapes.
Remove Removes the selected tool from the library.
Input Time, Formated Time The current position of the animation in seconds and as hours:minutes:seconds. Drag Input Time to scrub through the program.
Play speed Animation speed, 0.25× to 20×.
Play / Pause Starts or stops the animation from the current position.

Simulate Milling

The Milling Simulation section removes material from a work piece along the program, so you can see the part it will cut.

Milling Simulation section of the Simulation panel: Work Piece Settings, Milling Settings with Voxel Size and Movement Step, and the Mill All and Mill to Selected buttons, next to a toolpath with the tool

  1. Expand Milling Simulation.
  2. Under Work Piece Settings, check the stock. By default it is a box around the program: Work Piece Size and Work Piece Pos (its minimum corner) are taken from the program's bounding box. Turn on Visible Preview Work Piece to see it, or pick a mesh of the scene in WorkPiece Mesh.
  3. Under Milling Settings, set Voxel Size: the simulation works on a voxel grid, so a smaller size gives a finer result and takes longer. The default is 1/10 of the smallest dimension of the tool (allowed: 1/100 to 1/4 of it). Movement Step (default 3 × Voxel Size) is the distance between the tool positions the simulation samples. Work Piece Size in Voxels and Tool Size in Voxels show the resulting grid.
  4. Leave Colorize Milled on to paint the milled surfaces red.
  5. Click Mill All to run the whole program, or select a line and click Mill to Selected to stop there. The result is a new mesh <program name> milling result.

Result of Mill All: the milled work piece with the machined surfaces in red

Milling History

Click Activate Milling History to calculate the milling progress of the whole program as a voxel volume. Then:

  • Show Milling History shows or hides this progress on the work piece;
  • Real-Time (Volume Render) draws it with volume rendering and follows the animation: click Play or drag Input Time to watch the material disappear;
  • Auto Update Milling Progress (shown when Real-Time (Volume Render) is off) updates the work piece to the line you select;
  • Re-calc Milling History recalculates the progress after you change the settings;
  • Export Milling History adds a copy of the progress volume to the scene as a voxel object.

Milling History section after Activate Milling History: Re-calc Milling History, Show Milling History, Real-Time (Volume Render), Auto Update Milling Progress and Export Milling History

Good to Know

  • MeshInspector does not save G-code: Export is not available for a G-code object. Keep the original file. To keep the path as geometry, convert it with G-code to Lines.
  • To see the full volume the tool sweeps along the program, use Swept Volume.

Customize Consent Preferences

We use cookies and similar technologies, such as local storage. You will find detailed information about all of them under each consent category below.

To learn more about how Google processes personal information, visit: Google privacy policy

Always Active