Hello Guest it is March 29, 2024, 07:01:23 AM

Author Topic: Load Gcode file from an Image of part  (Read 6458 times)

0 Members and 1 Guest are viewing this topic.

Offline BR549

*
  •  6,965 6,965
    • View Profile
Load Gcode file from an Image of part
« on: March 09, 2013, 10:48:20 PM »
Seeing how Les at SHEETCAM gave us the ability to create image files from our jobs I created
a Button function in MACH3 to be able to LOAD a Gcode file by viewing an image
file and making a selection to LOAD. The image and Gcode file MUST have the same
name of course and the function will LET YOU KNOW if it cannot find a gcode
under the image name you selected(;-).

You would need to add a new button to your screen and copy over the code to it
so it may not be for everyone. I could create a macro from it and you could just
call it from the MDI line, OR open for suggestions ???

If you are like me I have about a half a zillion Gcode files for plasma cutting.
After the first hundred or so gcode file names they all seem to run together
anymore. Memory is not the best anymore.

So now you can select the FIlename and View an image of it THEN if it is the
correct one load it into Mach3 and be ready to cut.

To use simply press the button and a veiw screen will pop up. Click on the file name you wish to view and the IMAGE will come up in the view window. Once you have found the correct file/image push the load button and the function will search the Gcode DIR and IF it finds a matching name it will load the program and CLOSE.

IF it does not find a match it will display a message and you can either cancel or select again.

HOPE it is helpful, I already use it in the shop for plasma cutting.

(;-) TP


Button Code for Load from Image:

'=========================================================
' Macro function to load Gcode file FROM the BMP image.
' The image files MUST be in BMP format and be the same
' Name as the Gcode file. The Gcode files and the BMP files
' can be in the same DIR or different DIRs you will have to
' Point the CODE to the proper DIRs.
'
' There are notes in the code as to the various POINTERS
' that you may need to modify for your application
'=========================================================
 
Sub DrawBitmapSample
    Dim MyList()
    Begin Dialog BitmapDlg 60, 60, 590, 420, "Load Gcode From BMP Image", .DlgFunc
        ListBox 10, 10, 80, 180, MyList(), .List1, 2
        Picture 100, 10, 480, 380, "C:\mach3\bitmaps\splash.bmp", 0, .Picture1
        CancelButton 27, 225, 40, 12    
        PushButton 10, 200 ,80,12 ,"Load Gcode File", .PB1
    End Dialog
 
    Dim frame As BitmapDlg
    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( "D:\ScamData\Jobs\*.bmp" )  ' Points to the DIR of the BMP files
        count = 0
    While temp <> ""
        count = count + 1
        temp = Dir
        Wend
        Dim x() As String
        ReDim x(count)
        x(0) = Dir( "D:\ScamData\Jobs\*.bmp" ) ' Points to the DIR of the BMP files
        For i = 1 To count
            x(i) = Dir
        Next i
        DlgListBoxArray "List1", x()
        
    Case 2 ' Click
        fName = ( "D:\ScamData\Jobs\" & DlgText("List1") )  'Points to the DIR of the BMP DIR.
        DlgSetPicture "Picture1", fName
        
  If controlID = "PB1" Then
   sFile = Dlgtext("List1")
   sFile = Left(sFile, InStr(1, sFile, ".") - 1)
   Fext= ".TAP"               'Sets the .ext of the Gcode type
   Lfile = sFile &Fext
   
    If Dir ("C:\Mach3\Gcode\" & Lfile) ="" Then      'Points to the DIR of the GCODE files
        Message"Function Closed"
        MsgBox" Requested GCODE File Does NOT Exist "
    Else
   Loadfile "C:\Mach3\Gcode\" &Lfile                'Points to the DIR of the GCODE files
   End
   End If

End If      
End Select
End Function
End            
« Last Edit: March 09, 2013, 10:55:50 PM by BR549 »