Hi Paolo, AFAIK the problem here is that \tweak reads the next event of the input and you can't access those properties because the event has not been translated to a grob yet so lilypond has not yet calculated those values (others more suited than me may be able to explain it more elegantly or correct me if I have conceptual errors).
For these types of situations I use both the "before-line-breaking" and the "after-line-breaking" properties, both can be set to a function that is passed the grob as a variable. So we can do the following to achieve what you want: \version "2.19.83" token = #(let* ((ctr 0) (ctr! (lambda () (set! ctr (1+ ctr)) ctr))) (define-music-function (mus) (ly:music?) (let* ((id (format #f "foobar_~a" (ctr!))) (mexp #{ \tweak output-attributes.id #id #mus #} ) (type (ly:music-property mus 'name)) (mexp (case type ('BeamEvent #{ \tweak Beam.after-line-breaking #(lambda (grob) (let* ((outprop (ly:grob-property grob 'output-attributes)) (beam-thickness (ly:grob-property grob 'beam-thickness)) (outprop (append outprop `((beam-thickness . ,beam-thickness))))) (ly:grob-set-property! grob 'output-attributes outprop))) #mexp #} ) (else mexp)))) mexp))) \relative { c'4 d8 -\token [ e ] f -\token [ g ] c,4 } I wrote the token function in a way that I think will be easy for you to expand, testing for different types of events and saving different properties to the output attributes property. Hope this helps, Stéfano El mié., 18 dic. 2019 a las 17:11, Paolo Prete (<paolopr...@gmail.com>) escribió: > Hi Jaap, > > it doesn't fit with what I'm searching for (sorry: my question was not > enough clear) . > I need to obtain the property set/calculated by Lilypond, not the one set > by me. > Shortly: for a Beam, how can I: > > (set! myVar positions-of-the-beam-set-by-lilypond) > > or: > > (set! myVar Y-offset-of-the-beam-set-by-lilypond) > > ? > > I don't understand if these properties are user-only settable, or if they > are set by Lilypond too. > If they are not set by Lilypond, how can I obtain them and put them into > myVar ? > > My aim is to pass these properties to the SVG script through the " > output-attributes" mechanism, instead of having to parse the SVG output > with JS (which is possible too, but I would like to avoid that) > > Thanks, > P > > On Wed, Dec 18, 2019 at 6:57 PM <lilyp...@de-wolff.org> wrote: > >> Without giving you any solution, I can give you a hint: >> >> >> >> Write the music in the traditional way, with and without your >> modification. >> >> >> >> In your lilypond file put: >> >> \displayMusic oldmusic >> >> \displayMusic newmusic >> >> >> >> And what you can see wht you have to write by observing the differences >> >> >> >> Jaap >> >> >> >> *From:* lilypond-user <lilypond-user-bounces+lilypond= >> de-wolff....@gnu.org> *On Behalf Of *Paolo Prete >> *Sent:* Wednesday, December 18, 2019 3:30 PM >> *To:* Aaron Hill <lilyp...@hillvisions.com> >> *Cc:* lilypond-user <lilypond-user@gnu.org> >> *Subject:* Re: Need help with Scheme code >> >> >> >> Thanks again. >> >> Now, from what I see, I can extract if #mus is a Beam >> with (ly:music-property mus 'name) --> BeamEvent >> >> After that, how can I set, inside the same function you wrote, a variable >> with the beam-thickness value of the corresponding Beam? >> >> something like (pseudo code): (set! myVar >> current-value-of-beam-thickness ) >> >> >> >> >> >> >> >> On Wed, Dec 18, 2019 at 5:14 AM Aaron Hill <lilyp...@hillvisions.com> >> wrote: >> >> On 2019-12-17 6:01 pm, Paolo Prete wrote: >> > And thanks again to the Scheme-master Aaron. >> >> I appreciate the kind words, though I doubt my experience rises to the >> level of "master". >> >> > One last thing: >> > >> > how can I arrange that function so to obtain output-attributes = >> > output-attributes + id ? >> > >> > For example: if output-attributes is (('a' . 'aa') ('i' . 'ii')) it >> > must >> > become: (('a' . 'aa') ('i' . 'ii') ('id' . 'foobar_1')) >> >> Where or how are the other output-attributes being set? It is my >> understanding that output-attributes is unset by default, so any >> \override or \tweak would not need to worry about existing definitions. >> >> That said, consider this pattern: >> >> %%%% >> \version "2.19.83" >> { \tweak Accidental.output-attributes.id 123 bes'4 } >> %%%% >> >> Keep in mind this only *adds* a new key-value pair to the alist; it does >> not change an existing entry with the same key. >> >> >> -- Aaron Hill >> >>