I originally put this cook book up on Joe's 4 x 4 forum but I went into the gory details of using the various Mach screen editors and VBScript. I quickly decided it was much better to just post the already modified MachBlue.set file with the buttons and scripts already installed.
I tried using several of the Mach screen editors and they all have various problems. I had the most success using the Mach3Screen version 2.7e with the MachBlue interface, but it crashes fairly often and you have to be very careful of where you click. It's like walking through a mine field. The programming environment is not very friendly. When you make a syntax error in your script it will not run and you get no feed back on what is wrong. You basically have to start out with 1 or 2 lines of known working code and gradually add on a line at a time. If the program stops working you back up to the last line you added and try to figure out what you did wrong. Kind of frustrating and definitely not the place for a beginning programmer to cut his teeth. And then the editor will crash and you have to start all over again.
I had a hard time sorting this stuff out. The Mach community seems to be going off in many directions at once- Flash, html, Visual Basic, etc. and the documentation and tutorial threads are all mixed up. There doesn't seem to be a very clear sense of direction and the basic underpinnings of the user interface technology have obviously been added on to one too many times. It looks like it is a prime candidate for major house cleaning and a rewrite. Still it's pretty amazing what you can do if you have a lot of patience.
If this hasn't scared you off, there is a nice Wiki with info on how to program - http://www.machsupport.com/MachCusto...itle=Main_Page and you can download the various screen editors from the "Screen Designer" section of this page: http://www.artsoftcontrols.com/artso.../downloads.htm
The basic idea is that the Mach user interface is built from one or more background .jpg pictures that are overlayed with buttons, Led's, DRO's, labels and other specialized panels. All the overlay information is kept in a .set file. For instance the default screens you see when you first install Mach3 come from 1024.set. The MachBlue screen comes from MachBlue.set. The screen editors allow you to modify the .set files to add buttons, DRO's, Led's, labels and other specialized panels.
A button can activate a canned Mach function, execute a G-Code program or execute a Visual Basic script. The Visual Basic scripting language has access to most of Mach's internal state variables and can read and modify them. VBScript can also execute G-Code instructions from within the script. Pretty powerful stuff.
You can open up the .set files with the screen editor and then double click on any of the buttons and see how they are set up. The programming code is all there for you to read and modify. Make sure you make back up copies of the .set file before you make any modifications.... Here is the VBScript I put in the centering button:
Rem VBScript to center probe inside a pipe
If GetOemLed (825) <> 0 Then 'Check to see if the probe is already grounded or faulty
Code "(Probe plate is grounded, check connection and try again)"Else
FeedCurrent = GetOemDRO(818) 'Get the current settings
XCurrent = GetDro(0)
YCurrent = GetDro(1)
Code "G4 P1" 'Pause 1 second to give time to position probe plate
Code "F4" 'slow feed rate to 4 ipm
Rem Probe left
XNew = Xcurrent - 3 'probe 3 inches to leftRem Probe right
Code "G31 X" &XNew
While IsMoving() 'wait for the move to finish
XPos1 = GetVar(2000) 'get the probe touch location
Code "G0 X" &XCurrent 'rapid move back to start point
XNew = XCurrent + 3 'probe 3 inches to rightRem Probe up
Code "G31 X" &XNew
XPos2 = GetVar(2000)
XCenter = (XPos1 + XPos2) / 2 'center is midway between XPos1 and XPos2
Code "G0 X" &XCenter 'rapid move to the x center location
YNew = YCurrent + 3Rem Probe down
Code "G31 Y" &YNew
YPos1 = GetVar(2001)
Code "G0 Y" &YCurrent
YNew = YCurrent - 3Rem move to the center
Code "G31 Y" &YNew
YPos2 = GetVar(2001)
YCenter = (YPos1 + YPos2) / 2
Code "G0 Y" &YCenterEnd If
While IsMoving ()
Code "F" &FeedCurrent 'restore starting feed rate