Export current coordinates

This is where you talk about Macros, show examples of your macro scripting and SHARE handy segments of script code as examples.

Export current coordinates

Postby Mcasey » Mon Oct 04, 2021 7:01 pm

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.
Mcasey
 
Posts: 21
Joined: Sun Apr 11, 2021 6:10 pm

Re: Export current coordinates

Postby eabrust » Mon Oct 04, 2021 10:29 pm

http://www.forum.cncdrive.com/viewtopic.php?f=11&t=637&hilit=system.io

The 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
CraftyCNC: Plugins for UCCNC (and other neat stuff): http://www.craftycnc.com/plugins-for-uccnc/
eabrust
 
Posts: 361
Joined: Fri Sep 16, 2016 2:32 am
Location: Near Shirland IL, USA

Re: Export current coordinates

Postby Mcasey » Tue Oct 05, 2021 7:28 am

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
Mcasey
 
Posts: 21
Joined: Sun Apr 11, 2021 6:10 pm

Re: Export current coordinates

Postby eabrust » Tue Oct 05, 2021 11:47 am

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


M55555.txt
(519 Bytes) Downloaded 499 times
CraftyCNC: Plugins for UCCNC (and other neat stuff): http://www.craftycnc.com/plugins-for-uccnc/
eabrust
 
Posts: 361
Joined: Fri Sep 16, 2016 2:32 am
Location: Near Shirland IL, USA

Re: Export current coordinates

Postby Mcasey » Mon Oct 11, 2021 6:26 pm

Worked great thanks very much eabrust
Mcasey
 
Posts: 21
Joined: Sun Apr 11, 2021 6:10 pm


Return to Macros

Who is online

Users browsing this forum: No registered users and 3 guests