Last active
March 14, 2018 19:56
-
-
Save nosmokingbandit/76d2af6743f0c0625da9087cba5a3006 to your computer and use it in GitHub Desktop.
BitMover dialog for Mach3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' BitMover dialog. https://gist.github.com/nosmokingbandit/76d2af6743f0c0625da9087cba5a3006 | |
Public XAxisMoveDistance, YAxisMoveDistance, ZAxisMoveDistance As Double | |
Public Abort, OrigJogMode, MoveAbsolute, MoveRelative As Boolean | |
Public isImperial, MoveMM, MoveX, MoveY, MoveZ As Integer | |
Sub Main | |
OrigJogMode = GetIJMode() '1 for inc, 0 for abs | |
isImperial = GetSetupUnits() '1 for IN, 0 for MM machine units | |
Abort = False | |
If (GetOEMLED(800)) Then | |
Message ("MACHINE OFFLINE") | |
Exit Function | |
End If | |
Begin Dialog DlgCheckAxis 15,32,122,90,"Select Axes to Move",.DlgCheckAxis | |
GroupBox 4,0,114,22,"",.GroupMoveType | |
OptionGroup .grp1 | |
OptionButton 8,8,40,10,"Absolute",.SetAbsolute | |
OptionButton 64,8,40,10,"Relative",.SetRelative | |
GroupBox 4,22,74,46,"",.GroupAxesChk | |
CheckBox 8,30,15,10,"X",.ChkBoxXAxis | |
CheckBox 8,42,15,10,"Y",.ChkBoxYAxis | |
CheckBox 8,54,15,10,"Z",.ChkBoxZAxis | |
TextBox 26,30,48,10,.XAxisMoveDistance | |
TextBox 26,42,48,10,.YAxisMoveDistance | |
TextBox 26,54,48,10,.ZAxisMoveDistance | |
GroupBox 82,22,36,46,"",.GroupMeasureType | |
OptionGroup .grp2 | |
OptionButton 86,32,30,10,"mm",.UnitMM | |
OptionButton 86,52,30,10,"inch",.UnitIN | |
OKButton 78,72,40,14 | |
CancelButton 4,72,40,14 | |
End Dialog | |
Dim Dlg1 As DlgCheckAxis | |
Dlg1.grp1 = origJogMode | |
Dlg1.grp2 = isImperial | |
Dlg1.XAxisMoveDistance = "0.0" | |
Dlg1.YAxisMoveDistance = "0.0" | |
Dlg1.ZAxisMoveDistance = "0.0" | |
Button = Dialog ( Dlg1 ) | |
XAxisMoveDistance = CDbl(Dlg1.XAxisMoveDistance) | |
YAxisMoveDistance = CDbl(Dlg1.YAxisMoveDistance) | |
ZAxisMoveDistance = CDbl(Dlg1.ZAxisMoveDistance) | |
If Not Abort Then | |
MoveAxes | |
End If | |
End Sub | |
Sub MoveAxes() | |
Multiplier = 1.0 | |
If MoveAbsolute Then | |
Code "G90" | |
End If | |
If MoveRelative Then | |
Code "G91" | |
End If | |
If isImperial = 1 Then | |
If MoveMM = 1 Then ' If Machine in INCHES and Diglog in MM | |
Multiplier = (1/25.4) | |
End If | |
End If | |
If isImperial = 0 Then | |
If MoveMM = 0 Then ' If Machine in MM and Dialog in INCHES | |
Multiplier = 25.4 | |
End If | |
End If | |
Message("G0 Z " + CStr(ZAxisMoveDistance * Multiplier)) | |
If MoveX = 1 Then | |
Code "G0 X " + CStr(XAxisMoveDistance * Multiplier) | |
End If | |
If MoveY = 1 Then | |
Code "G0 Y " + CStr(YAxisMoveDistance * Multiplier) | |
End If | |
If MoveZ = 1 Then | |
Code "G0 Z " + CStr(ZAxisMoveDistance * Multiplier) | |
End If | |
If OrigJogMode = 1 Then | |
Code "G91" | |
Else | |
Code "G90" | |
End If | |
End Sub | |
Function DlgCheckAxis( ControlID$, Action%, SuppValue%) | |
If DlgValue("ChkBoxXAxis") Then | |
DlgEnable "XAxisMoveDistance", 1 | |
MoveX = 1 | |
Else | |
DlgEnable "XAxisMoveDistance", 0 | |
MoveX = 0 | |
End If | |
If DlgValue("ChkBoxYAxis") Then | |
DlgEnable "YAxisMoveDistance", 1 | |
MoveY = 1 | |
Else | |
DlgEnable "YAxisMoveDistance", 0 | |
MoveY = 0 | |
End If | |
If DlgValue("ChkBoxZAxis") Then | |
DlgEnable "ZAxisMoveDistance", 1 | |
MoveZ = 1 | |
Else | |
DlgEnable "ZAxisMoveDistance", 0 | |
MoveZ = 0 | |
End If | |
If DlgValue("SetAbsolute") Then | |
MoveAbsolute = 1 | |
Else | |
MoveAbsolute = 0 | |
End If | |
If DlgValue("SetRelative") Then | |
MoveRelative = 1 | |
Else | |
MoveRelative = 0 | |
End If | |
If DlgValue("UnitMM") Then | |
MoveMM = 1 | |
End If | |
If DlgValue("UnitIN") Then | |
MoveMM = 0 | |
End If | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment