Hello Guest it is May 11, 2021, 09:56:57 PM

Author Topic: G49 on Mach3 Mill  (Read 6603 times)

0 Members and 1 Guest are viewing this topic.

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
    • DD Metal Products Ltd
Re: G49 on Mach3 Mill
« Reply #20 on: February 04, 2018, 10:20:18 AM »
Ok, sorted.

Simple little VB6 app created that i can run on the mill, it will read the files from the USB stick, comment out and G43/G44 lines and output the files to the hard drive ready to run.

:)
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives.
Plasma table, Mach3 V062, Step motors, C&CNC THC.

Offline rcaffin

*
  •  1,035 1,035
    • View Profile
Re: G49 on Mach3 Mill
« Reply #21 on: February 04, 2018, 03:13:30 PM »
Chips!

Offline TPS

*
  •  2,129 2,129
    • View Profile
Re: G49 on Mach3 Mill
« Reply #22 on: February 05, 2018, 05:57:11 AM »
ok here is my Little solution to run in a button script:

Code: [Select]
Sub Main()

Set objFiles = CreateObject("Excel.Application")
Dim Filename As String


'set default open file folder
ChDrive "C:"
ChDir   "C:\Mach3\GCode"

FileName = objFiles.Application.GetOpenFilename("GCodeFiles (*.TAP), *.tap")
 
If FileName = "False" Then Exit Sub

'find the last "\" in filename
For i = 1 To Len(FileName)
If Mid(FileName,i,1) = "\" Then
last = i
End If
Next i

'extract filename
myfilename = Mid(FileName,last+1,Len(FileName)-last)

'find the extension in filename
For i = 1 To Len(myfilename)
If Mid(myfilename,i,1) = "." Then
last = i
End If
Next i

'seperate filename and extension
blancfilename = Mid(myfilename,1,last-1)
extension = Mid(myfilename,last,Len(FileName)-last)

'open input file
FNumInput    = FreeFile 'Determine next file number.
Open FileName For Input As FNumInput

'open output file
FNumOutput = FreeFile 'Determine next file number.
Open "C:\Mach3\GCode\" + blancfilename + "_filtered" + extension For Output As FNumOutput

'go through To hole file
Do While Not EOF(FNumInput)
Line Input #FNumInput, FileData ' Read a line of data.
If InStr(FileData,"G43") = 0 Then
Print #FNumOutput, FileData
Else
Print #FNumOutput, "( " + FileData + " )"
End If
Loop


Close ' Close all open files.

End Sub




it will only work on a machine where Excel is present,
because all my known openfile dialogs (in VBScript) where
not working on a 64bit OS
 
Thomas

so if anybody has a working fileopen Dialog, would be nice to share it.
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
    • DD Metal Products Ltd
Re: G49 on Mach3 Mill
« Reply #23 on: February 05, 2018, 06:12:19 AM »
Well, if that does indeed work (i'll test it this afternoon) it will solve the issue 99%

Its VBA which is the same as VB6 uses so it all makes sense to me, Excel uses VBA thats why it needs to installed but any VB app installer will load the VB runtime which holds the key to VBA.

Very nice.

BTW, I only gave it 99% as each time you load the file it will append more () so third time round it will look like (((G43..........))) etc
That could be fixed though if it runs.

Nice
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives.
Plasma table, Mach3 V062, Step motors, C&CNC THC.

Offline TPS

*
  •  2,129 2,129
    • View Profile
Re: G49 on Mach3 Mill
« Reply #24 on: February 05, 2018, 06:17:52 AM »
Little bugfix,  (((G43..........)))  problem:

Code: [Select]

'go through To whole file
Do While Not EOF(FNumInput)
Line Input #FNumInput, FileData ' Read a line of data.
If ((InStr(FileData,"G43") <> 0) and (Left(FileData,1) <> "(")) Then
Print #FNumOutput, "( " + FileData + " )"
Else
Print #FNumOutput, FileData
End If
Loop


anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.

Offline TPS

*
  •  2,129 2,129
    • View Profile
Re: G49 on Mach3 Mill
« Reply #25 on: February 05, 2018, 06:30:40 AM »
next Little bugfix,

add

Code: [Select]

LoadFile( "C:\Mach3\GCode\" + blancfilename + "_filtered" + extension)


at the end, to load "cleaned" file imediatelly.
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
    • DD Metal Products Ltd
Re: G49 on Mach3 Mill
« Reply #26 on: February 05, 2018, 08:18:13 AM »
Hmm, ok my thoughts on it running using VB6 core did not work, is there a way to make this work if you have no Excel etc installed??
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives.
Plasma table, Mach3 V062, Step motors, C&CNC THC.

Offline TPS

*
  •  2,129 2,129
    • View Profile
Re: G49 on Mach3 Mill
« Reply #27 on: February 05, 2018, 08:19:24 AM »
witch os are you running on?
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
    • DD Metal Products Ltd
Re: G49 on Mach3 Mill
« Reply #28 on: February 05, 2018, 08:20:37 AM »
Win7 & XP
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives.
Plasma table, Mach3 V062, Step motors, C&CNC THC.

Offline TPS

*
  •  2,129 2,129
    • View Profile
Re: G49 on Mach3 Mill
« Reply #29 on: February 05, 2018, 08:40:24 AM »
this Version should work on every OS:

Code: [Select]

'Gcode Selection Box
Sub GcodeSelect
    Dim MyList()
    Begin Dialog GcodeFileDlg 60, 60, 190, 220, "Gcode file selection", .DlgFunc
        ListBox 10, 10, 150, 180, MyList(), .List1, 2
        CancelButton 42, 198, 40, 12
        OKButton 90, 198, 40, 12   
       End Dialog
   
 Dim frame As GcodeFileDlg
 
    ' Show the GcodeFile dialog
    Dialog frame
End Sub
 
Function DlgFunc( controlID As String, action As Integer, suppValue As Integer)
 
    DlgFunc = 1  ' Keep dialog active
 
    Select Case action
    Case 1 ' Initialize
        temp = Dir( "c:\Mach3\Gcode\*.tap" )
        count = 0 
        While temp <> ""
            count = count + 1
            temp = Dir
        Wend
        Dim x() As String
        ReDim x(count)
        x(0) = Dir( "c:\Mach3\Gcode\*.tap" )
        For i = 1 To count
            x(i) = Dir
        Next i
        DlgListBoxArray "List1", x()
       
    Case 2 ' select
     
        Fname = (DlgText("List1"))
       
        Dim FileName As String
FileName = "c:\Mach3\Gcode\" &Fname
If FileName = "False" Then Exit Sub

'find the last "\" in filename
For i = 1 To Len(FileName)
If Mid(FileName,i,1) = "\" Then
last = i
End If
Next i

'extract filename
myfilename = Mid(FileName,last+1,Len(FileName)-last)

'find the extension in filename
For i = 1 To Len(myfilename)
If Mid(myfilename,i,1) = "." Then
last = i
End If
Next i

'seperate filename and extension
blancfilename = Mid(myfilename,1,last-1)
extension = Mid(myfilename,last,Len(FileName)-last)

'open input file
FNumInput    = FreeFile 'Determine next file number.
Open FileName For Input As FNumInput

'open output file
FNumOutput = FreeFile 'Determine next file number.
Open "C:\Mach3\GCode\" + blancfilename + "_filtered" + extension For Output As FNumOutput

'go through To whole file
Do While Not EOF(FNumInput)
Line Input #FNumInput, FileData ' Read a line of data.
If ((InStr(FileData,"G43") <> 0) And (Left(FileData,1) <> "(")) Then
Print #FNumOutput, "( " + FileData + " )"
Else
Print #FNumOutput, FileData
End If
Loop


Close ' Close all open files.

LoadFile( "C:\Mach3\GCode\" + blancfilename + "_filtered" + extension)

       
       
       
       
       
       
        End
     End Select

End Function





anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.