Hy. This is my first post becouse i have no idea how to solve my problem and i was recommended this forum to ask for help. First of all this is amazing community you have here wish i heard for it before. And sorry for my english

Now i have Huron K2X8Five and it is five axis machine with rotary table and sinumerik 820D.
I have to make measuring program for workpices that we do around the clock.
I now how to align workpice with cycle 988 it calculates rotation around X and Y
I now how to determin X and Y zerro ofset in one point with cycle978 but align it in Y axis by using two groves i have no idea hov to do.

So i have two groves each on other side of the workpiece and they are usualy turned. Now i have to measure those two and calculate rotation arround Z to align my workpiece with Y axis.



Here is a part of my code the comments are in croatian

; MJERNI PROGRAM HURON
; T20 TICALO RENISHAW
msg( " MJERNI PROGRAM " )
CYCLE800(2,"KX8F",0,57,0,0,0,0,0,0,0,0,0,-1)
CYCLE800(,"0",,,,,,,,,,,,)
G90 G17 G40 G0 G94 G642
T20 D1
M6
msg( " PORAVNANJE RAVNINE U TRI TOCKE " )
G75 Z0.
G0 A0. C0.
G54 ;ODREDITI NULU ZA PISANJE PROGRAMA
G0 X-40. Y-180. ;POCETNA TOCKA MJERANJA
G1 Z30. F1000. ;PRIBLIZAVANJE ZA TOCKU P1
_VMS=0 ;BRZINA MJERENJA (NE DIRAJ)
_PRNUM=1 ;PODACI O TICALU (NE DIRAJ)
_TSA=20 ;SIGURNOSNA ZONA (NE DIRAJ)
_EVNUM=0 ;METRICKE VRIJEDNOSTI (NE DIRAJ)
_NMSP=1 ;BROJ MJEREJA PO TOCKI (NE DIRAJ)
_FA=30 ;UDALJENOST POVRSINE OD TOCKE P1
_STA1=0 ;KUT ALFA 0 (NE DIRAJ)
_INCA=0 ;KUT BETA 0 (NE DIRAJ)
_MVAR=100106 ;VRSTA MJERENJA (NE DIRAJ)
_MD=1 ;SMJER MJERANJA (NE DIRAJ)
_ID=80 ;UDALJENOST OD P1 DO P2 PO X OSI
_SETV[0]=160 ;UDALJENOST OD P1 DO P3 PO Y OSI
_KNUM=1 ;UPISUJE VRIJEDNOSTI U G54
CYCLE988 ;POZIVANJE CIKLUSA (NE DIRAJ)
G54
CYCLE800(2,"KX8F",0,57,0,0,0,0,0,0,0,0,0,-1)
msg( " MJERENJE NULE PO Z MOZE I U FAZONI " )
G75 Z0.
G0 X30. Y-5. ;POZICIJA ZA MJERENJE NULE PO Z
G1 Z30. F1000 ;PRIBLIZAVANJE ZA TOCKU P1
_MVAR=100 ;VRSTA MJERENJA (NE DIRAJ)
_SETVAL=0 ;KOREKCIJA ZA Z (PAZI!!!)
_MA=3 ;MJERI SE Z (NE DIRAJ)
_TSA=30 ;SIGURNOSNA ZONA NA P1
_FA=30 ;UDALJENOST OD P1 DO MJERENE POVRSINE
_KNUM=1 ;MJERI SE G54
CYCLE978


Thank you for your time and please help me