[JW Lua] Staff-stuff (create, transposition, name)

Jari Williamsson jari.williamsson at mailbox.swipnet.se
Fri Apr 25 13:26:48 CEST 2014


Bart,

Your code will not work if the staves doesn't have any existing staff 
name to overwrite. When I wrote this reply, I discovered that the latest 
JW Lua version you have doesn't have the SaveNewFullNameString() method, 
which was implemented after the last beta release.

Here's a modified version (for the next JW Lua build). Note that I also 
also modified it to check that the staff ID exists in the document, by 
checking that the table result is non-nil.


function set_staff_names()
	local all_staves = finale.FCStaves()
	all_staves:LoadAll()
	for staff in each(all_staves) do
		current_name = staff:CreateFullNameString()
             if (staff_names[staff.ItemNo]) then
                 current_name.LuaString = staff_names[staff.ItemNo] 

                 if not staff:SaveFullNameString(current_name) then
                     staff:SaveNewFullNameString(current_name)
                     staff:Save()
                 end
             end
	end
end

The methods SetTransposeAlteration() and SetTransposeInterval() are also 
implemented in the next build. Would that cover what you need?

Saving new staves will arrive later. Now I'll prepare a new beta build 
of the stuff that have been implemented since the last public beta. I'll 
see if I can get creation of new staves in the build after that one.


Best regards,

Jari Williamsson


On 2014-04-17 12:36, Bart Visser wrote:
> Hi all,
>
> I try to name a bunch of new staves with JW Lua:
>
>
> local staff_names = {
> 	[1] = "C",
> 	[4] = "Bb-bas",
> 	[5] = "C-bas",
> 	[6] = "Bb",
> 	[7] = "Eb-laag",
> 	[8] = "F",
> 	[9] = "Eb-hoog",
> }
>
> function set_staff_names()
> 	local all_staves = finale.FCStaves()
> 	all_staves:LoadAll()
> 	for staff in each(all_staves) do
> 		current_name = staff:CreateFullNameString()
>          	current_name.LuaString = staff_names[staff.ItemNo]
>          	print(staff:SaveFullNameString(current_name))
> 	end
> end
>
> set_staff_names()
>
> It doesn't work (keeps returning false when calling the SaveFullNameString-method). Is there a way to get this working?
>
>
> Also I would like to set the transposition of each staff (interval -6, etc.). If I read the documentation correctly, this isn't possible at the moment (you can get it but not set it). Would it be possible to add this function?
>
>
> And while I'm mailing about staff-stuff: is it already possible to create a staff (with all kinds of custom properties) from scratch? (This wasn't possible when I first asked a few months ago).
>
> Thanks,
>
>
> Bart Visser
>
> _______________________________________________
> JWLua mailing list
> JWLua at jwmusic.nu
> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>
>






More information about the JWLua mailing list