[JW Lua] get all items of "Expression Tool"
Bart Visser
bartvisser at me.com
Mon May 9 21:02:36 CEST 2016
Hi Robert,
Welcome to the list. As far as I know, there is no direct way to list all expressions in a category (there would probably need to be a Class-Function for something like that). The way to go forward is to load all TextEpressionDefs and look at each one of them to see if it’s attached to the Misc-category:
--------
function IsMiscCategory(inputExpressionDef)
local allCategories = finale.FCCategoryDefs()
allCategories:LoadAll()
for thisCategory in each(allCategories) do
if thisCategory.ID == inputExpressionDef.CategoryID then
local categoryName = thisCategory:CreateName()
print(categoryName.LuaString)
if categoryName.LuaString == "Miscellaneous" then return true end
end
end
return false
end -- function IsRehearsalCategory(inputExpression)
local miscExpressions = {}
-- This handles all TextExpression
-- In case you also need ShapeExpressions use
-- local exprdefs = finale.FCShapeExpressionDefs()
-- and repeat the process
local exprdefs = finale.FCTextExpressionDefs()
exprdefs:LoadAll()
for exprdef in each(exprdefs) do
if IsMiscCategory(exprdef) then
miscExpressions[#miscExpressions + 1] = exprdef.ItemNo
end
end
print(#miscExpressions) -- Number of all Misc Expressions
--------
I hope this helps.
All the best,
Bart Visser
> Op 8 mei 2016, om 18:37 heeft Robert Wildling <robertwildling at gmail.com> het volgende geschreven:
>
> Hi,
>
> this is my first post and also my first day with JW Lua from a developer point of view. Quite amazing, what can be done with it!
>
> Currently I would like to adapt the awesome DoubleStaffMMR Lua script that is somewhere out the in the forums. Whenever this plugin is applied, it creates one (and only one!) MultiMeasureRest number to a 2-staff-system instruments, hiding the default settings (which make a MMR appear twice).
>
> The numbers are created as text expressions saved in the "Miscellaneous" category. The disadvantage of this plugin is that it creates a number for each measure, not checking whether a number already exists as a text expression. So I would like to fetch all the data that can be found in the "Miscellaneous" category, check against the "Description" field (where is says "DoubleStaffMMR_[number]") and use the existing item, or only then create a new item.
>
> That's the theory. Now for the practical part: How do I fetch all items from the "Miscellaneous" category?
>
> Thanks for any tips!
>
> Greetings,
> Robert
> _______________________________________________
> JWLua mailing list
> JWLua at jwmusic.nu
> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
More information about the JWLua
mailing list