[JW Lua] Updating expression categories

Jan Angermüller jan at angermueller.com
Fri Mar 24 19:42:04 CET 2023


FCString:ReplaceCategoryFonts() is what you need.
This changes "Finale Maestro" dynamics to "Bravura".

local catnumber=1
local c=finale.FCCategoryDef()
c:Load(catnumber)

local f=finale.FCFontInfo()
c:GetMusicFontInfo(f)
f.Name="Bravura"
c:SetMusicFontInfo(f)
c:Save()

local te=finale.FCTextExpressionDefs()
te:LoadAll()
local t
for t in each(te) do
     if t.CategoryID==catnumber then
         local tstr=t:CreateTextString()
         if tstr then
tstr:ReplaceCategoryFonts(c,finale.CATEGORYMODE_MUSIC,true)
--tstr:ReplaceCategoryFonts(c,finale.CATEGORYMODE_TEXT,true)
--tstr:ReplaceCategoryFonts(c,finale.CATEGORYMODE_NUMBER,true)
             t:SaveTextString(tstr)
         end
     end
end

Jan

Am 24.03.2023 um 19:22 schrieb Robert Patterson:
> You have to rewrite the font info in the enigma string 
> <http://jwmusic.nu/jwplugins/wiki/doku.php?id=jwlua:enigmastrings>. I 
> think there are library functions to help with this. Look in 
> enigma_string library. Somewhere in the repo there's an example of 
> assigning an expressions to a category and syncing the font, but I 
> don't remember where now.
>
> On Fri, Mar 24, 2023 at 10:47 AM Aaron Sherber <aaron at sherber.com> wrote:
>
>     Hi Jan,
>
>     Thanks -- but update how? I've tried setting and unsetting
>     UseCategoryFonts, force setting the CategoryID, and using
>     exp.AssignToCategory(), but none of those seem to work.
>
>     Aaron.
>
>
>
>
>
>     On Fri, Mar 24, 2023 at 11:11 AM Jan Angermüller
>     <jan at angermueller.com> wrote:
>
>         Hi Aaron,
>
>         here is a very old mail from Jari. You need to update the
>         expressions with an extra loop.
>
>         Am 04.09.2014 um 18:29 schrieb Jari Williamsson:
>>         Some additional info: Expression defs are actually very weak
>>         linked with the categories in Finale (much more weak than the
>>         impression the UI gives). If you make changes to a category,
>>         you need to manually update all expression defs that connects
>>         that category.
>
>         Jan
>
>
>
>         Am 24.03.2023 um 14:06 schrieb Aaron Sherber:
>>         Hi all,
>>
>>         If I use FCCategoryDef to change the font of a category, it
>>         appears that existing expressions which are set to use the
>>         category font don't automatically pick up this change. If I
>>         go into the Expression Designer, the expressions still show
>>         using their old font. I need to uncheck and recheck "Use
>>         Category Fonts" in order to get each expression to update.
>>         Doing this in code (i.e., looping through
>>         FCTextExpressionDefs and setting UseCategoryFont to false and
>>         then true and saving) doesn't seem to work either.
>>
>>         Is there some programmatic way to get expressions to
>>         recognize changes to their categories?
>>
>>         Thanks,
>>         Aaron.
>>
>>         _______________________________________________
>>         JWLua mailing list
>>         JWLua at jwmusic.nu
>>         http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>
>         -- 
>         Jan Angermüller
>         Orchideenstieg 13
>         22297 Hamburg
>         Tel. 040 - 28 94 84 82
>         Mobil 0173 - 99 33 904
>         www.elbsound.studio  <http://www.elbsound.studio>
>
>         _______________________________________________
>         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

-- 
Jan Angermüller
Orchideenstieg 13
22297 Hamburg
Tel. 040 - 28 94 84 82
Mobil 0173 - 99 33 904
www.elbsound.studio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20230324/12a92c8a/attachment.htm>


More information about the JWLua mailing list