Hey Ron, adn vmax549,
Here is how I did G68 rotation calcs, from the Convo wizard..... in the VB and wizards thread, page 4 in screen designer.
you could pick, the first Rotation point, or get fancey and probe it what ever, or just transfer in the current X1 Y1 coor. for point 1,
which is the corner of the Vice or whatever.
Then you could Jog, or probe, or transfer in the second point X2, Y2.
note: x1 and x2 cannot be equal......
note: y1 and y2 cannot be equal......
Use 5 UserDROs,
The following was in a G68 calc angle button:
'***********start calc, button script*********************************
Sub Main()
'G68 angle calc
SetUserLed(1039,1) 'this led was flipped by a button, to signify using this function. to append it to the teach file in the Addoffset button at bottom.
x1=GetUserDRO(1081) 'put whatever userDROs you want here.
y1=GetUserDRO(1082)
x2=GetUserDRO(1095)
y2=GetUserDRO(1096)
D=1
pi = 4 * Atn(1)
If x2-x1=0 Then
Message("X2 cannot = X1!!")
Exit Sub
End If
If y2-y1=0 Then
Message("y2 cannot = y1!!")
Exit Sub
End If
If y2=0 Then
Message("y2 cannot = 0!!")
Exit Sub
End If
If x2=0 Then
Message("X2 cannot = 0!!")
Exit Sub
End If
If y2>y1 And x2>x1 Then
D=D*1
End If
If y2>y1 And x2<x1 Then
D=D*-1
End If
If y2<y1 And x2<x1 Then
D=D*1
End If
If y2<y1 And x2>x1 Then
D=D*-1
End If
a=y2-y1
b=x2-x1
ang=(180/pi) * Atn(a/b)
If D>0Then
SetUserDRO(1094,ang)
End If
If D<0Then
SetUserDRO(1094,ang)
End If
End Sub
Main
'********End Calc button script***********
The following was in a "Add Offsets button" that if the Use coordinate rotation button LED was on, (for to use it)
Then, this code was "Appended" to the teach file. I just took out the G68 stuff and did not put in all the other
stuff from that page............again open it up in screen designer if you want to see more crap..........
'*******Add Offsets button (with out Append and teach file stuff)**********
A=GetUserDRO(1081)
B=GetUserDRO(1082)
R=GetUserDRO(1094)
If GetUserLED(1039) then
Code "G68 A" & A & " B" & B & " R" & R
End If
'**********End Add Offsets button**********************
Scott