[JW Lua] Staff Styles

Robert Patterson robert at robertgpatterson.com
Sun Oct 11 14:57:14 CEST 2020


Switch to Score view. Find the FCStaffStyleAssign, if any. Call DeleteData
if found.

(I haven't done it myself, but that's what I would try.)

On Sun, Oct 11, 2020 at 7:35 AM Emile Meuffels <e.meuffels at gmail.com> wrote:

> Hi Robert,
>
> Thank you for your advice. I now wrote a function which loads all the
> staff styles in a document, creates new ones if the ones I need (which are
> transpositions for different instruments which I created in separate
> tables) are not there already and returns the staff style id for the new
> staff style. I have added the code here as it might help somebody else.
>
> What I'm still not able to do is to clear a staff style from the score.
> Does anybody know how to do this?
>
> Thanks!
>
> Emile
>
> function CreateStaffStyles()
>     local staffstyledefs = finale.FCStaffStyleDefs()
>     staffstyledefs:LoadAll()
>     local newID = 0
>     local createNew = true
>     for ssd in each(staffstyledefs) do
>         local myEFIXDistance = 1
>         ssd.LineSpacing = myEFIXDistance
>         local argString = finale.FCString()
>         ssd:GetName(argString)
>         if argString.LuaString == "Trumpet in B-flat" then createNew =
> false end
>         local myIDResult = ssd:GetItemNo()
>         if createNew and myIDResult >= newID then newID = myIDResult end
>     end
>     staffstyledefs:SaveAll()
>
>     if createNew then -- Create new staff styles
>         local ssd = finale.FCStaffStyleDef()
>         if ssd:Load(1) then
>             ssd.AddToMenu = true
>             local string = finale.FCString()
>             for i = 1, #allinstruments do
>                 string.LuaString = allinstruments[i]
>                 ssd:SetName(string)
>                 ssd:SetUseNotationStyle(false)
>                 ssd:SetUseTransposition(true)
>                 ssd.TransposeInterval = interval[i]
>                 ssd.TransposeAlteration = keyalter[i]
>                 --local myIDResult = ssd:SetItemNo(22)
>                 local myBooleanResult = ssd:DeepSaveAs(newID+i)
>             end
>         end
>     end
> return newID end
>
> Op zo 4 okt. 2020 om 15:49 schreef Robert Patterson <
> robert at robertgpatterson.com>:
>
>> Just because the name starts with the text "22" doesn't mean the staff
>> style number is 22. Most likely the staff style has a different number in
>> the new file. The most reliable way to find the correct number is to search
>> the staff styles for the name you want.
>>
>> Also, I believe that assigning a staff style in this manner only assigns
>> it in the current part or score. You should test this, at least. If you
>> want it assigned in all, you'll have to cycle through the parts for the
>> part(s) containing that staff.
>>
>> Finally, you might find my Enigma Text Dump plugin handy for figuring
>> these things out. You can find a link in the Resources section of the
>> ReadMe here <https://github.com/Nick-Mazuk/jw-lua-scripts#resources>.
>>
>>
>>
>>
>>
>> On Sun, Oct 4, 2020 at 8:35 AM Emile Meuffels <e.meuffels at gmail.com>
>> wrote:
>>
>>> I have been experimenting with adding staff styles through JW Lua to
>>> change the transposition of an instrument and I'm getting some results I
>>> don't understand...
>>>
>>> My code is based on the example script on the Lua-site (where "style" is
>>> a local decided by the program before):
>>>
>>>     local musicRegion = finale.FCMusicRegion()
>>>     musicRegion:SetCurrentSelection()
>>>     local startbar = musicRegion:GetStartMeasure()
>>>     local endbar = musicRegion:GetEndMeasure()
>>>     local ssa = finale.FCStaffStyleAssign()
>>>     ssa.StyleID = style
>>>     ssa.StartMeasure = startbar
>>>     ssa.StartMeasurePos = 0
>>>     ssa.EndMeasure = endbar
>>>     ssa:SetEndMeasurePosRight()
>>>     ssa:SaveNew(1)
>>>
>>> If I create a Staff Style and I name it "22. Transposition in G" and
>>> then set the local "style" to 22, this script works as expected.
>>> For the next step I created all the necessary staff styles and saved
>>> them as a library. If I load the library in a new file, I can see the "22.
>>> Transposition in G" staff style, but when I run the script, a staff style
>>> is added, but this one doesn't transpose. It also doesn't show a name...
>>>
>>> Any idea how I can make this work?
>>>
>>> All the best,
>>>
>>> Emile
>>> _______________________________________________
>>> JWLua mailing list
>>> JWLua at jwmusic.nu
>>> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>>>
>> _______________________________________________
>> JWLua mailing list
>> JWLua at jwmusic.nu
>> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>>
> _______________________________________________
> JWLua mailing list
> JWLua at jwmusic.nu
> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20201011/e1b1a6f3/attachment-0001.html>


More information about the JWLua mailing list