Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: pedropin on November 26, 2021, 12:07:06 AM

Title: help macro to call g54 , g55, g56, g57,g58, g59, g60
Post by: pedropin on November 26, 2021, 12:07:06 AM
Hello, how are you? I have built a machine that has 7 heads,
I would like to know if you can create a macro that when reading a tool change in g code, the macro calls the offset in the X and Y axes of that tool.
I tried but I don't understand any programming and
I've seen videos of machines doing it but I can't.
I only have this macro M6 star but it does not work well for me
Thank you
attentively

'get new tool number
   newtool = GetSelectedTool()

       'select Offset by toolnumber
       If newtool = 1 Then
           Code "G54"
       Else         
           Code "G55"
           
      End If
   
           
        If newtool = 2 Then
           Code "G55"
         Else       
           Code "G56"       
   
       End If       
       
       
        If newtool = 3 Then
           Code "G56"
       Else   
       
           Code "G57"   
     
   
       End If



Title: Re: help macro to call g54 , g55, g56, g57,g58, g59, g60
Post by: TPS on November 26, 2021, 02:43:49 AM
maybe this is what you are looking for

Code: [Select]
'get new tool number
newtool = GetSelectedTool()

'select Offset by toolnumber
If newtool = 1 Then
Code "G54"
End If
If newtool = 2 Then
Code "G55"
End If
If newtool = 3 Then
Code "G56"
End If
If newtool = 4 Then
Code "G57"
End If
If newtool = 5 Then
Code "G58"
End If
If newtool = 6 Then
Code "G59"
End If
If newtool = 7 Then
Code "G59P7"
End If
Title: Re: help macro to call g54 , g55, g56, g57,g58, g59, g60
Post by: TPS on November 26, 2021, 02:47:36 AM
this version will also set new toollength if it is set in tooltable

Code: [Select]
'get new tool number
newtool = GetSelectedTool()

'select Offset by toolnumber
If newtool = 1 Then
Code "G54"
End If
If newtool = 2 Then
Code "G55"
End If
If newtool = 3 Then
Code "G56"
End If
If newtool = 4 Then
Code "G57"
End If
If newtool = 5 Then
Code "G58"
End If
If newtool = 6 Then
Code "G59"
End If
If newtool = 7 Then
Code "G59P7"
End If
 
SetCurrentTool(newtool)
Code "G43H" 6 newtool

       

Title: Re: help macro to call g54 , g55, g56, g57,g58, g59, g60
Post by: pedropin on November 26, 2021, 09:23:08 AM
Thank you very much this is what I need, how good the help of this forum.
why in the last line of the code you write?
  Code "G59P7"

have a good day and thank you again
Title: Re: help macro to call g54 , g55, g56, g57,g58, g59, g60
Post by: TPS on November 26, 2021, 11:17:46 AM
if you have a look to config -> fixtures there is no G60 the next after G59 is G59P7.
Title: Re: help macro to call g54 , g55, g56, g57,g58, g59, g60
Post by: pedropin on November 29, 2021, 10:34:46 AM
ahhh I understood thank you sir
Title: Re: help macro to call g54 , g55, g56, g57,g58, g59, g60
Post by: TPS on June 16, 2022, 04:05:14 AM
you mean:
Code: [Select]
Code "G43H" &newtool

it is just to activate tool length compensation

the original code:
Code: [Select]
Code "G43H" 6 newtool
was faulty the 6 has to be a &