[JW Lua] metatools assignments

Jari Williamsson jari.williamsson at mailbox.swipnet.se
Fri Nov 13 09:32:37 CET 2015


Joseph/Jan,

A couple of things:
1. There's an error in the script. The expression must be saved before 
it's assigned to a metatool key. Put the "ted:SaveNew()" before the 
metatool assignment.
2. However, I also found an error in both AssignTextExpressionDef() and 
AssignShapeExpressionDef() that prevents expression metatools to be 
assigned correctly. This will be fixed in the next beta. I didn't found 
any such bug in AssignArticulationDef though.
3. There seems to be some strange thing regarding SaveAsKeystroke() as 
well, but I haven't found the cause of this yet.


Best regards,

Jari Williamsson

On 2015-11-12 15:08, Joseph Weidinger wrote:
> Jari, any advice on this? I still cannot get a metakey assigned, even
> after taking your advice into consideration. I made a bare minimum
> example that demonstrates what won't work on this. It SHOULD create a
> new text expression called "test" (which it does) and assign it to
> metakey "a" (which it does not)
> ---------------------------------------------------------------------------
> local ted = finale.FCTextExpressionDef()
>
> -- actual text of expression
> expText = "test"
> stringObject = finale.FCString()
> stringObject.LuaString = "^fontTxt(Times New
> Roman,4096)^size(14)^nfx(1)" .. expText
> ted:SaveNewTextBlock(stringObject)
>
> -- put into expression category
> catdef = finale.FCCategoryDef()
> catdef:Load(4)
> ted:AssignToCategory(catdef)
>
> -- assign metakey "a"
> local ma = finale.FCMetatoolAssignment()
> ma:SetMode(finale.MTOOLMODE_EXPRESSION)
> ma:AssignTextExpressionDef(ted)
> ma:SaveAsKeystroke(65)
>
> ted:SaveNew()
> ------------------------------------------------------------------------------
>
> On Sun, Nov 8, 2015 at 8:07 AM, Joseph Weidinger <jsphweid at gmail.com
> <mailto:jsphweid at gmail.com>> wrote:
>
>     So I moved that above metatool assignment and wrapped a print around
>     AssignTextExpressionDef. Still no metatool assignment but it *does*
>     return true...
>
>     On Sun, Nov 8, 2015 at 7:55 AM, Jan Angermüller
>     <jan at angermueller.com <mailto:jan at angermueller.com>> wrote:
>
>         I haven't tested it, but maybe call ted:SaveNew() *before
>         *assigning the metatool ?
>         I am not sure, but the text expression might need "to be
>         registered in the system" before assigning the metatool.
>         Does AssignTextExpressionDef
>         <http://www.finaletips.nu/frameworkref/class_f_c_metatool_assignment.html#ab9c22e27b1d9d30357d5a8d63b775acb>
>         return true ?
>
>
>
>         Am 08.11.2015 um 14:39 schrieb Joseph Weidinger:
>>         Thanks.  However, I did all of those things and it still does
>>         assign the metakey. Here is the updated part + the rest of the
>>         relevant code in case maybe it is part of a larger problem (?).
>>
>>         function makeBoldAbove(expressionText)
>>         local ted = finale.FCTextExpressionDef()
>>
>>         -- actual text
>>         stringObject = finale.FCString()
>>         stringObject.LuaString = "^fontTxt(Times New
>>         Roman,4096)^size(14)^nfx(1)" .. expressionText
>>         ted:SaveNewTextBlock(stringObject)
>>
>>         -- description
>>         local descriptionstr = finale.FCString()
>>         descriptionstr.LuaString = expressionText -- get it from
>>         userinput also, why not
>>         ted:SetDescription(descriptionstr)
>>
>>         -- put into which category?
>>         catdef = finale.FCCategoryDef()
>>         catdef:Load(4) -- 4 is expressions
>>         ted:AssignToCategory(catdef)
>>
>>         -- we will not use standard positioning
>>         ted:SetUseCategoryPos(false)
>>
>>         -- here is the positioning data
>>         ted:SetVerticalAlignmentPoint(finale.ALIGNVERT_ABOVE_STAFF_BASELINE_OR_ENTRY)
>>         ted:SetVerticalBaselineOffset(-26)
>>         ted:SetVerticalEntryOffset(36)
>>         ted:SetHorizontalJustification(finale.EXPRJUSTIFY_LEFT)
>>         ted:SetHorizontalAlignmentPoint(finale.ALIGNHORIZ_CLICKPOS)
>>         ted:SetHorizontalOffset(0)
>>         ted:SetBreakMMRest(false)
>>
>>
>>         local ma = finale.FCMetatoolAssignment()
>>         ma:SetMode(finale.MTOOLMODE_EXPRESSION)
>>         ma:AssignTextExpressionDef(ted)
>>         ma:SaveAsKeystroke(65)
>>
>>         ted:SaveNew()
>>
>>         return ted:GetItemNo()
>>         end
>>
>>         local expressionID = makeBoldAbove("test") -- create it and
>>         get its new ID
>>
>>
>>         On Sun, Nov 8, 2015 at 5:47 AM, Jari Williamsson
>>         <jari.williamsson at mailbox.swipnet.se
>>         <mailto:jari.williamsson at mailbox.swipnet.se>> wrote:
>>
>>             Joseph,
>>
>>             In addition to what Jan said:
>>             * Remove the call to SaveNew(), since it isn't needed.
>>             SaveNew() should only be used for classes that can save a
>>             list of objects to the same location. SaveAsKeyStroke() is
>>             the SaveAs method to use for metatool assignments.
>>
>>             * Put the AssignTextExpressionDef before the save,
>>             otherwise the connection to the text expression def will
>>             not be saved to Finale.
>>
>>
>>             Best regards,
>>
>>             Jari Williamsson
>>
>>             On 2015-11-08 11:07, Jan Angermüller wrote:
>>
>>                 As the online documentation says for
>>                 AssignTextExpressionDef:
>>                 "The mode for the object must be set to
>>                 MTOOLMODE_EXPRESSION *in advance*. "
>>
>>                 So you need a SetMode before.
>>
>>                 Jan
>>
>>                 Am 08.11.2015 um 09:04 schrieb Joseph Weidinger:
>>
>>                     I am creating a new text expression definition
>>                     (ted) and that part
>>                     works. However it won't assign the metakey "a"
>>                     (which is 65 apparently)
>>
>>                     I try to do this:
>>                     ~ ted defined and working great
>>
>>                     local ma = finale.FCMetatoolAssignment()
>>                     ma:SaveAsKeystroke(65)
>>                     ma:SaveNew()
>>                     ma:AssignTextExpressionDef(ted)
>>
>>                     ted:SaveNew()
>>
>>                     Maybe it has something to do with set mode? I
>>                     coculdn't get anything
>>                     to work. Help appreciated! Thanks.
>>
>>
>>
>>
>>                     _______________________________________________
>>                     JWLua mailing list
>>                     JWLua at jwmusic.nu <mailto:JWLua at jwmusic.nu>
>>                     http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>>
>>
>>
>>
>>                 _______________________________________________
>>                 JWLua mailing list
>>                 JWLua at jwmusic.nu <mailto:JWLua at jwmusic.nu>
>>                 http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>>
>>
>>
>>
>>             _______________________________________________
>>             JWLua mailing list
>>             JWLua at jwmusic.nu <mailto:JWLua at jwmusic.nu>
>>             http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>>
>>
>>
>>
>>         _______________________________________________
>>         JWLua mailing list
>>         JWLua at jwmusic.nu <mailto:JWLua at jwmusic.nu>
>>         http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>
>
>         _______________________________________________
>         JWLua mailing list
>         JWLua at jwmusic.nu <mailto: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
>






More information about the JWLua mailing list