If LilyPond stored the measure numbers in the annotation it would be possible, but not otherwise. So it's a feature request for LilyPond. (I think that would be easy to implement in LilyPond.) Actually LilyPond could generate a lot of other information in a separate file, because when rendering a grob, it has access to the Music element that renders the grob.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If LilyPond stored the measure numbers in the annotation it would be possible, but not otherwise. So it's a feature request for LilyPond. (I think that would be easy to implement in LilyPond.) Actually LilyPond could generate a lot of other information in a separate file, because when rendering a grob, it has access to the Music element that renders the grob.