Hi Steven,

On Thu, May 19, 2016 at 4:01 PM, Steven Weber <pant...@hotmail.com> wrote:
> Is there any way to get the context from a grob?

Not that I know of.

> Or is there another way to
> get the current bar number from a grob?

Yes, you can do this using the function grob::rhythmic-location which
will return a pair consisting of the bar number and the moment within
that bar of the passed-in grob.

Example of usage:

\version "2.19.30"

#(define after-break-function
   (lambda (grob)
     (let* ((loc (grob::rhythmic-location grob))
            (bar (car loc))
            (mom (cdr loc))
            (name (grob::name grob)))
       (format #t "~%~a at ~a of measure ~a" name mom bar))))

\relative c {
  \override NoteHead.after-line-breaking = #after-break-function
  \repeat unfold 20 { c2 d }
}

I don't remember when the function was introduced, but you will need
one of the development releases (2.19.something) to use it (and
grob::name as well).

Hope this gets you started--
David

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to