Hi all.

I have some problems with frame rotation on Sinumerik 840D.

So i have 5 axis vertical mill with swivel table and i am trying to align my parts with custom program.
So i made a program and all works fine but frame rotation.
I have part with two slots on each side and it is clamped parallel with Y axis so that upper slot is in + from center of the table and lower is usually in - from center of
but it can be also in + if the mold is shorter than standard.
I have to align my mold so it is 100% parallel with Y axis and i am using those slots for that because i have to mill surface between them so they are perfectly connected.

So i measure their X value and calculated my angle with ATAN2 and i have to write it in zero offset but here is the problem.

If i use my angle value "ANG" as this $P_UIFR[1,C,TR]=ANG then i have rotated my C axis and this works just fine only when my mold is clamped in center of rotation what is rarely the case so i can't do that.

If i use my angle value "ANG" as this $P_UIFR[1,Z,RT] then i don't know what happens and i need help with that.
I know it is coordinate rotation but when it is activated my X offset changes and i don't know which X to use for my offset upper or lower.
Also sometimes my program zero is on top sometimes it is down.

Please help someone i can upload some pictures for explanation if needed