'ToolChange Macro Test Const ToolChangeZ = "200" Const AfterZ = "0" Const UseAfterZ = False Const TimeOut = 10 Const SpindleStartCommand = "M3" Const DebugMode = False Const Trigger = 29 Call Main Sub Main() tool = GetSelectedTool() CurrentZ=GetToolChangeStart( 2 ) - ToolLengthOffset() Call Code( "G49" ) Call Code( "G90G00Z" & ToolChangeZ ) Message "Now Moving to Tool Change Position." Call WaitForMove Call SendSerial ("Tool#" & Tool) Message "Now Progress, Change to Tool #" & Tool If WaitForTRIG(Timeout) Then SetCurrentTool( tool ) Call Code ("H" & tool & "G43") Message "Tool #" & Tool & " Selected" If UseAfterZ Then Zpos=AfterZ Else Zpos=CurrentZ End If Call Code ( "G00Z" & Zpos ) Call WaitForMove Call Code( SpindleStartCommand ) Else Message "Tool Change Failed,Because TimeOut." DoOEMButton( 1003 ) End If End Sub Function WaitForMove() While IsMoving() Wend End Function Function WaitForTRIG(intTimeout) inTime=Now() bolWait=False Do While DateDiff("s",inTime,Now())