1
VB and the development of wizards / macro fix help
« on: February 20, 2024, 06:00:25 AM »
Good morning
I found a macro on the net, I adapted it to my needs, from the tests I did it seems to work, but since it is not within my capabilities I would like to be sure of its functioning without having problems. I wonder if someone (much more capable than me) could check it for me and possibly correct it.
I thank anyone who can help me. Regards
I found a macro on the net, I adapted it to my needs, from the tests I did it seems to work, but since it is not within my capabilities I would like to be sure of its functioning without having problems. I wonder if someone (much more capable than me) could check it for me and possibly correct it.
I thank anyone who can help me. Regards
Code: [Select]
Sub Main()
Dim Title As String
Begin Dialog TextBoxSample 250,15,180,335," RICERCA ANGOLO > "
Picture 25, 5, 130, 130, "c:\mach3\bitmaps\Ita_Screenset\ANGOLO2.bmp"
OKButton 30,312,40,15
CancelButton 100,312,40,15
GroupBox 5,140,170,165,"-- RICERCA ANGOLO",.GroupBox1
TextBox 15,160,25,12,.XPlateWidth
Text 45,162,128,8,"SPESSORE PIASTRA LATERALE X"
TextBox 15,178,25,12,.YPlateWidth
Text 45,180,128,8,"SPESSORE PIASTRA LATERALE Y"
TextBox 15,196,25,12,.Xrepos
Text 45,198,125,8,"SPOSTAMENTO LATERALE X"
TextBox 15,214,25,12,.Yrepos
Text 45,216,125,8,"SPOSTAMENTO LATERALE Y"
TextBox 15,232,25,12,.PlateHeight
Text 45,234,128,8,"ALTEZZA PIASTRA "
TextBox 15,250,25,12,.ProbeDiameter
Text 45,252,80,8,"DIAMETRO PROBE"
Text 55,272,80,8,"### VELOCITA' ###"
TextBox 15,288,25,12,.Velo
Text 42,290,110,8,"<-- VELOCE PIANO -->"
TextBox 140,288,25,12,.Pian
End Dialog
Dim Dlg1 As TextBoxSample
'Default Settings
Dlg1.Xrepos = 25 'Distanza per spostare X- prima di spostarsi verso il basso per la sonda
Dlg1.Yrepos = 25 'Distanza per spostare X- prima di spostarsi verso il basso per la sonda
Dlg1.XPlateWidth = 0 'SPESSORE LATERALE X
Dlg1.YPlateWidth = 0 'SPESSORE LATERALE Y
Dlg1.PlateHeight = 5 'ALTEZZA PIASTRA
Dlg1.ProbeDiameter = 3.0 'DIAMETRO PROBE
Dlg1.velo = 150 'VELOCITA' VELOCE
Dlg1.Pian = 40 'VELOCITA' PIANO
Button = Dialog (Dlg1)
If Button = 0 Then Exit Sub
Xrepos = Val(Dlg1.Xrepos)
Yrepos = Val(Dlg1.Yrepos)
XPlateWidth = Val(Dlg1.XPlateWidth)
YPlateWidth = Val(Dlg1.YPlateWidth)
PlateHeight = Val(Dlg1.PlateHeight)
ProbeDiameter = Val(Dlg1.ProbeDiameter)
velo = Val(Dlg1.velo)
Pian = Val(Dlg1.Pian)
Cutter_Size = ProbeDiameter
Cutter_Size2 = Cutter_Size/2
Plate_X_Offset = XPlateWidth
Plate_Y_Offset = YPlateWidth
Plate_Z_Offset = 0
Plate_X_Offset1 = -1*(Plate_X_Offset+Cutter_Size2)
Plate_Y_Offset1 = -1*(Plate_Y_Offset+Cutter_Size2)
Message( "Probing routine initialized" )
If IsSuchSignal (22) Then
SetDRO(0,0) 'set X DRO a Zero
SetDRO(1,0) 'set Y DRO a Zero
SetDRO(2,0) 'set Z DRO a Zero
Sleep 10
code "G90"
'Z Probing
code "G31 Z-30 F" & velo
While IsMoving()
Wend
Sleep 50
code "G0 G91 Z1"
While IsMoving()
Wend
code "G31 Z-10 F" & Pian
While IsMoving()
Wend
ZProbePos = GetOEMDRO(802)
code "G90"
code "G0 Z" &ZProbePos
While IsMoving()
Wend
Call SetDro(2, Plate_Z_Offset)
Sleep 100
code "G0 Z5"
End If
'Y Probing
If IsSuchSignal (22) Then
code "G0 Y-" & Yrepos
code "G0 Z-8"
code "G31 Y5 F" & velo
While IsMoving()
Wend
Sleep 50
code "G0 G91 Y-3"
While IsMoving()
Wend
code "G31 Y5 F" & Pian
While IsMoving()
Wend
YProbePos = GetOEMDRO(801)
code "G90"
code "G0 Y" &YProbePos
While IsMoving()
Wend
Call SetDro(1, Plate_Y_Offset1)
Sleep 100
code "G0 Y-18"
code "G0 Z5"
code "G0 Y10"
End If
'X Probing
If IsSuchSignal (22) Then
code "G0 X-" & Xrepos
code "G0 Z-8"
code "G31 X5 F" & velo
While IsMoving()
Wend
Sleep 50
code "G0 G91 X-3"
While IsMoving()
Wend
code "G31 X5 F" & Pian
While IsMoving()
Wend
XProbePos = GetOEMDRO(800)
code "G90"
code "G0 X" &XProbePos
While IsMoving()
Wend
Call SetDro(0, Plate_X_Offset1)
Sleep 100
code "G0 X-18"
code "G0 Z10"
End If
Sleep 100
code "G0 X0.0"
code "G0 Y0.0"
While IsMoving()
Wend
z=GetOEMDRO(802)
z=Z+PlateHeight
SetOEMDRO(802,z)
Message( "Probing routine complete" )
End Sub