Convert milling path for etching

I am playing with the TopoMiller output. I am trying different tool paths and bits along the way.
I had been using the Scallop path operation but I did not like some of the tool marks.

I changed to a Ramp operation, since it gives an elevation cut feel, I still have not cut one yet.
I was looking at the path from straight down and found the path makes a great Topo representation. It looks so good, I want to make an etching from the path, but I need to change all the Z values to zero (accept for the retracts).

Does anyone know how to do this ?

2 Likes

G-code isn’t too terrible to work with manually. You may be able to change them yourself with vscode or something. I’d highly recommend running any changed code through a simulator for a warm fuzzy feeling.

If you want to share the file I’d be interested in taking a look. An interesting idea for sure.

I am using the Top of Stock as my zero point.
You could reset any negative Z value to zero.

In the longer term you could enter a min and max z value that should be reset to Z0.
That way you could use a bottom of stock origin, I think…

TestResetZValue.nc (1.6 MB)

1 Like

That file does not have full retract, so retracts are probably buried in the paths and you would never find them.

TestResetZValueFullREetract.nc (1.6 MB)

1 Like

This has been pretty fun little AI test so far. Getting the tool paths flattened is straightforward enough and detecting loops is working fairly well.
The issue I’m running into at this point is the pesky transitions from one tool path to another from the original 3d. These lead ins and lead outs are harder to automagically detect than I would have thought.

No guarantees I’ll come up with anything but if I do, I’ll share it. The best bet for a real solution is to ask the topo folks for a feature to output these natively :smiley:
I bet it’s pretty darn close to the logic used for laser tool path generation :thinking:

Good points.

I removed the lead in/out and changed Helix to a Plunge with a clearance height of 1"

Test3ResetZValue.nc (1.4 MB)

Good Hunting.

1 Like

Since gcode is modal, you could open the file in excel, set the first plunge to Z0, and parse the remaining Z parameters out and delete them. Resave the file as text and it should be flat. My Excel is currently running a Gcode modification which may take an hour. When done, I could mess with your file. Let me know. Cheers.

Edit: A quick look and I see the difficulty with my initial thought. However I do see G0Z0.2, isnt that the retracts?

Feel free to take a stab at it.

The current “Test3” file looks like this in ncviewer.
I can see a short cut lines connecting the retracts to the cut paths.

If I can remove that line, it will create a cleaner result ( no duplicate points ).

This one might be okay.
Test3ResetZValueFlat.nc (1.5 MB)

1 Like

Here’s a better one. I had to zero out the Safe distance in the Links tab.

Test4ResetZValue.nc (1.4 MB)

1 Like

Not 100% sure what I am looking at but the file I posted has minimal movements in Z remaining other than Z0.2. Can you view it in something like NC Corrector and let me know what needs modified?

What software are you using to view this?

Oops, I need to read a message completely.

The file looks pretty darn good in ncviewer.
I need to get a feel for the changes ( text wise ).

FYI, I did that entirely manual in Excel but you have an image looking straight down. I suspect it could be imported into CC direct. Cheers.

That will one of tomorrows task. I will air run it, if CM accepts the file.
I don’t see why not.

Thanks for the effort !

I just compared the two files.
The differences are limited to some whitespace added to the end of most records.
The record count is identical.

The “Test4” file would eliminate a duplicate point in the nc file.

Awesome.

1 Like

I got into a squirrel action regarding this effort, so I wrote a windows batch file.
As I got going and remembered why I hated writing batch files at work.
I just downloaded Python and will go again.
So after 6 days of hacking away I got this to work with the following limitations.

The program writes the output file as it reads the input file.
It is SLOW !!!

The program assumes you used Top of stock so all cutting codes are Z- .
The data must have spaces between the values

G0 X16.3438 Y0.0404
Z0.6
G0 Z0.2486
G1 Z0.243 F80
X16.3441 Y0.0409 Z0.2375

Codes supported:
G0 and G1

G2 and G3 minimal testing.

Blank lines are ignored,
The reported line numbers will be incorrect by the number of blank lines encountered.

Comment lines are kept ( and %

Control C will stop the batch file.

Unzip the file and remove the .txt file extension
parseNC.bat.zip (1.4 KB)

Example:

C:\Projects\gCode>parsenc
Please enter the Input filename: testg3.nc
You entered: testg3.nc
The file "testg3.nc" exists.
Please enter the Output filename: testme.nc
You entered: testme.nc
The file "testme.nc" will be created.
Reading "testg3.nc" line by line: 21:44:57.58
---------------------------------
replace Z Code Z-0.7491 with "Z0" line 22
replace Z Code Z-0.7813 with "Z0" line 23
replace Z Code Z-0.8075 with "Z0" line 24
replace Z Code Z-0.8114 with "Z0" line 25
replace Z Code Z-0.8152 with "Z0" line 26
replace Z Code Z-0.8188 with "Z0" line 27
replace Z Code Z-0.8222 with "Z0" line 28
replace Z Code Z-0.8252 with "Z0" line 29
replace Z Code Z-0.8277 with "Z0" line 30
replace Z Code Z-0.8298 with "Z0" line 31
replace Z Code Z-0.8313 with "Z0" line 32
replace Z Code Z-0.8322 with "Z0" line 33
replace Z Code Z-0.8325 with "Z0" line 34
^C^C^CTerminate batch job (Y/N)? y

I think this will work converting Ramp like passes into a Topographic like etching paths.

So you’re changing all the negative Z values to 0.0

Couldn’t this be done with a simple Replace command in a text editor?

Find: Z-\d+(.\d{1,4})?
Replace With: Z0.0

Yep, but I took off in the batch script direction just because.

Grep is awesome if you know it.

You are correct and a whole lot more efficient !

1 Like

I used to be a grep (re) expert, 35+ years ago. I had to google that one. Although I did recognize it once I saw it.

You would still get some redundant G0 Z0.0 followed by G1 Z0.0 lines, but they don’t hurt anything.

1 Like

I am still going to make a python version. I would like to be able to set a “base” Z value instead of assuming 0. Batch files do not allow floating point math.

All part of the retired guy re-education.

Thanks !!

1 Like