Macro for writing X,Y position to file

I’ve been diving into macros as a first time user of this code and have found it super interesting (and difficult).

I do a lot of slab furniture work and often times, I need to plot points for locations of cracks that I need to patch. I have been doing this manually - jogging the machine to the crack, writing down the X,Y coordinates, and plot several points in my CAD file to manually probe the location of the crack.

Ideally, I could set up one of the macro keys on my WMPG-6 (Pro5x10/EX/Centroid/CNC12) to write the current X,Y position and create a list in Notepad++. I would take that list into Rhino/Grasshopper where I would plot the points at once.

Looking around the forum, I had found an interesting thread regarding custom macros, and found it to be a great intro into how these codes work.

I thought I had found a possible solution from this thread. There is an existing macro in the “\cncm\system” folder named “probe_write_point_to_file” and I used that to rewrite “wmpgmacro4” in my macros folder for my user profile. Code below:

; Filename: probe_write_point_to_file.cnc
; Purpose: Write a point to the currently open data file
; Programmer: John Popovich
; Date: Nov 9, 2010
; Usage: G65 “/cncm/system/probe_write_point_to_file.cnc” X[x_position] Y[y_position] Z[z_position] D[skip_new_line]
; Where: x_position = x point
; y_position = y point
; z_position = z point
; skip_new_line = 1 to skip the new line
; Notes: A file must be open for output
; Copyright (C) 2011 Centroid Corporation, Howard, PA 16841

if [#24901] then M223 "%c %f " #20101 #24
if [#24902] then M223 "%c %f " #20102 #25
if [#24903] then M223 "%c %f " #20103 #26
if [#24904] then M223 "%c %f " #20104 #5044
if [#24905] then M223 "%c %f " #20105 #5045
if [#d != 1] then m223 “\n”

The macro won’t run when I have my machine on and notepad open. Is this something that will only run with a probe attached? Or am I going about this in the completely wrong way?

I have greatly appreciated all the knowledge in this forum - super inspiring!

Mahalo,

Scott

I would like to have a macro also like you describe
I had a program I ran with Mach 4 that recorded the position to a file each time I pressed the enter button on the keyboard. I could then upload that file to Vcarve and it would plot the vectors defined by the points.

I did a little research and was thinking about trying the:

M121: open data file append

M124: record machine position

I just have not had time to go any further.

Standing by

You’re on the write track here… You can open a data file and you can write the current machine position out to a file. That’s a classic digitizing workflow.

You can use something like G code ripper to take your digitized moves and turn them into DXFs that you can bring back into your CAM tool

Thanks guys, I’ll keep trying things.

One question on the code I posted above:

Does the code above rely on a probing macro to initiate? Or is this type of code able to run from the home screen when I hit the WPMG button assigned to this code? I’m having trouble deciphering the workflow in the code.

Thanks again

Ok @NLE I finally circled back to this and have it worked out.

I use the WMPG-6 controller for my machine (Pro5x10/EX/Centroid/CNC12). I’m using the “Macro4” button to write coordinates to a .txt file.

I modified “wmpgmacro4” under the “\cncm\system” folder to read below:

; Usage: G65 “/cncm/system/probe_write_point_to_file.cnc” X[x_position] Y[y_position] Z[z_position] D[skip_new_line]
; Where: x_position = x point
; y_position = y point
; z_position = z point
; skip_new_line = 1 to skip the new line
; Notes: A file must be open for output

M121 “G:\My Drive\CAD\Avid CNC\XY Coordinate Probing.txt”
M122

In order for this to work, I created a .txt file named “XY Coordinate Probing.txt” and listed the file location after M121.

This text file needs to be open when recording the points. I open this file in Notepad++ and Monitoring “tailing” needs to be activated (located under View>Monitoring (tail - f).

M122 writes the X,Y,Z position to the open text file and every subsequent press of Macro4 will record the new X,Y,Z position on the line below.

I then “save-as” this file as the probing record, and clear all the data from the “XY Coordinate Probing.txt” for the next time that I need the file.

Hope that helps (if you didn’t already do this).

thank you very much