JWLua: working with rehearsal marks

General notation questions, including advanced notation, formatting, etc., go here.

Moderators: Peter Thomsen, miker

User avatar
HaraldS
Posts: 229
Joined: Mon Dec 19, 2016 11:46 am
Finale Version: 25.5
Operating System: Windows

Post by HaraldS » Sun Dec 06, 2020 11:15 am

Hello all,

I'm posting this for future reference, sort of work-in-progress to refer to. The following script collects information on letter and number rehearsal marks and displays them in the JWLua output window.

A possible goal in the future would be to convert rehearsal marks to bookmarks, as requested in a Facebook discussion. Obviously, JWLua does not have access to Finale's bookmarks, so no luck up to now.

Code: Select all

-- Goal is to convert rehearsal marks to bookmarks.
-- Up to now, JWLua doesn't have access to Finale's bookmarks, so the script simply collects information

local Count_REHMARKSTYLE_LETTER = 0
local Count_REHMARKSTYLE_NUMBER = 0
-- Rehearsal marks offsets aren't taken into account in this first version

local measures = finale.FCMeasures()
measures:LoadAll()

for meas in each(measures) do

    local expressions = finale.FCExpressions()
    expressions:LoadAllForItem( meas.ItemNo )    -- Load all elements for measure 1

    for e in each(expressions) do
        local ted= finale.FCTextExpressionDef()
        ted:Load( e.ID )
        local str = finale.FCString() 

       if ted:IsAutoRehearsalMark() == true then

            -- only two rehearsal mark styles are covered: simple letters and numbers. For all styles, see
            -- http://www.finaletips.nu/frameworkref/class_f_c_text_expression_def.html#a7cd4431a7e5fe768a26eedb47759ba48

            if ted.RehearsalMarkStyle == finale.REHMARKSTYLE_LETTER then
            -- Rehearsal style: Letters only (upper-case)
                Count_REHMARKSTYLE_LETTER = Count_REHMARKSTYLE_LETTER + 1
            -- works only for one-digit rehearsal marks, code needs enhancement to cover extended ones (AA, BB..)
                str =  string.char( 64+Count_REHMARKSTYLE_LETTER )
            end

            if ted.RehearsalMarkStyle == finale.REHMARKSTYLE_NUMBER then
            -- Rehearsal style: Numbers only
                Count_REHMARKSTYLE_NUMBER = Count_REHMARKSTYLE_NUMBER + 1
                str = Count_REHMARKSTYLE_NUMBER
            end

            print ("Measure ",meas.ItemNo , " contains rehearsal mark ",str)
        end
    end
end
Any enhancements are welcome.
Finale 3.0-25.5, German edition, Windows 7
trombonist, pianist, conductor / Recklinghausen, Germany


User avatar
motet
Posts: 8292
Joined: Tue Dec 06, 2016 8:33 pm
Finale Version: 2014.5,2011,2005,27
Operating System: Windows

Post by motet » Sun Dec 06, 2020 5:26 pm

I guess if you could make bookmarks from rehearsal marks they would appear on the drop-down menu, which would perhaps be an advantage over JWNavigate.

Thanks for posting this. I like to have rehearsal marks centered over the measure's left barline, but for double bars I have to manually add 6e to the placement to get it centered since Finale centers it over the leftmost of the two barlines. (And, perversely, in Scroll view it centers it over the rightmost of the two!). So I may well hack on your script to automate that. I sometimes have hundreds of rehearsal marks so this help a lot!

Can anyone confirm that in the latest version of Finale this positioning still centers over the leftmost bar of a double barline in Page view, and over the rightmost in Scroll view?
Attachments
scrollview.png
scrollview.png (39.49 KiB) Viewed 717 times
positioning.png
positioning.png (2.67 KiB) Viewed 717 times
pageview.png
pageview.png (49.57 KiB) Viewed 717 times

Post Reply