[JW Lua] Move NoteEntries

Jari Williamsson jari.williamsson at mailbox.swipnet.se
Mon Aug 25 09:18:59 CEST 2014


Bart,

Here's a few notes about your script.

* The eachentrysaved() uses the FCNoteEntryCell class internally, so 
trying to use both at the same time would lead to strange things.

* The first parameter in MoveEntry() must belong to the FCNoteEntryCell 
collection used as the second parameter.

* Since you want to move the whole note entries, there's no need to 
parse the individual notes in the entry (chord).

* Another thing that complicate things here is that 
FCNoteEntryCell:Save() after a FCNoteEntryCell:MoveEntry() would remove 
elements from a collection, which makes iterators such as each(), 
eachentry(), eachentrysaved() unsuitable.


Below is a version that should work. My version constantly moves the 
first entry in the FCNoteEntryCell collection. Since that first entry is 
deleted, there will always be a "new" first entry to move. And it moves 
the entries until the FCNoteEntryCell collection is empty.

---
local region = finenv.Region()

local selectedMeasureCell = finale.FCNoteEntryCell(region.StartMeasure, 
region.StartStaff)
selectedMeasureCell:Load()

local newMeasureCell = finale.FCNoteEntryCell((region.StartMeasure + 1), 
region.StartStaff)
newMeasureCell:Load()

while newMeasureCell:GetItemAt(0) ~= nil do
     local noteentry = newMeasureCell:GetItemAt(0)
     local result = selectedMeasureCell:MoveEntry(noteentry, 
newMeasureCell)
     if not result then break end
     selectedMeasureCell:Save()
     newMeasureCell:Save()
end
---


Best regards,

Jari Williamsson


On 2014-08-24 20:49, Bart Visser wrote:
> Hi,
>
> I'm trying to move note entries from one cell to another one, but nothing happens (MoveEntry returns false for each entry). Is there something I'm doing wrong?
>
> Thanks,
>
>
> Bart
>
> local region = finenv.Region()
>
> local selectedMeasureCell = finale.FCNoteEntryCell(region.StartMeasure, region.StartStaff)
> selectedMeasureCell:Load()
>
> local newMeasureCell = finale.FCNoteEntryCell((region.StartMeasure + 1), region.StartStaff)
> newMeasureCell:Load()
>
> for noteentry in eachentrysaved(region) do
>      for note in each(noteentry) do
>          current_entry = note:GetEntry()
>          local result = selectedMeasureCell:MoveEntry(current_entry, newMeasureCell)
>          print(result)
>          selectedMeasureCell:Save()
>          newMeasureCell:Save()
>      end
> end
> _______________________________________________
> JWLua mailing list
> JWLua at jwmusic.nu
> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>
>






More information about the JWLua mailing list