Good morning
I found this macro on the web, it works well, I kindly ask if anyone can modify it, since it is not in my skills and competences, the modification I would like to make is the following:
in the line " Open "C:\Mach3\SurfaceScan.txt" For Output As #iFileOutput " I would like if possible when saving if it finds a file with the same name that I store in "SurfaceScan1.txt .SurfaceScan2.txt , SurfaceScan3.txt, etc etc" I hope I made myself clear.
Thanks to anyone who can help me
GreetingsOption Explicit
Dim Xstart, Ystart, Zstart As Double
Dim Xdim, Ydim As Double
Dim Xpos, Ypos As Double
Dim Xcnt, Ycnt As Integer
Dim Xstep, Ystep As Double
Dim x, y As Integer
Dim FeedMeas, FeedMove As Double
Dim iFileOutput As Integer
FeedMeas=350
FeedMove=2500
Dim Title As String
Xdim=InputBox("Set scanning dimension in X",Title)
Ydim=InputBox("Set scanning dimension in Y",Title)
Xcnt=InputBox("Set number of samples in X",Title)
Ycnt=InputBox("Set number of samples in Y",Title)
If(Xcnt<1 Or Ycnt<0) Then
MsgBox "Wrong parameters. Script terminated!",0,Title
Exit Sub
End If
If(MsgBox("Start surface scanning?",4,Title)<>6) Then
MsgBox "Script terminated!",0,Title
Exit Sub
End If
ActivateSignal(OUTPUT4) 'aktivace digitizeru
Open "C:\Mach3\SurfaceScan.txt" For Output As #iFileOutput
If(Xcnt>1) Then
XStep=Xdim/(Xcnt-1)
Else
Xstep=0
End If
If(Ycnt>1) Then
Ystep=Ydim/(Ycnt-1)
Else
Ystep=0
End If
Xstart=GetOEMDRO(800)
Ystart=GetOEMDRO(801)
Zstart=GetOEMDRO(802)
For y=1 To Ycnt
Ypos=Ystart + (y-1) * Ystep
For x=1 To Xcnt
Xpos=Xstart + (x-1) * Xstep
Code "G90 G0 Z" & Zstart & " F" & FeedMove
While IsMoving()
Sleep(10)
Wend
Code "G90 G0 X" & Xpos & " Y" & Ypos & " F" & FeedMove
While IsMoving()
Sleep(10)
Wend
While GetOemLed (825) <> 0
MsgBox "Sensor is active! Fix the sensor and continue.",0,Title
Wend
Code"G91 G31 Z-20 F" &FeedMeas
Sleep(10)
While IsMoving()
Sleep(10)
Wend
Print #iFileOutput, "X" & roun(Xpos) & " Y" & roun(Ypos) & " Z" & roun(GetOEMDRO(802))
Next x
Next y
Code "G90 G0 Z" & Zstart & " F" & FeedMove
While IsMoving()
Sleep(10)
Wend
Code "G90 G0 X" & Xstart & " Y" & Ystart & " F" & FeedMove
While IsMoving()
Sleep(10)
Wend
DeActivateSignal(OUTPUT4) 'aktivace digitizeru
Close #iFileOutput