'ToolChange Macro for Turret type tool changer – 8 tools 04/10/24 Sub Main()OldTool = GetOEMDRO (1200) 'Tool In spindle DRO You must add this to your settings screen before starttool = GetSelectedTool()NewTool = tool'Tool Changer Macro (Turret Type)MaxToolNum = 8      'Max number off tools for the changerIf NewTool = OldTool Then Exit Sub			'no tool change neededEnd IfWhile NewTool > MaxToolNum Or Newtool < 1NewTool = Question ("Enter New Tool Number up to " & MaxToolNum)Wendx = GetToolChangeStart( 0 )	'save last programmed xz = GetToolChangeStart( 2 ) 	'save last programmed zCode "G53 x20 Z150"             'moves turret to safe positionabsolute	Call MovePos(NewTool)While IsMoving()WendCode "G00 X" & & "Z" & Z	'moves turret back to last programmed positionWhile IsMoving()WendCall SetUserDRO (1200,NewTool)	'Updates DRO and settingsSetCurrentTool( NewTool )End SubSub MovePos(ByVal ToolNumber As Integer)Select Case ToolNumber       Case Is = 1         Apos = 1		'Assumes A-axis for turret position before lock         Alock = -358		'This is locked position       Case Is = 2         Apos = 47         Alock = -42       Case Is = 3         Apos = 95         Alock = -85       Case Is = 4         Apos = 140         Alock = -130       Case Is = 5         Apos = 185         Alock = -175       Case Is = 6         Apos = 230         Alock = -220       Case Is = 7         Apos = 270         Alock = -265                                                                                                                                     Case Is = 8         Apos = 315         Alock = -310              End SelectCode "G00 A" & Apos				Code "G04 P1"			'Could be shorter pause or none?Code "G00 A" & Alock	Code "G04 P1"			'Could be shorter pause or none?While IsMoving()WendSetOemDRO(803,Apos) 'This bit is added to set DRO to position wantedSleep 1000	'Wait for 1 second End SubMain             