# Gcode: Where is M6 - Tool change?

**URL:** <https://forum.onefinitycnc.com/t/gcode-where-is-m6-tool-change/14739>\
**Category:** Carbide Create\
**Created:** [August 16, 2022, 12:16am UTC](https://forum.onefinitycnc.com/t/gcode-where-is-m6-tool-change/14739 "2022-08-16T00:16:55Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![GeeksWoodShop](https://avatars.discourse-cdn.com/v4/letter/g/9de053/32.png) [@GeeksWoodShop](https://forum.onefinitycnc.com/u/GeeksWoodShop)\
**Post date:** [August 16, 2022, 12:16am UTC](https://forum.onefinitycnc.com/t/gcode-where-is-m6-tool-change/14739/1 "2022-08-16T00:16:55Z")

</div>

I’m pulling my hair out, what is left of it. There are some great posts in here about dealing with tool changes, or splitting the gcode into multiple files to accomodate different tools. I’m sorry if I just can’t find the right thread, but each post I read refers to the M6 command, like this one:

> [@Firmware Update 1.0.9 (12/17/21) (Outdated Firmware)](https://forum.onefinitycnc.com/t/firmware-update-1-0-9-12-17-21-outdated-firmware/8483/57):
>
> if the ‘tool-change’ field in the [General Configuration Tab](https://buildbotics.com/manual-v1-1/#generaltab) of the Onefinity Controller only contains
> 
> ```auto
> (Runs on M6, tool change)
> M0 M6 (MSG, Change Tool)
> 
> ```

I’m on the most recent firmware, in the ‘tool-change’ field of my controller, I have the new code to raise the bit, change the bit, probe for z, and resume…

However,

I’m using Carbide Create Pro, trying to do Advanced VCarves, and in all the gcode I export, it does not use M6, a tool change is written like this: with M0 ;T302 as the tool change prompt, but nowhere in the code is M6 written, and so the ‘tool-change’ code is never run. Like this:

X0.1258  
Z0.5000  
(Advanced…)  
M0 ;T302  
S20000  
G0X0.0478Y0.0367  
G1Z-0.0500F12.0  
X0.1869Y0.6574F45.0

I know the T302 is just the tool number, but I don’t know how to change the code so the firmware will recognize to run a different set of commands.

I’ve exported (Post Processor) from Carbide Create as Basic and as GRBL, I can’t find any difference, and both use T rather than M6.

I’m I just missing the point completely? Any help on how to adjust the code or the ‘tool-change’ option in the settings?

Many thanks

---

<div class="post-metadata">

**Author:** ![349iq2345](https://avatars.discourse-cdn.com/v4/letter/3/bb73d2/32.png) [@349iq2345](https://forum.onefinitycnc.com/u/349iq2345)\
**Post date:** [August 16, 2022, 12:30am UTC](https://forum.onefinitycnc.com/t/gcode-where-is-m6-tool-change/14739/2 "2022-08-16T00:30:53Z")

</div>

Hey Tyson,

from what I know there will no effect by a T command unless a M6 command is encountered.

> [@GeeksWoodShop](#):
>
> I’m using Carbide Create Pro

However in [Carbide3D → Software FAQ](https://docs.carbide3d.com/category/software-faq/) → [List of supported gcodes](https://docs.carbide3d.com/software-faq/list-of-supported-gcodes/), it says:

> M6 — Tool change — this is implemented in [Carbide Motion](https://carbide3d.com/carbidemotion/) to facilitate the Nomad tool length sensor for changing tools

where it says:

> Carbide Motion is only available for the Nomad and Shapeoko CNC machines

Maybe it is not supported?

---

<div class="post-metadata">

**Author:** ![GeeksWoodShop](https://avatars.discourse-cdn.com/v4/letter/g/9de053/32.png) [@GeeksWoodShop](https://forum.onefinitycnc.com/u/GeeksWoodShop)\
**Post date:** [August 16, 2022, 12:35am UTC](https://forum.onefinitycnc.com/t/gcode-where-is-m6-tool-change/14739/3 "2022-08-16T00:35:18Z")

</div>

Thanks!

Could be that it is not supported… any chance you (or anyone) knows if there is a code snippet I could swap out? The tool change - T command is easy to find, could it be exchanged with a comparable M6 code?

---

<div class="post-metadata">

**Author:** ![349iq2345](https://avatars.discourse-cdn.com/v4/letter/3/bb73d2/32.png) [@349iq2345](https://forum.onefinitycnc.com/u/349iq2345)\
**Post date:** [August 16, 2022, 12:56am UTC](https://forum.onefinitycnc.com/t/gcode-where-is-m6-tool-change/14739/4 "2022-08-16T00:56:52Z")

</div>

Hey Tyson,

if you manage to insert a [M6](https://linuxcnc.org/docs/html/gcode/m-code.html#mcode:m6) command into your g-code program, then the code you previously entered into the ‘tool-change’ field in the [General Configuration Tab](https://buildbotics.com/manual-v1-0/#generaltab) of the Onefinity Controller will be executed.

Regarding what to insert there, I cited some information [here the other day](https://forum.onefinitycnc.com/t/like-many-new-forums-the-excitement-and/9209/14).

I don’t have any experience with the Carbide 3D products, but they have a [forum](https://community.carbide3d.com/c/software/carbide-create/17). Maybe you ask there if there is a way to activate M6 commands in the g-code output?

---

<div class="post-metadata">

**Author:** ![GeeksWoodShop](https://avatars.discourse-cdn.com/v4/letter/g/9de053/32.png) [@GeeksWoodShop](https://forum.onefinitycnc.com/u/GeeksWoodShop)\
**Post date:** [August 16, 2022, 1:02am UTC](https://forum.onefinitycnc.com/t/gcode-where-is-m6-tool-change/14739/5 "2022-08-16T01:02:25Z")

</div>

Thanks @349iq2345

Ya, I’ll head over there shortly, I found the code snippets here first, so thought I’d start here. I didn’t mean to call you out directly by quoting your earlier post, but it was a good example, so thanks for that.

---

<div class="post-metadata">

**Author:** ![GeeksWoodShop](https://avatars.discourse-cdn.com/v4/letter/g/9de053/32.png) [@GeeksWoodShop](https://forum.onefinitycnc.com/u/GeeksWoodShop)\
**Post date:** [August 16, 2022, 3:24am UTC](https://forum.onefinitycnc.com/t/gcode-where-is-m6-tool-change/14739/6 "2022-08-16T03:24:07Z")

</div>

I did wander over to the Carbide Create forums, but thankfully a bit of trial and error showed that it’s a simple code swap. In code like I shared above, replace:

M0 ;T302

with

M6 T302

(302 is just the tool number, so it will vary based on the bit you’ve specified) So ya, swap the M0 for M6 and remove the semi-colon. I’m guessing this is obvious for someone who knows gcode.

As referenced, I think it’s also helpful to add one line to the default tool-changer macro to raise the router higher, as [explained in this thread:](https://forum.onefinitycnc.com/t/like-many-new-forums-the-excitement-and/9209/14)

G0Z100

---

<div class="post-metadata">

**Author:** ![349iq2345](https://avatars.discourse-cdn.com/v4/letter/3/bb73d2/32.png) [@349iq2345](https://forum.onefinitycnc.com/u/349iq2345)\
**Post date:** [August 16, 2022, 4:21am UTC](https://forum.onefinitycnc.com/t/gcode-where-is-m6-tool-change/14739/7 "2022-08-16T04:21:00Z")

</div>

Hey Tyson,

yes this was already clear, but you did not find an option in the Carbide Create program on how to enable M6 being inserted by the program?

---

<div class="post-metadata">

**Author:** ![GeeksWoodShop](https://avatars.discourse-cdn.com/v4/letter/g/9de053/32.png) [@GeeksWoodShop](https://forum.onefinitycnc.com/u/GeeksWoodShop)\
**Post date:** [August 16, 2022, 1:24pm UTC](https://forum.onefinitycnc.com/t/gcode-where-is-m6-tool-change/14739/8 "2022-08-16T13:24:21Z")

</div>

No luck or responses over in those forums, and once I posted my found solution, the thread was closed by an admin.

---

<div class="post-metadata">

**Author:** ![349iq2345](https://avatars.discourse-cdn.com/v4/letter/3/bb73d2/32.png) [@349iq2345](https://forum.onefinitycnc.com/u/349iq2345)\
**Post date:** [August 16, 2022, 7:42pm UTC](https://forum.onefinitycnc.com/t/gcode-where-is-m6-tool-change/14739/9 "2022-08-16T19:42:21Z")

</div>

Hey Tyson,

> [@GeeksWoodShop](#):
>
> No luck or responses over in those forums, and once I posted my found solution, the thread was closed by an admin.

Aw.

I wouldn’t consider having to edit every g-code file manually really a solution. Maybe you should not have posted your “solution”. Now the question if there is a way to enable M6 commands being inserted into the g-code output by Carbide Create remains unanswered.

---

<div class="post-metadata">

**Author:** ![DaveInTexas](https://avatars.discourse-cdn.com/v4/letter/d/e274bd/32.png) [@DaveInTexas](https://forum.onefinitycnc.com/u/DaveInTexas)\
**Post date:** [January 19, 2023, 2:07am UTC](https://forum.onefinitycnc.com/t/gcode-where-is-m6-tool-change/14739/10 "2023-01-19T02:07:29Z")

</div>

Hi,  
Mac user here running Carbide Create Pro. I too have struggled with handling GCode files for Advanced VCarves. I know there was a Website shared that would separate the files. I don’t have Web access in my shop, so wrote a quick Python script to split an AVC file:

= = = = = =

import sys  
print sys.argv[1]  
origFile = sys.argv[1]

fd = open(origFile, “r”)  
lines = fd.readlines();  
fd.close()

clearingName = origFile[0:-3] + “\_125\_clearing.nc”  
f1 = open(clearingName, “w”)  
vcarveName = origFile[0:-3] + “\_60\_vbit.nc”  
f2 = open(vcarveName, “w”)

activeFile = “both”  
for line in lines:  
if line[0:4] == “M0 ;”:  
if activeFile == “both”:  
activeFile = “one”  
elif activeFile == “one”:  
f1.write(“M05\n”)  
f1.write(“M02\n”)  
f1.close()  
activeFile = “two”  
if activeFile == “both”:  
f1.write(line)  
f2.write(line)  
if activeFile == “one”:  
f1.write (line)  
if activeFile == “two”:  
f2.write(line)

f2.close()

= = = = = =

Named it avc\_split.py – put a little script (called avc) in my GCode directory to save some typing:

python avc\_split.py $1

Just pass the combined AVC toolpath file … it will split it into two files for the clearing and VCarve portions. Since I typically use a 1/8" clearing bit and 60 degree V bit, I put those in the file names. Obviously, you can modify the script for your situation.

Dave

---

<div class="post-metadata">

**Author:** ![DaveInTexas](https://avatars.discourse-cdn.com/v4/letter/d/e274bd/32.png) [@DaveInTexas](https://forum.onefinitycnc.com/u/DaveInTexas)\
**Post date:** [January 19, 2023, 6:51pm UTC](https://forum.onefinitycnc.com/t/gcode-where-is-m6-tool-change/14739/11 "2023-01-19T18:51:44Z")

</div>

Sorry … didn’t realize the tabs would get eliminated. Have substituted blanks for tabs to properly show the indentation:

import sys  
print sys.argv[1]  
origFile = sys.argv[1]

fd = open(origFile, “r”)  
lines = fd.readlines();  
fd.close()

clearingName = origFile[0:-3] + “\_125\_clearing.nc”  
f1 = open(clearingName, “w”)  
vcarveName = origFile[0:-3] + “\_60\_vbit.nc”  
f2 = open(vcarveName, “w”)

activeFile = “both”  
for line in lines:  
if line[0:4] == “M0 ;”:  
if activeFile == “both”:  
activeFile = “one”  
elif activeFile == “one”:  
f1.write(“M05\n”)  
f1.write(“M02\n”)  
f1.close()  
activeFile = “two”  
if activeFile == “both”:  
f1.write(line)  
f2.write(line)  
if activeFile == “one”:  
f1.write (line)  
if activeFile == “two”:  
f2.write(line)

f2.close()

---

<div class="post-metadata">

**Author:** ![349iq2345](https://avatars.discourse-cdn.com/v4/letter/3/bb73d2/32.png) [@349iq2345](https://forum.onefinitycnc.com/u/349iq2345)\
**Post date:** [January 19, 2023, 7:01pm UTC](https://forum.onefinitycnc.com/t/gcode-where-is-m6-tool-change/14739/12 "2023-01-19T19:01:55Z")

</div>

Hey Dave,

> [@DaveInTexas](#):
>
> Sorry … didn’t realize the tabs would get eliminated. Have substituted blanks for tabs to properly show the indentation:
> 
> import sys  
> print sys.argv[1]  
> origFile = sys.argv[1]
> 
> fd = open(origFile, “r”)  
> lines = fd.readlines();  
> fd.close()
> 
> clearingName = origFile[0:-3] + “\_125\_clearing.nc”  
> f1 = open(clearingName, “w”)  
> vcarveName = origFile[0:-3] + “\_60\_vbit.nc”  
> f2 = open(vcarveName, “w”)
> 
> activeFile = “both”  
> for line in lines:  
> if line[0:4] == “M0 ;”:  
> if activeFile == “both”:  
> activeFile = “one”  
> elif activeFile == “one”:  
> f1.write(“M05\n”)  
> f1.write(“M02\n”)  
> f1.close()  
> activeFile = “two”  
> if activeFile == “both”:  
> f1.write(line)  
> f2.write(line)  
> if activeFile == “one”:  
> f1.write (line)  
> if activeFile == “two”:  
> f2.write(line)
> 
> f2.close()

this [discourse.org](http://discourse.org) forum uses [Markdown](https://en.wikipedia.org/wiki/Markdown) markup language.

Since when writing python, reproduction of whitespace indentation is mandatory, you might be interested in this:

- [Syntax highlighting in markdown](https://support.codebasehq.com/articles/tips-tricks/syntax-highlighting-in-markdown)

---

<div class="post-metadata">

**Author:** ![DaveInTexas](https://avatars.discourse-cdn.com/v4/letter/d/e274bd/32.png) [@DaveInTexas](https://forum.onefinitycnc.com/u/DaveInTexas)\
**Post date:** [January 20, 2023, 12:14am UTC](https://forum.onefinitycnc.com/t/gcode-where-is-m6-tool-change/14739/13 "2023-01-20T00:14:04Z")

</div>

```python
import sys
print sys.argv[1]
origFile = sys.argv[1]

fd = open(origFile, "r")
lines = fd.readlines();
fd.close()

clearingName = origFile[0:-3] + "_125_clearing.nc"
f1 = open(clearingName, "w")
vcarveName = origFile[0:-3] + "_60_vbit.nc"
f2 = open(vcarveName, "w")

activeFile = "both"
for line in lines:
        if line[0:4] == "M0 ;":
        if activeFile == "both":
            activeFile = "one"
        elif activeFile == "one":
            f1.write("M05\n")
            f1.write("M02\n")
            f1.close()
            activeFile = "two"
    if activeFile == "both":
        f1.write(line)
        f2.write(line)
    if activeFile == "one":
        f1.write (line)
    if activeFile == "two":
        f2.write(line)

f2.close()

```

@349iq2345 – Thanks for the heads up!

---

<div class="post-metadata">

**Author:** ![RailLife365](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.onefinitycnc.com/raillife365/32/33522_2.png) [@RailLife365](https://forum.onefinitycnc.com/u/RailLife365)\
**Post date:** [April 12, 2026, 6:28pm UTC](https://forum.onefinitycnc.com/t/gcode-where-is-m6-tool-change/14739/14 "2026-04-12T18:28:58Z")

</div>

I know this is an old thread, but [this post](https://forum.onefinitycnc.com/t/carbide-create-pro-post-processor-for-onefinity-m6-tool-change/37317) seems to claim to solve the lack of an M06 command issue with Carbide Create. I can’t add much more information than this as I haven’t figured out how to utilize the script yet.

_However_, I do know that this website: [NC Viewer](https://ncviewer.com/) , works really well for editing GCode. I’ve been using it to find and replace any “M0” codes with “M06”, and remove the “;” symbol before the tool designation. It’s also handy to be able to add some notes in place of the toolpath names at the beginning.

---

<div class="post-metadata">

**Author:** ![joejk](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@joejk](https://forum.onefinitycnc.com/u/joejk)\
**Post date:** [April 14, 2026, 1:28am UTC](https://forum.onefinitycnc.com/t/gcode-where-is-m6-tool-change/14739/15 "2026-04-14T01:28:53Z")

</div>

I have been programing industrial machines with Gcode since the late 80’s and a MO is used to stop the program. The semi colon character “;” should not be used in normal Gcode but can be used in between “( )” only. Now the Masso controller is the software that uses this kind of code. I don’t know what the other style software controllers uses for sure, never used them before. As far as a tool change goes you call up a tool number followed by the M6 and this will activate a tool change.

If you look up the in the manual about the codes available for your controller, it should explain the different codes used in the software of the controller.
