MecSoft Blog Part 2
PART 2 CONTENTS:
Editor’s Notes:
About this Tutorial
In Part 1 of this tutorial we covered G-Code Editor basics, typical workflow, quick editing, and how cutting tools are used by the editor. In Part 2 below we will cover g-code analysis and more advanced editing. If you are unfamiliar with g-code I recommend that you go back to Part 1 of this tutorial and review the sections What is G-Code and What is a G-Code Editor before continuing.
About G-Code Editor
G-Code Editor is a new software module included with MecSoft’s desktop CAM plug-ins including VisualCAD/CAM, RhinoCAM, VisualCAM for SOLIDWORKS and AlibreCAM. The G-Code Editor module is available free of charge to all McSoft users who are active on their Annual Maintenance Subscription (AMS)! Plus, there is no added software to download and install. As long as your AMS subscription has not expired the G-Code Editor will appear as an added module on your CAM Main Menu!
To see this tutorial and more, watch the full-length video here!

G-Code Analysis
The G-Code Editor module includes tools for visualizing, analyzing and simulating your g-code files. You may be asking “But I can do this in the MecSoft CAM MILL module, right?” In the MILL module you are creating and visualizing toolpaths but not g-code. The actual g-code is not created until you post-process your toolpaths. During post-processing your toolpaths are converted into g-code files that are formatted specifically for your CNC machine’s controller software. In the G-Code Editor module you are looking at the actual g-code that your CNC machine is reading.
A “backplot” of a g-code file is the visual representation of the toolpaths that are defined by the g-code file. The backplot will display the entry, approach, engage, cut, departure and retract motions. A backplot is displayed automatically when you load a g-code file into the G-Code Editor. Here are the basic steps:
1. In our example part we have programmed several 2½ Axis and Hole Making toolpaths using the MILL module in RhinoCAM. Below is how the part and Machining Job tree looks in RhinoCAM-MILL.

2. Here is a closeup of the Machining Job tree:

3. From the RhinoCAM Main Menu we select G-CODE EDITOR and the G-Code Editor Browser displays on the left side of the screen by default. As in all MecSoft CAM modules you can dock or undock the browser to any location on the screen that you wish.

4. From the Project tab of the G-Code Editor Browser we select Load.

5. We navigate to the folder where our g-code files are located, select the g-code file for the first operation in the machining job named “Part1_2 1_2 Axis Facing.nc” and pick Open. The g-code file is listed in the Project tree along with a list of the cutting tools that the file references.

The flag next to Tool #7 in the Project tree indicates that the tool was not found in the Tool Crib. Refer to the topic How Cutting Tools are Used located in Part 1 of this tutorial.
6. A backplot of the g-code is also displayed on the screen as shown below.
It is important to note that you DO NOT have to have part geometry loaded in order to view and/or edit g-code files in the G-Code Editor. We are showing the part geometry here because this is the part we used to create the original toolpaths and g-code files.

7. You can change the backplot colors from the G-Code Editor Preferences dialog. Select the Preferences icon
to display the Preferences dialog and navigate to the Toolpath section as shown below. From here you can also control the display thickness of the back plot and set other toolpath related preferences.


8. To view tool motions, right-click on the g-code file in the Project tree and pick Edit to load the g-code file into the Edit tab. Alternatively you can just double-left-click on the g-code file.

Note: If you have not yet loaded a Tool Library and defined your Tool Crib, a message will appear asking if you want to use a default tool. As you can see from the Project tree above, there is no flag on Tool #7. This indicates that we have loaded our Tool Library and Tool Crib and that the actual tool will be used.
9. As you move the cursor down the g-code file the tool will display on the toolpath backplot indicating the exact location of the tool at that line of code.

Estimating Machining Time
You can get an estimate of the machining time that will be required to run the g-code file. There are also feed rate related preferences that you can set that will affect the estimated machining time. Here are the basic steps:
1. From the Project tree, right-click on the g-code file and select Info.

2. From the Information dialog you can Print the report if needed.

3. See Backplots & Tool Motions, Step 7 above to locate the Preferences dialog that affect machining time estimates.
Simulating Stock Removal
You can define a stock model in the G-Code Editor. If stock is defined when you simulate a g-code file the backplot will display the cut material removal at each Step in the simulation. Here are the basic steps.
1. After loading a g-code file, from the Project tab, dropdown the Stock menu and select the type of stock to create.

2. In our example a cylinder stock is used and from the dialog we select Z Axis, Copy Model Bounding Box and then add some distance to the Length and then pick OK. The stock model will display on the backplot.


3. Now, right-click on the g-code file and pick Simulate. The g-code file is loaded into the Simulate tab and the simulation will run to the end of the g-code file showing the cut material at each line in the g-code file.

4. To see an incremental cut removal repeatedly select the Step icon from the Simulate tab to see the tool location and cut removal at each increment.

5. To adjust the step increment, from the Simulate tab select Preferences and adjust the Simulation Mode settings shown below.

Editing Your G-Code
In Part 1 of this tutorial we discussed how easy it is to make quick edits to your g-code files using the G-Code Editor. In this section we’ll discuss how to make some more advanced edits to one or more g-code files.
Editing Multiple G-Code Files
Sometimes you may want to combine multiple g-code files into one file. For example if you have two g-code files that use the same tool you may want to merge them into one file. This can be done in the G-Code Editor. Here are the basic steps.
1. In our example you will notice that we have two g-code files that use Tool #3. From the Project tab we load each g-code file in the order that we want them combined. Our Project tree and backplot now looks like this:


2. While pressing the <Ctrl> key select the two files that you want to combine and then pick Merge Files from the Project tab menu.

3. You see that only the first file remains, it is selected and that it is now flagged.

4. Now right-click on the selected file pick Edit to load it into the Edit tab.

5. Now we just need to delete the end block from the first file and the start block from the second file as well as a few additional lines. The lines we deleted are indicated below:

6. Our g-code file now looks like this:

7. With our edits complete we select the Back icon to return to the Project tab.

8. From here we select Save from the Project tab to save the file. Note that you are saving over the existing g-code file!

Searching your G-Code
The G-Code Editor allows you to search your g-code file for specific locations. These include Top, Bottom, Next Tool Change, Next Spindle Change and Next Feed Rate Change. These search commands are located on the right-click menu from the Edit tab as shown below.

You can also perform transformations and XYZ Instancing of your g-code file. These options are available from the Project tab. These functions are similar to merging two g-code files (see Editing Multiple G-Code Files above). Here are the basic steps to perform an XY instance of a single g-code file.
1. Load the g-code file into the G-Code Editor from the Project tab and select it.


2. From the Project tab select XY Instance to display the dialog.

3. We will be creating one additional instance of the g-code file so we will set the following parameters and then pick OK.
Method: Spaced
Order: X First
X Spacing: 8
Y Spacing: 0
# in X: 1
# in Y: 1
4. Our backplot now looks like this:

5. You see that the g-code file is now flagged as being edited. Right-click on the g-code file and select Edit or just double-left-click on the file to load it into the Edit tab.

6. We’ll scroll down to where the XY instance begins and delete a few lines of g-code as shown below:

7. The g-code now looks like this and we’ll select the Back to project icon to return to the project tab.

8. From here we select Save from the Project tab to save the file. Note that you are saving over the existing g-code file!

Let’s Review
Let’s take a moment to review what we have learned in Part 2 of this tutorial: Click here to review Using the G-Code Editor in MecSoft CAM Part 1.
- How to get the G-Code Editor: We learned about the G-Code Editor module, part of MecSoft’s desktop CAM plug-ins including VisualCAD/CAM, RhinoCAM, VisualCAM for SOLIDWORKS and AlibreCAM. We learned that as long as your Annual Maintenance Subscription (AMS) is active, this module is yours to use free of charge.
- G-Code Analysis: You can view back plots of your g-code files and analyze tool motions. You can get an estimate of the machining time required to run your g-code files. You can also perform a visual simulation of cut material stock being removed during simulations.
- G-Code Editing: You can also load multiple g-code files into the project and then merge two or more g-code files together if needed. You can also search your g-code for Tool, Spindle and Feed Rate changes. You can also perform transformations of your g-code as well as XYZ instancing of g-code within the same file.
More Resources
Want to learn more about the G-Code Editor module in MecSoft’s desktop CAM plug-ins? Check out some of these resources: