Export current coordinates

Posted:
Mon Oct 04, 2021 7:01 pm
by Mcasey
Hey guys, I am currently trying to make a macro to export the current coordinates to a text file, Is this possible? I cant find any information on exporting code from uccnc.
Re: Export current coordinates

Posted:
Mon Oct 04, 2021 10:29 pm
by eabrust
http://www.forum.cncdrive.com/viewtopic.php?f=11&t=637&hilit=system.ioThe link gives a blip of code on how to write to a text file, sending out string/text. But you can convert any DROs, etc values to text to dump to a file.
What exactly do you mean by 'current coordinates' that you want to export? The current x/y/z DRO position values, the current GCode block, or something else?
regards
Eric
Re: Export current coordinates

Posted:
Tue Oct 05, 2021 7:28 am
by Mcasey
Thanks Eric, the current x/y/z DRO position values is exactly what I'm trying to export, I just want to move to a point and then record the position move again, record and so on and then be able to replay the movements. Currently I just write this down manually into a text file and then replay as gcode but it's very time consuming
Re: Export current coordinates

Posted:
Tue Oct 05, 2021 11:47 am
by eabrust
Super quick and dirty, you have to manually define full path/file name for the file to record.
put it in a Mxxxxx.txt file in macros, and run that M number to record the current point to file.
- Code: Select all
#vb
' save file path location w/ existing folder , includes filename in path
dim fname as string = "c:\uccnc2114\test.txt" ' <- change this as necessary
' What you want to write each time you execute macro
dim texttowrite as string
texttowrite = "X" & exec.getxpos & " Y" & exec.getypos & " Z" & exec.getzpos '<- x/y/z pos, w/ leading axis letter
using sw as system.IO.StreamWriter = System.IO.File.appendtext(fname)
sw.writeline(texttowrite) ' <- write to the file, appending line at end.
end using
Re: Export current coordinates

Posted:
Mon Oct 11, 2021 6:26 pm
by Mcasey
Worked great thanks very much eabrust