381
VB and the development of wizards / Re: Moving tool magazine with 14 drill heads
« on: May 14, 2021, 01:54:46 AM »
i have tested this here, and it works:
'start code ------------------------------------------------------------------------
Sub Main
'Get tool information
newtool = GetSelectedTool() ' get the newtool
acttool = GetCurrentTool() ' get the acttool
Message "New Tool = " &newtool
Sleep(200)
' new and acttool = 0
If ((newtool = 0) and (acttool = 0)) Then
message("new and old tool = 0 -> abort toolchange !")
Sleep(500)
Exit Sub
End If
' new tool = 0
If (newtool = 0) Then
DoButton(1003)
message("new tool = 0 -> abort toolchange !")
Sleep(500)
Exit Sub
End If
' new and acttool are the same
If newtool = acttool Then
message("acttool and newtool are the same -> do nothing!")
Sleep(500)
Exit Sub
End If
'check toolnumber in range
If (((newtool > 14) Or (newtool < 1)) And (newtool <> 0)) Then
DoButton(1003)
Message (" toolnumber " & newtool & " is not in range (1-" &MaxTool &"). abort toolchange ! ")
MsgBox (" toolnumber " & newtool & " is not in range (1-" &MaxTool &"). abort toolchange ! ")
Exit Sub
End If
'toolnumber 1 mastertool
If newtool = 1 Then
Code ("G52 X0 Y0")
End If
'toolnumber 2
If newtool = 2 Then
Code ("G52 X32 Y0")
End If
'toolnumber 3
If newtool = 3 Then
Code ("G52 X64 Y0")
End If
'And so ON
'set new tool
SetCurrentTool( newtool )
Code ("G43 H" & newtool)
Message " "
End Sub
'end code ------------------------------------------------------------------------
'start code ------------------------------------------------------------------------
Sub Main
'Get tool information
newtool = GetSelectedTool() ' get the newtool
acttool = GetCurrentTool() ' get the acttool
Message "New Tool = " &newtool
Sleep(200)
' new and acttool = 0
If ((newtool = 0) and (acttool = 0)) Then
message("new and old tool = 0 -> abort toolchange !")
Sleep(500)
Exit Sub
End If
' new tool = 0
If (newtool = 0) Then
DoButton(1003)
message("new tool = 0 -> abort toolchange !")
Sleep(500)
Exit Sub
End If
' new and acttool are the same
If newtool = acttool Then
message("acttool and newtool are the same -> do nothing!")
Sleep(500)
Exit Sub
End If
'check toolnumber in range
If (((newtool > 14) Or (newtool < 1)) And (newtool <> 0)) Then
DoButton(1003)
Message (" toolnumber " & newtool & " is not in range (1-" &MaxTool &"). abort toolchange ! ")
MsgBox (" toolnumber " & newtool & " is not in range (1-" &MaxTool &"). abort toolchange ! ")
Exit Sub
End If
'toolnumber 1 mastertool
If newtool = 1 Then
Code ("G52 X0 Y0")
End If
'toolnumber 2
If newtool = 2 Then
Code ("G52 X32 Y0")
End If
'toolnumber 3
If newtool = 3 Then
Code ("G52 X64 Y0")
End If
'And so ON
'set new tool
SetCurrentTool( newtool )
Code ("G43 H" & newtool)
Message " "
End Sub
'end code ------------------------------------------------------------------------