'ToolChange Macro For Bed type tool changer 11/05 Brian
Sub Main()
OldTool = GetOEMDRO (1203) 'Tool In spindle DRO You must add this to your settings screen
x = GetToolChangeStart ( 0 )
y = GetToolChangeStart ( 1 )
z = GetToolChangeStart ( 2 )
a = GetToolChangeStart ( 3 )
b = GetToolChangeStart ( 4 )
c = GetToolChangeStart ( 5 )
tool = GetSelectedTool()
NewTool = tool
'Tool Changer Macro (Bed Type)
MaxToolNum = 2 'Max number off tools for the changer
ToolDown = -115 'Z Pos to Get or drop a tool
ToolUp = 38 'Z Height to Rapid from tool to tool
If NewTool = OldTool Then
Exit Sub
End If
While NewTool > MaxToolNum
NewTool = Question ("Enter New Tool Number up to " & MaxToolNum)
Wend
Code "G00 G53 Z" & ToolUp
While IsMoving()
Wend
Call MoveOldtoolPos(OldTool)
While IsMoving()
Wend
Code "G91 Y-50" 
While IsMoving()
Wend
Code "G90 G53 Z" & ToolDown
While IsMoving()
Wend
Code "G91 Y50"
While IsMoving()
Wend
Code "m8"
While IsMoving()
Wend
Code "g4 p1"
While IsMoving()
Wend
Code "m9"
While IsMoving()
Wend
Code "G90 G53 Z" & ToolUp
While IsMoving()
Wend
Call MoveNewtoolPos(NewTool)
While IsMoving()
Wend
Code "G53 Z" & ToolDown
While IsMoving()
Wend
Code "m7"
While IsMoving()
Wend
Code "g4 p1"
While IsMoving()
Wend
Code "m9"
While IsMoving()
Wend
Code "G91 Y-50"
While IsMoving()
Wend
Code "G90 G53 Z" & ToolUp
While IsMoving()
Wend
Call SetUserDRO (1203,NewTool)
SetCurrentTool( NewTool )
Code "G00 X" & x & " Y" & y 'Move back to where the tool change was prompted
End Sub

Sub MoveOldtoolPos(ByVal ToolNumber As Integer)

Select Case ToolNumber
Case Is = 0
Xpos = 0
Ypos = -412
Case Is = 1
Xpos = 260
Ypos = -412
Case Is = 2
Xpos = 520
Ypos = -412
Case Is = 3
Xpos = 780
Ypos = -412
Case Is = 4
Xpos = 1040
Ypos = -412
Case Is = 5
Xpos = 1300
Ypos = -412

End Select

Code "G53 X" & XPos & " Y" & YPos
End Sub
Sub MoveNewtoolPos(ByVal ToolNumber As Integer)

Select Case ToolNumber
Case Is = 0
Xpos = 0
Ypos = -412
Case Is = 1
Xpos = 260
Ypos = -412
Case Is = 2
Xpos = 520
Ypos = -412
Case Is = 3
Xpos = 780
Ypos = -412
Case Is = 4
Xpos = 1040
Ypos = -412
Case Is = 5
Xpos = 1300
Ypos = -412


End Select

Code "G53 X" & XPos & " Y" & YPos
End Sub
Main 