[JW Lua] Help Adding Articulation
Jan Angermüller
jan at angermueller.com
Sat Sep 29 20:21:57 CEST 2018
>I'm amazed you've been able to do your elaborate plug-ins with such a
lack of information.
Unfortunately I couldn't test the code before I sent you the correction.
At first sight I only noticed the SaveNew() missing.
But indeed I have never added an articulation before, I have only used
"articulation clone" ("AddArticulations") in my plug-ins and this only
to already existing notes.
And I think I have not even used FCNoteEntryCell:AppendEntriesInLayer
before, I have always used FCNoteEntryLayer:InsertEntriesAfter.
I remember having problems with AppendEntriesInLayer which I didn't have
with InsertEntriesAfter. Maybe it was the reload? I don't know.
Your original script was nearly ok (I mean the one that you sent me via
PM, it was different than the one on the list).
It only needed the SaveNew() and, as Chris pointed out, the reload.
Here is your corrected original script - slightly differen than Chris'
which is more optimized.
For example entry.ArticulationFlag=true is not necessary (but indeed
faster) if you use notecell:Save() as you did in your script.
function plugindef()
-- This function and the 'finaleplugin' namespace
-- are both reserved for the plug-in definition.
return "Fermatas", "", ""
end
local fermatadef = finale.FCArticulationDef()
local metatools = finale.FCMetatoolAssignments()
metatools:SetMode(2)
metatools:LoadAll()
for metatool in each(metatools) do
if metatool.Keystroke == 70 then
fermatadef:Load(metatool:GetDefID())
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()
notecell:Save() --this line added
local index = notecell:GetIndexOf(entry) --this line added
notecell:Load() --this line added
entry = notecell:GetItemAt(index) --this line added
local fermata = finale.FCArticulation()
fermata:SetArticulationDef(fermatadef)
fermata:SetNoteEntry(entry)
fermata:SaveNew() --this line changed
notecell:Save()
end
end
end
Jan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20180929/fe86897c/attachment.htm>
More information about the JWLua
mailing list