Funny I just did this recently on my ar. First I divide the scope diameter by half, measure height of rings/mount (from lowest ring to where the mount sits on the rail) then measure and divide the barrel diameter by half (where it is flush with handguard) then measure from the top of the barrel to top of picatiny rail on handguard. Add them all up and you have your height over bore.
For bolt guns, I use a straight edge or long level and lightly clamp it onto the rings mounting surface. Measure end of barrel diameter and divide by half. Measure from the bottom tip of the barrel to bottom of level/straight edge. Then subtract the half of barrel diameter. Add ring height and half of scope tube diameter and you have your bore over height.
Sounds complicated, but it truly is easy. I use it for laser bore sighting software. I think there is also a company that makes a magnetic tool that sticks into the bore and you look through the scope to get the height over bore measurement. YMMV.