Advanced V Carve

I just got my 1f, and I am using carbide create, does this still work?

I use Carbide Create and needed to split the Advanced VCarve gcode so I could do some inlays. I wrote some basic python code which worked well for me. I have copied it below. No doubt it can be improved as I am no expert!

and: Thanks to Matticustard for advice on how to post code in Markdown format

# python program to split a gcode into separate files so tools can be changed
# V1.0 6 June 2022
# Author: Jonathan Palmer 

linecount = 0
filecount = 1
print ('GCODE FILE SPLITTER')
print ('===================')
print ('The file must be in the documents folder')
name = input("Enter the gcode file name without .nc: ")
filename = name + str(filecount) + ".nc"

# the gcode command to split the file at is in the split variable here.
# this corresponds to the tool number.
split = 'T302'

writer = open(filename,'w')

# read the input file into gcodes string
with open(name + '.nc', 'r') as reader:
    gcodes = reader.readlines()

    
for codeline in gcodes:
    linecount = linecount + 1
    # write the code if it isnt a split command
    if (codeline.find(split) == -1): writer.write(codeline)
    
    # if it is a split command
    if (codeline.find(split) != -1):
            # write end lines and close file
            writer.write('M05'+ '\n')
            writer.write('M02')
            writer.close()
            print ('file ' + filename + ' closed with ' + str(linecount) + ' lines')
            #open the next file and write start lines
            filecount = filecount+1
            linecount = 0
            filename = name + str(filecount) + ".nc"
            writer= open(filename,'w')
            writer.write('G90'+ '\n')
            writer.write('G21'+'\n')
            writer.write('M05'+ '\n')
            writer.write('M0 ;T10' +'\n')
print ('file ' + filename + ' closed with ' + str(linecount) + ' lines')                        
writer.close()
print ('Processing complete')
1 Like

This forum uses Markdown. The # character at the start of a line denotes an HTML <h1 /> tag. You can use a backslash \ to escape the # character if you do not want it to behave in such a way.

But the easier way to display code is to put the whole thing inside a code block, which is surrounded by three backticks (same key as ~ on qwerty keyboards).

Type like this:

```
your code…
```

Looks like this:

your code...
2 Likes

Thanks! Much appreciated. I will edit (not to get credit but to make it easier for others).

1 Like