[JW Lua] metatools assignments

Jan Angermüller jan at angermueller.com
Thu Nov 12 15:28:01 CET 2015


I couldn't get it to work either.
The problem seems to be with expressions and articulations only.
When using MTOOLMODE_EXPRESSION 
<http://www.finaletips.nu/frameworkref/class_f_c_metatool_assignment.html#a066f55661ffa8c0866fb0a839e131355afdaea1bba27ffb31aa52f8132222720e> 
or MTOOLMODE_ARTICULATION 
<http://www.finaletips.nu/frameworkref/class_f_c_metatool_assignment.html#a066f55661ffa8c0866fb0a839e131355ae7835e68d5c68a82751f99afb983ed4d> 
FCMetatoolAssignment:CreateLinkedObject() always returned nil in my test 
cases. The other metatool assignment modes seem to work fine - or at 
least they return an object.

Jan

Am 12.11.2015 um 15:08 schrieb Joseph Weidinger:
> 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20151112/c5a4a2ed/attachment.htm>


More information about the JWLua mailing list