# How to get rotation of constrained object?

So let's imagine I have a gun pointing at a target. Gun has copy location constraint to locate to another object that rotates around the same axis as the gun. Gun has track to constraint to keep it pointing towards the target (just up/down movement, rotation around its y axis which is x axis in world space). On it's 0-position there is an initial angle of about 10 degrees of up (measured by hand).

How do you actually get the gun rotation so I can set its allowed range to -55 to +55 deg? How do I even get the gun rotation value at all? The gun object rotation in the n.menu transform panel is 0 and never changes no matter how I move the target. I've tried using limit rotation constraint but it is totally broken and just set's the object rotation to its max value

Here is a sample file: http://www.mediafire.com/file/c4x62lx6kmil7nu/constraints.zip/file The rotation of the rectangle object causes the "gun" to go outside of its rotation limits. The cylinder should point towards the target as long as its angle is inside its local rotation limits. These rotation limits come from the rectangle object.

In other words the angle limit is for the angle between the rectangle and the cylinder. Cylinder moves with the rectangle (rectangle just rotates) and cylinder points at the target as long as its angles are inside its limits.