'Declare variable CDC - Camera Dot CountDim CDCIf GetOEMDRO(1110) = 0 Then    SetOEMDRO(1110,1)End If'Declare variable XGA - X GCode for DOT ADim XGA'Declare variable YGA - Y GCode for DOT ADim YGA'Declare variable XOA - X Offset for DOT ADim XOA'Declare variable YOA - Y Offset for DOT ADim YOA'Declare variable XGB - X GCode for DOT BDim XGB'Declare variable YGB - Y GCode for DOT BDim YGB'Declare variable XOB - X Offset for DOT BDim XOB'Declare variable YOB - Y Offset for DOT BDim YOB'Declare variable XGC - X GCode for DOT CDim XGC'Declare variable YGC - Y GCode for DOT CDim YGC'Declare variable XOC - X Offset for DOT CDim XOC'Declare variable YOC - Y Offset for DOT CDim YOC'Declare variable XG1 - X GCode for DOT 1 TO 3Dim XG(1 To 3)'Declare variable YG1 - Y GCode for DOT 1 TO 3Dim YG(1 To 3)'Declare variable XO1 - X Offset For DOT 1 TO 3Dim XO(1 To 3)'Declare variable YO1 - Y Offset for DOT 1 TO 3Dim YO(1 To 3)If GetOEMDRO(1110) = 1 Then'Open Camera DoorActivateSignal(Output3)Sleep(2500)'First Dot'XG1 = GCode DOT 1 Location'XO1 = Offset X Dot 1'YG1 = GCode DOT 1 Location'YO1 = Offset X Dot 1'Message "Dot 1 info"'Sleep(7000)'Get X & Y Position - Set Dot 1 Position DRO        XG(1) = (GetDRO (0))        YG(1) = (GetDRO (1))        'Get X & Y offset - Set Dot 1 Offset DRO        XO(1) = (GetOEMDRO (1111))        YO(1) = (GetOEMDRO (1112))                Sleep(50)        If XO(1) = 0 Then        Message "No Dot Found"        SetUserLED (1120,1)        Code "M30"        End If        If YO(1) = 0 Then        Message "No Dot Found"        SetUserLED (1120,1)        Code "M30"        End If                               SetOEMDRO(1140,XG(1))        SetOEMDRO(1141,YG(1))                XO(1) = (XO(1)) - 640        YO(1) = 512 - (YO(1))        YIN = (GetOEMDRO(1114))        INPP = (YIN) / 1024        SetOEMDRO(1113, (INPP))        XO(1) = (XO(1)) * (INPP)        YO(1) = (YO(1)) * (INPP)                XO(1) = (XO(1)) + (XG(1))        YO(1) = (YO(1)) + (YG(1))                	SetOEMDRO(1142,XO(1))        SetOEMDRO(1143,YO(1))        SetOEMDRO(1110,2)                Sleep(50)        If GetUserLED(1120) = 0 Then        Message "Dot 1 info END"End IfSleep(500)           Else'Second Dot'XG2 = GCode DOT 3 Location'XO2 = Offset X Dot 2'YG2 = GCode DOT 3 Location'YO2 = Offset X Dot 2If GetOEMDRO(1110) = 2 Then'Message "Dot 2 info"       'Sleep(7000)'Get X & Y Position - Set Dot 2 Position DRO        While IsMoving()        Sleep (500)        Wend        XG(2) = (GetDRO (0))        YG(2) = (GetDRO (1))        'Get X & Y offset - Set Dot 2 Offset DRO        XO(2) = (GetOEMDRO (1111))        YO(2) = (GetOEMDRO (1112))                        Sleep(50)        If XO(2) = 0 Then        Message "No Dot Found"        SetUserLED (1120,1)        Code "M30"        End If        If YO(2) = 0 Then        Message "No Dot Found"        SetUserLED (1120,1)        Code "M30"        End If                SetOEMDRO(1144,XG(2))        SetOEMDRO(1145,YG(2))                XO(2) = (XO(2)) - 640        YO(2) = 512 - (YO(2))        INPP = (GetOEMDRO(1113))        XO(2) = (XO(2)) * (INPP)        YO(2) = (YO(2)) * (INPP)                XO(2) = (XO(2)) + (XG(1))        YO(2) = (YO(2)) + (YG(1))                   	SetOEMDRO(1146,XO(2))        SetOEMDRO(1147,YO(2))               SetOEMDRO(1110,3)                Sleep(50)        If GetUserLED(1120) = 0 Then        Message "Dot 2 info END"End IfSleep(500)Else'Third Dot'XG3 = GCode DOT 3 Location'XO3 = Offset X Dot 3'YG3 = GCode DOT 3 Location'YO3 = Offset X Dot 3If GetOEMDRO(1110) = 3 Then'Message "Dot 3 info"'Sleep(7000)       'Get X & Y Position - Set Dot 3 Position DRO        While IsMoving()        Sleep (500)        Wend        XG(3) = (GetDRO (0))        YG(3) = (GetDRO (1))        'Get X & Y offset - Set Dot 3 Offset DRO        XO(3) = (GetOEMDRO (1111))        YO(3) = (GetOEMDRO (1112))                        Sleep(50)        If XO(3) = 0 Then        Message "No Dot Found"        SetUserLED (1120,1)        Code "M30"        End If        If YO(3) = 0 Then        Message "No Dot Found"        SetUserLED (1120,1)        Code "M30"        End If                SetOEMDRO(1148,XG(3))        SetOEMDRO(1149,YG(3))                XO(3) = (XO(3)) - 640        YO(3) = 512 - (YO(3))        INPP = (GetOEMDRO(1113))        XO(3) = (XO(3)) * (INPP)        YO(3) = (YO(3)) * (INPP)                XO(3) = (XO(3)) + (XG(1))        YO(3) = (YO(3)) + (YG(1))         	SetOEMDRO(1150,XO(3))        SetOEMDRO(1151,YO(3))        Sleep(50)        If GetUserLED(1120) = 0 Then             Message "Dot 3 info END"End IfSleep(500) 'Close Camera DoorDeActivateSignal(Output3)Sleep(200)              'Step20 &30        XG(1) = (GetOEMDRO (1140))YG(1) = (GetOEMDRO (1141))XO(1) = (GetOEMDRO (1142))YO(1) = (GetOEMDRO (1143))XG(2) = (GetOEMDRO (1144))YG(2) = (GetOEMDRO (1145))XO(2) = (GetOEMDRO (1146))YO(2) = (GetOEMDRO (1147))XG(3) = (GetOEMDRO (1148))YG(3) = (GetOEMDRO (1149))XO(3) = (GetOEMDRO (1150))YO(3) = (GetOEMDRO (1151))Sleep(50)        Dim Dot(1 To 5)                        Dot(1) = (XG(1)) + (YG(1))         Dot(2) = (XG(2)) + (YG(2))         Dot(3) = (XG(3)) + (YG(3))         Dot(4) = (XG(1)) + (YG(1))         Dot(5) = (XG(2)) + (YG(2)) Sleep(50)               'Message "Set Dot ABC"              'Sleep(7000)For DotCount = 1 To 3 If Dot(DotCount)<Dot(DotCount+1) Then'Message "A dot<dot+1"              'Sleep(7000)If Dot(DotCount)<Dot(DotCount+2) Then	'Message "Set Dot A" 	'Sleep(7000)        XGA = XG(DotCount)                  YGA = YG(DotCount)        XOA = XO(DotCount)         YOA = YO(DotCount)          SmDot = DotCount        Sleep(50)'Message "Set Dot A END" 	'Sleep(7000)End IfEnd IfNext DotCountFor DotCount = 1 To 3If Dot(DotCount)>Dot(DotCount+1) Then'Message "C dot>dot+1"              'Sleep(7000)If Dot(DotCount)>Dot(DotCount+2) Then'Message "Set Dot C" 	'Sleep(7000)        XGC = XG(DotCount)                YGC = YG(DotCount)        XOC = XO(DotCount)         YOC = YO(DotCount)          LgDot = DotCount        Sleep(50)'Message "Set Dot C END" 	'Sleep(7000)      End If End IfNext DotCountFor DotCount = 1 To 3If Dot(DotCount)<>Dot(SmDot) Then'Message "B dot<>dot Sm Lg"              'Sleep(7000)If Dot(DotCount)<>Dot(LgDot) Then'Message "Set Dot B" 	'Sleep(7000)        XGB = XG(DotCount)                YGB = YG(DotCount)        XOB = XO(DotCount)         YOB = YO(DotCount)         MiddleDot = DotCount        Sleep(50)'Message "Set Dot B END" 	'Sleep(7000)               End IfEnd IfNext DotCount'Message "Set DRO's"'Sleep(7000)        SetOEMDRO(1120,XGA)                SetOEMDRO(1121,YGA)        SetOEMDRO(1122,XOA)        SetOEMDRO(1123,YOA)        SetOEMDRO(1124,XGC)        SetOEMDRO(1125,YGC)        SetOEMDRO(1126,XOC)        SetOEMDRO(1127,YOC)        SetOEMDRO(1128,XGB)        SetOEMDRO(1129,YGB)        SetOEMDRO(1130,XOB)        SetOEMDRO(1131,YOB)        SetOEMDRO(1110,4)        Sleep (300)        'Step 50' Move to Dot A and Reset HomeElse       If GetOEMDRO(1110) = 4 Then'Message "Shift Home Location"        'While IsMoving()       'Sleep (100)       'Wend       StartPosX = (GetDro(0))       StartPosY = (GetDro(1))       ShiftedStartX = (StartPosX) + (GetOEMDRO(1122))       ShiftedStartY = (StartPosY) + (GetOEMDRO(1123))       Code "G00 X" & ShiftedStartX & "Y" & ShiftedStartY       While IsMoving()       Sleep (500)       Wend       Sleep (1000)       Sleep (1000)       Code "G92 X" & StartPosX & "Y" & StartPosY              Sleep(50)              'Step 60'Calculate A-B scale and set rotation'lenght of line AB      'Message "Set Scaling"        ABXGL = (GetOEMDRO(1128)) - (GetOEMDRO(1120))                If (GetOEMDRO (1129)) > (GetOEMDRO (1121)) Then        ABYGL = (GetOEMDRO (1129)) - (GetOEMDRO (1121))        End If        If (GetOEMDRO (1129)) < (GetOEMDRO (1121)) Then        ABYGL = (GetOEMDRO (1121)) - (GetOEMDRO (1129))        End If        If (GetOEMDRO (1129)) = (GetOEMDRO (1121)) Then        ABYGL = 0        End If                ABTGL = Sqr ((ABXGL * ABXGL) + (ABYGL * ABYGL))                If (GetOEMDRO (1122)) > 0 Then        If (GetOEMDRO (1130)) > 0 Then        ABXOL = (GetOEMDRO (1130)) - (GetOEMDRO (1122))        End If        End If        If (GetOEMDRO (1122)) < 0 Then        If (GetOEMDRO (1130)) < 0 Then        ABXOL = (GetOEMDRO (1130)) - (GetOEMDRO (1122))        End If        End If        If (GetOEMDRO (1122)) > 0 Then        If (GetOEMDRO (1130)) < 0 Then        TMPNBR = (GetOEMDRO (1122)) * (-1)        ABXOL = (GetOEMDRO (1130)) + TMPNBR        End If        End If        If (GetOEMDRO (1122)) < 0 Then        If (GetOEMDRO (1130)) > 0 Then        TMPNBR = (GetOEMDRO (1122)) * (-1)        ABXOL = (GetOEMDRO (1130)) + TMPNBR        End If        End If                If (GetOEMDRO (1123)) > 0 Then        If (GetOEMDRO (1131)) > 0 Then        ABYOL = (GetOEMDRO (1131)) - (GetOEMDRO (1123))        End If        End If        If (GetOEMDRO (1123)) < 0 Then        If (GetOEMDRO (1131)) < 0 Then        ABYOL = (GetOEMDRO (1131)) - (GetOEMDRO (1123))        End If        End If        If (GetOEMDRO (1123)) > 0 Then        If (GetOEMDRO (1131)) < 0 Then        TMPNBR = (GetOEMDRO (1123)) * (-1)        ABYOL = (GetOEMDRO (1131)) + TMPNBR        End If        End If        If (GetOEMDRO (1123)) < 0 Then        If (GetOEMDRO (1131)) > 0 Then        TMPNBR = (GetOEMDRO (1123)) * (-1)        ABYOL = (GetOEMDRO (1131)) + TMPNBR        End If        End If                ABTOL = Sqr ((ABXOL * ABXOL) + (ABYOL * ABYOL))        'ABLEN = ABTGL + ABTOL                AXSTRT = (GetOEMDRO (1120)) +  (GetOEMDRO (1122))        AYSTRT = (GetOEMDRO (1121)) +  (GetOEMDRO (1123))        BXSTRT = (GetOEMDRO (1128)) +  (GetOEMDRO (1130))        BYSTRT = (GetOEMDRO (1129)) +  (GetOEMDRO (1131))        ABXLEN = (BXSTRT) - (AXSTRT)        If AYSTRT > BYSTRT Then        ABYLEN = AYSTRT - BYSTRT        End If        If AYSTRT < BYSTRT Then        ABYLEN = BYSTRT - AYSTRT        End If        If AYSTRT = BYSTRT Then        ABYLEN = 0        End If        ABLEN = Sqr ((ABXLEN * ABXLEN) + (ABYLEN * ABYLEN))                ABYTL = ABYGL + ABYOL        XScaAmt = (ABLEN/ABTGL)        'XScaAmt = XScaAmt - 1        'XScaAmt = XScaAmt * (-1)        'XScaAmt = XScaAmt + 1        SetOEMDRO(59, XScaAmt)          Sleep(50)        'Step 70  'Calculate  B-C scale  'lenght of line BC       'Message "Set Rotation"        If (GetOEMDRO (1128)) > (GetOEMDRO (1124)) Then        BCXGL = (GetOEMDRO (1128)) - (GetOEMDRO (1124))        End If        If (GetOEMDRO (1128)) < (GetOEMDRO (1124)) Then        BCXGL = (GetOEMDRO (1124)) - (GetOEMDRO (1128))        End If        If (GetOEMDRO (1128)) = (GetOEMDRO (1124)) Then        BCXGL = 0        End If                BCYGL = (GetOEMDRO(1125)) - (GetOEMDRO(1129))         BCTGL = Sqr ((BCXGL * BCXGL) + (BCYGL * BCYGL))                If (GetOEMDRO (1130)) > 0 Then        If (GetOEMDRO (1126)) > 0 Then        BCXOL = (GetOEMDRO (1126)) - (GetOEMDRO (1130))        End If        End If        If (GetOEMDRO (1130)) < 0 Then        If (GetOEMDRO (1126)) < 0 Then        BCXOL = (GetOEMDRO (1126)) - (GetOEMDRO (1130))        End If        End If        If (GetOEMDRO (1126)) > 0 Then        If (GetOEMDRO (1130)) < 0 Then        TMPNBR = (GetOEMDRO (1130)) * (-1)        BCXOL = (GetOEMDRO (1126)) + TMPNBR        End If        End If        If (GetOEMDRO (1130)) < 0 Then        If (GetOEMDRO (1126)) > 0 Then        TMPNBR = (GetOEMDRO (1130)) * (-1)        BCXOL = (GetOEMDRO (1126)) + TMPNBR        End If        End If                If (GetOEMDRO (1131)) > 0 Then        If (GetOEMDRO (1127)) > 0 Then        BCYOL = (GetOEMDRO (1127)) - (GetOEMDRO (1131))        End If        End If        If (GetOEMDRO (1131)) < 0 Then        If (GetOEMDRO (1127)) < 0 Then        BCYOL = (GetOEMDRO (1127)) - (GetOEMDRO (1131))        End If        End If        If (GetOEMDRO (1127)) > 0 Then        If (GetOEMDRO (1131)) < 0 Then        TMPNBR = (GetOEMDRO (1131)) * (-1)        BCYOL = (GetOEMDRO (1127)) + TMPNBR        End If        End If        If (GetOEMDRO (1131)) < 0 Then        If (GetOEMDRO (1127)) > 0 Then        TMPNBR = (GetOEMDRO (1131)) * (-1)        BCYOL = (GetOEMDRO (1127)) + TMPNBR        End If        End If                BCTOL = Sqr (( BCXOL * BCXOL) + (BCYOL * BCYOL))        'BCLEN = BCTGL + BCTOL                BXSTRT = (GetOEMDRO (1128)) +  (GetOEMDRO (1130))        BYSTRT = (GetOEMDRO (1129)) +  (GetOEMDRO (1131))        CXSTRT = (GetOEMDRO (1124)) +  (GetOEMDRO (1126))        CYSTRT = (GetOEMDRO (1125)) +  (GetOEMDRO (1127))        BCYLEN = (CYSTRT) - (BYSTRT)        If BXSTRT > CXSTRT Then        BCXLEN = BXSTRT - CXSTRT        End If        If BXSTRT < CXSTRT Then        BCXLEN = CXSTRT - BXSTRT        End If        If BXSTRT = CXSTRT Then        BCXLEN = 0        End If        BCLEN = Sqr ((BCXLEN * BCXLEN) + (BCYLEN * BCYLEN))                YScaAmt = (BCLEN/BCTGL)        'YScaAmt = YScaAmt - 1        'YScaAmt = YScaAmt * (-1)        'YScaAmt = YScaAmt + 1        SetOEMDRO(60, YScaAmt)                Sleep(50)        'To Step 80 'Calculate Rotation and Rotate                 RotABGR = Atn(ABYGL / ABTGL)        RotABTR = Atn(ABYTL / ABLEN)              RotR = RotABTR - RotABGR        RotD = RotR * 57.29577            Code "g68 R" & RotD	        Sleep(50)        'Set CDC to Final Functions                 SetOEMDRO(1110,5)                   'Step 90Else'Final FunctionsIf GetOEMDRO(1110) = 5 Then'Message "Shift X and Y and set new Home"       StartPosX = (GetDro(0))       StartPosY = (GetDro(1))       ShiftedStartX = (StartPosX) - (GetOEMDRO(1122))       ShiftedStartY = (StartPosY) - (GetOEMDRO(1123))       Code "G00 X" & ShiftedStartX & "Y" & ShiftedStartY       While IsMoving()       Sleep (100)       Wend       Code "G92 X" & StartPosX & "Y" & StartPosY 'Calculate Rotation and Rotate                       Code "G68 R 0.0"        'Calculate  B-C scale  'Reset lenght of line BC                       SetUserLED (1112,0)        SetOEMDRO(59, 1)        SetOEMDRO(60, 1)        SetOEMDRO(1110,0)        SetOEMDRO(1120,0)                SetOEMDRO(1121,0)        SetOEMDRO(1122,0)        SetOEMDRO(1123,0)        SetOEMDRO(1124,0)        SetOEMDRO(1125,0)        SetOEMDRO(1126,0)        SetOEMDRO(1127,0)        SetOEMDRO(1128,0)        SetOEMDRO(1129,0)        SetOEMDRO(1130,0)        SetOEMDRO(1131,0)        SetOEMDRO(1140,0)                SetOEMDRO(1141,0)        SetOEMDRO(1142,0)        SetOEMDRO(1143,0)        SetOEMDRO(1144,0)        SetOEMDRO(1145,0)        SetOEMDRO(1146,0)        SetOEMDRO(1147,0)        SetOEMDRO(1148,0)        SetOEMDRO(1149,0)        SetOEMDRO(1150,0)        SetOEMDRO(1151,0)        While IsMoving()        Sleep (100)        Wend     End If End IfEnd IfEnd IfEnd If                                                                