[JW Lua] Adding notes in empty measures

Thomas Weber thomas.weber at notengrafik.com
Wed Nov 18 08:59:28 CET 2015


Hi all,

so far, I've mostly used JWLua to modify stuff that's already in a file or add things like expressions.  However, I have a hard time trying to create new note entries.  Should I feel stupid missing something obvious?  Here's something that I tried to add a note:


local cell=finenv.Region():CreateCells():GetItemAt(0)
if cell then
    local nECell = cell:CreateNoteEntryCell(true, 0)
    -- Delete what's there; works.
    for entry in eachbackwards(nECell) do
        nECell:DeleteEntry(entry)
    end
    -- Now create something new; doesn't work like this.
    local entry=nECell:AppendEntriesInLayer(1, 1)
    entry:MakeNote()
    entry.Duration = finale.WHOLE_NOTE
    local note = entry:AddNewNote()
    if note then
        -- Check whether we have a meaningful note
        print(note:CalcPitchChar(), note:CalcOctave(cell:GetKeySignature(), 0))
        print(entry:CalcNondottedDuration(), entry:CalcDots())
    end
    -- Not sure whether the following Save() calls are actually needed,
    -- the deletion works even without them.
    nECell:Save()
    cell:Save()
    -- Do we also need to save the entry?
    -- If so, how?  entry:Save() does not exist.
end



P.S.: The recent developments are awesome!  I really need to find the time to dig into the new GUI possibilities.




More information about the JWLua mailing list