SOLVED !!!
1. Never ever use C# when you can use VB
2. Found this little gem in the Macro detailed instruction file
If the first line of the macro code contains the #VB directive then the software uses the VisualBasic compiler to compile the macro instead of the C# compiler.3. Don't overthink things, why prompt the user to enter co-ordinates when the machine knows exactly what they are?
And the result is this working code. Hope someone finds it useful, I just stuck it on a button and press that every time I want to record a point.
- Code: Select all
#VB
Dim Xpos As Double = exec.GetXmachpos() ' Get the current machine coordinates
Dim Ypos As Double = exec.GetYmachpos() ' Get the current machine coordinates
Dim filePath As String = "C:\UCCNC\DXF.txt" 'Change this as suits your System
Dim file As System.IO.StreamWriter
MessageBox.Show(Xpos & " " & Ypos,"Point added to file")
file = My.Computer.FileSystem.OpenTextFileWriter(filePath, True)
file.WriteLine(Xpos & "," & Ypos &",0") 'Appended a trailing zero so CamBam will accept this as a valid point list file
file.Close()