[JW Lua] Help adding articulation

Bryan Higgins bryan at motet.com
Fri Sep 28 22:26:19 CEST 2018


JW Lua neophyte here, struggling. I'm trying to write a script to find
all empty measures in the selected region and add a whole rest with a
fermata. The code successfully finds the "F" articulation metatool, but
I don't know how to proceed from there to an articulation I can add to
the whole rest (which I'm able to create). How do I add the fermata to
the rest? Here is my code. If fails at "articulations:Add(fermata)" with
"attempt to call method 'Add' (a nil value)". 

function plugindef()
   -- This function and the 'finaleplugin' namespace
   -- are both reserved for the plug-in definition.
   return "Fermatas", "", ""
end
local fermata = finale.FCArticulation()
local metatools = finale.FCMetatoolAssignments()
metatools:SetMode(2)
metatools:LoadAll()
for metatool in each(metatools) do
   if metatool.Keystroke == 70 then
      fermata:SetID(metatool:GetDefID())
      fermata:Reload()
      break
   end
end

for m, s in eachcell(finenv.Region()) do
   local cell = finale.FCCell(m, s)
   notecell = finale.FCNoteEntryCell(m, s)
   notecell:Load()
   if notecell:IsEmpty() then
      entry = notecell:AppendEntriesInLayer(1, 1)
      if entry then
         entry.Duration = finale.WHOLE_NOTE
         entry.Legality = true
         entry:MakeRest()
         articulations = entry:CreateArticulations()
         articulations:Add(fermata)
         articulations:Save()
         notecell:Save()
      end
   end
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20180928/cedb5f20/attachment.html>


More information about the JWLua mailing list