RobotStudio event

Can a robtarget rotation be easily converted to multidata & spin rotations?

I'll pose the question at the top, then explain my application lower down.

The question:

A robtarget has a quarternion/rot/orient component that can be created from Euler Angles, more specifically a ZY'X'' rotation. It seems that all rotations in robot studio are done in the order of Z, Y' then X''.

The exception to this rule is with the ArcRepL instruction & seam tracking. 
When a seam is tracked a set of seam coordinates is generated.
To rotate the tool during an ArcRepL instruction, multidata must be provided which includes a Y rotation about the seam coordinates, and an X' rotation about the seam coordinates. No Z rotation is accepted here, instead the MpOffsEaxOnPath instruction with the optional argument \SpinAngle must be used which allows the user to input a z rotation which is about the tool frame, not the seam frame. To make matters worse, these rotations are then applied in the order of Y,X' and then the tool Z, a different order to normal.

My question is how can a robtarget rotation in a seam workobject be converted to the seam Y,X' and tool Z rotations required by the ArcRepL function? 
Second to this, if anyone from ABB knows, why does ArcRepL work this way and why not just accept a quarternion input for the tool orientation relative to the tracked seam?

I am curious to hear about other people's experiences with ArcRepL rotations, has anyone else done any complicated rotations? 

Now for the application:

We are welding multiple (up to 48 of them) 90 degree T joints on a component with a 45 degree work angle, and due to the shape of the part and our torch we have to have a 45 degree push angle. Each T joint requires 3 passes, at different offsets and rotations. The first pass tracks fine at the 45 degree work angle.

The program is written so the user can "teach" offsets and rotations for multi pass welding as there are also some 30+ pass welds involved elsewhere on the part. For this the user jogs the TCP to the orientation & offset they want on one of the seams, and the position in seam coordinates is recorded. For the 48 T joints, each pass should be the same relative to the part, e.g. rotated towards the base or offset higher up the vertical plate etc. 

The tracked paths have 2 different configurations of seam coordinates:


The above image shows the tracked seam coordinates with a 45 degree work angle. Note that to rotate the torch so the work angle is more vertical, a counterclockwise rotation about the seam X axis is required on the left, and a clockwise rotation on the right is needed. 

The robtarget recorded by the user when teaching has a rotation quarternion that can be converted to Euler ZY'X'' angles. When the recorded path is replayed using ArcRepL, it accepts Y and X' angles through the multidata, then the Z rotation through the optional \SpinAngle argument of the MpOffsEaxOnPath function. 

The user will only ever apply a rotation about the x axis, the 45 degree push angle will always be needed.

Not only do I need to convert from one rotation type to the other, I also need to mirror the rotation about the seam X axis from one seam to the other as their coordinate systems are not the same, let alone what's required to play any passes in reverse. 

I am able to extract the seam X axis rotation from the taught robtarget, for example whether the user tilted the torch work angle upwards 15 degrees, and store that for use later. I can't figure out how to convert that rotation into the angles required by ArcRepL. I have attached pseudo code to try and explain the program a bit as well.

I am hoping there is a generic solution, or tool, as all I can get at the moment is very application specific ways of figuring out the required angles that doesn't work in all the cases I need it to.

Thanks for any help anyone can offer.