'ToolChange Macro For Bed type tool changer 11/05 BrianSub Main()		OldTool = GetOEMDRO (1200) '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 = 10     'Max number of tools for the changer	SafeZ      = -20.00 'Safe Z long distance traveling	ToolDown   = -353.0000 'Z Pos to Get or drop a tool	ToolUp     = -260.0000 'Z Height to Rapid from tool to tool	ToolX      = 56.0000 'X Position to take or release a tool	PrepareX   = 110.0000 'X Position to prepare to release tool		If NewTool = 0 Then		Call SetUserDRO (1200,NewTool)		SetCurrentTool( NewTool )		Code "G43 H" & NewTool		Exit Sub	End If		If NewTool = 100 Then 'Tool number of the Haimer'		Call SetUserDRO(1200, NewTool)		SetCurrentTool( NewTool )		Code "G43 H" & NewTool		Exit Sub	End If	If NewTool > MaxToolNum Then		Call SetUserDRO(1200,NewTool)		SetCurrentTool( NewTool )		Code "G43 H" & NewTool		Exit Sub	End If		If OldTool = 0 Or OldTool > 9 Then		OldTool = 0		isTool = 0		answer = MachMsg("Est-ce qu'il y a un outil dans le moteur?", "Outils dans le moteur?", 4 )		If answer = 6 Then			isTool = 1		End If		If isTool = 1 Then			While OldTool = 0				OldTool = Question("Entre le # d'outils actuelement dans le moteur. 1-9")				If OldTool > 9 Then					OldTool = 0				End If			Wend		End If	End If		If NewTool = OldTool Then 		Call SetUserDRO(1200,NewTool)		SetCurrentTool( NewTool )		Code "G43 H" & NewTool		Exit Sub	End If			Message("Changement d'outil de: " & OldTool & " a: " & NewTool )		Code "G00 G53 Z" & SafeZ	While IsMoving()	Wend		If OldTool > 0 Then		Call MovePosPrep(OldTool)		Code "G00 G53 Z" & ToolDown		Code "G00 G53 X" & ToolX		While IsMoving()		Wend		ActivateSignal(Output1) 'Turn On Draw bar to release the tool		Code "G4 P1."    'Wait for the tool to release		Code "G00 G53 Z" & ToolUp		While IsMoving()		Wend		'DeActivateSignal(Output1) 'Turn Off Draw bar to Clamp the tool	End If		If (NewTool > 0) And (NewTool < 10) Then		Call MovePos(NewTool)		ActivateSignal(Output1) 'Turn On Draw bar to release the tool		Code "G00 G53 Z" & ToolDown		While IsMoving()		Wend		DeActivateSignal(Output1) 'Turn Off Draw bar to Clamp the tool		Code "G4 P1."    'Wait for the tool to Clamp		Code "G00 G53 X" & 140		While IsMoving()		Wend	End If		DeActivateSignal(Output1) 'Turn Off Draw bar to Clamp the tool		Code "G00 G53 Z" & SafeZ	While IsMoving()	Wend	Call SetUserDRO (1200,NewTool)	SetCurrentTool( NewTool )	Code "G43 H" & NewTool	Code "G00 Y" & y	While IsMoving()	Wend'	Code "G00 X" & x'	While IsMoving()'	Wend	End SubSub MovePosPrep(ByVal ToolNumber As Integer)	Select Case ToolNumber		Case Is = 1			YPos = 523.0680		Case Is = 2			YPos = 637.7544		Case Is = 3			YPos = 750.4466		Case Is = 4			YPos = 904.8906		Case Is = 5			YPos = 1019.8013		Case Is = 6			YPos = 1141.2302		Case Is = 7			Ypos = 1299.2137		Case Is = 8			Ypos = 1414.5233		Case Is = 9			Ypos = 1531.7895	End Select	Code "G53 X" & 140	While IsMoving()	Wend	Code "G53 Y" & YPos	While IsMoving()	Wend	End SubSub MovePos(ByVal ToolNumber As Integer)	Select Case ToolNumber		Case Is = 1			YPos = 523.0680		Case Is = 2			YPos = 637.7544		Case Is = 3			YPos = 750.4466		Case Is = 4			YPos = 904.8906		Case Is = 5			YPos = 1019.8013		Case Is = 6			YPos = 1141.2302		Case Is = 7			Ypos = 1299.2137		Case Is = 8			Ypos = 1414.5233		Case Is = 9			Ypos = 1531.7895	End Select		Code "G00 G53 X" & 140	While IsMoving()	Wend	Code "G00 G53 Y" & YPos	While IsMoving()	Wend	Code "G00 G53 X" & 56	While IsMoving()	Wend	End SubMain                                      