<div dir="ltr"><div dir="ltr">Hi Robert,<div><br></div><div>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.</div><div><br></div><div>What I'm still not able to do is to clear a staff style from the score. Does anybody know how to do this?</div><div><br></div><div>Thanks!</div><div><br></div><div>Emile</div><div><br></div><div><div>function CreateStaffStyles()</div><div>    local staffstyledefs = finale.FCStaffStyleDefs()</div><div>    staffstyledefs:LoadAll()</div><div>    local newID = 0</div><div>    local createNew = true</div><div>    for ssd in each(staffstyledefs) do</div><div>        local myEFIXDistance = 1</div><div>        ssd.LineSpacing = myEFIXDistance</div><div>        local argString = finale.FCString()</div><div>        ssd:GetName(argString)</div><div>        if argString.LuaString == "Trumpet in B-flat" then createNew = false end</div><div>        local myIDResult = ssd:GetItemNo()</div><div>        if createNew and myIDResult >= newID then newID = myIDResult end</div><div>    end</div><div>    staffstyledefs:SaveAll()</div><div><br></div><div>    if createNew then -- Create new staff styles</div><div>        local ssd = finale.FCStaffStyleDef()</div><div>        if ssd:Load(1) then</div><div>            ssd.AddToMenu = true</div><div>            local string = finale.FCString()</div><div>            for i = 1, #allinstruments do</div><div>                string.LuaString = allinstruments[i]</div><div>                ssd:SetName(string)</div><div>                ssd:SetUseNotationStyle(false)</div><div>                ssd:SetUseTransposition(true)</div><div>                ssd.TransposeInterval = interval[i]</div><div>                ssd.TransposeAlteration = keyalter[i]</div><div>                --local myIDResult = ssd:SetItemNo(22)</div><div>                local myBooleanResult = ssd:DeepSaveAs(newID+i)</div><div>            end</div><div>        end </div><div>    end</div><div>return newID end</div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Op zo 4 okt. 2020 om 15:49 schreef Robert Patterson <<a href="mailto:robert@robertgpatterson.com">robert@robertgpatterson.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>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.</div><div><br></div><div>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.</div><div><br></div><div>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 <a href="https://github.com/Nick-Mazuk/jw-lua-scripts#resources" target="_blank">here</a>.</div><div><br></div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Oct 4, 2020 at 8:35 AM Emile Meuffels <<a href="mailto:e.meuffels@gmail.com" target="_blank">e.meuffels@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">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...<div><br></div><div>My code is based on the example script on the Lua-site (where "style" is a local decided by the program before):</div><div><br></div><div><div>    local musicRegion = finale.FCMusicRegion()</div><div>    musicRegion:SetCurrentSelection()</div><div>    local startbar = musicRegion:GetStartMeasure()</div><div>    local endbar = musicRegion:GetEndMeasure()</div><div>    local ssa = finale.FCStaffStyleAssign()</div><div>    ssa.StyleID = style</div><div>    ssa.StartMeasure = startbar</div><div>    ssa.StartMeasurePos = 0</div><div>    ssa.EndMeasure = endbar</div><div>    ssa:SetEndMeasurePosRight()</div><div>    ssa:SaveNew(1)</div></div><div><br></div><div>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.</div><div>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...</div><div><br></div><div>Any idea how I can make this work?</div><div><br></div><div>All the best,</div><div><br></div><div>Emile</div></div></div>
_______________________________________________<br>
JWLua mailing list<br>
<a href="mailto:JWLua@jwmusic.nu" target="_blank">JWLua@jwmusic.nu</a><br>
<a href="http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu" rel="noreferrer" target="_blank">http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu</a><br>
</blockquote></div>
_______________________________________________<br>
JWLua mailing list<br>
<a href="mailto:JWLua@jwmusic.nu" target="_blank">JWLua@jwmusic.nu</a><br>
<a href="http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu" rel="noreferrer" target="_blank">http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu</a><br>
</blockquote></div>