[JW Lua] Snippet Exchange: Swap layers
Bart Visser
bartvisser at me.com
Thu Feb 13 15:24:05 CET 2014
Hi all,
I learn a lot from this list and from the examples on the website. Because most scripts are build from smaller components, I thought it would be helpful (for me and others) so share some snippets on this list. This makes it easier for new members to get going. It also gives the more experienced users small units to use in their more complicated scripts.
Below I've pasted a small snippet: Swap Layers.
function swap_layers(input_layer_x, input_layer_y)
local region = finenv.Region()
local selection = finale.FCMusicRegion()
selection:SetRegion(region)
for s = selection.StartStaff, selection.EndStaff do
local layer_a = finale.FCNoteEntryLayer((input_layer_x-1), s, selection.StartMeasure, selection.EndMeasure)
layer_a:Load()
local layer_b = finale.FCNoteEntryLayer((input_layer_y-1), s, selection.StartMeasure, selection.EndMeasure)
layer_b:Load()
layer_a.LayerIndex = input_layer_y-1
layer_a:Save()
layer_b.LayerIndex = input_layer_x-1
layer_b:Save()
end
end
swap_layers(1, 2)
I'll post more snippets in the coming days. If others find this useful, maybe you can post a snippet or two as well.
Cheers,
Bart Visser
More information about the JWLua
mailing list