[JW Lua] JWLua Digest, Vol 34, Issue 11
Jan Angermüller
jan at angermueller.com
Wed May 11 18:02:57 CEST 2016
You should check the class browser to see if a Save() is available.
Usually a class has at least one Save() or similar function like
SaveNew, SaveAs...
Only subclasses like FCSmartShapeSegment that are directly connected to
a main class don't have it. There you need to save the main class after
updating the subclass.
It's also described in detail in the mail archive.
Am 11.05.2016 um 17:35 schrieb Robert Wildling:
> Jan, thanks so much!
>
> I tried this script, it works without throwing an error - but also
> without the expected result. Is there probably a Save() command I am
> not aware of?
>
> ----------------------
> function plugindef()
> -- Requires the creation of a new category "ZZZ_NOT_USED";
> -- TODO: items (textExprDef) moved to that category could loose
> -- some aspects, if certain features of an item are available in
> the cateory
> finaleplugin.CategoryTags = "Expression"
> return "CreateUnusedCategory", "undoCreateUnusedCategory", "Create
> a category that will hold all unused elements"
> end
>
> -- Find category with name "ZZZ_NOT_USED"; needs to be created manually!
> local catMoveToName = finale.FCString()
> catMoveToName.LuaString = "ZZZ_NOT_USED"
>
> -- Prepare the category, where unused elements will be moved to
> -- (needs to be in the global namespace, not within a funcion!
> Therefore it is defined here.)
> local moveToCat = finale.FCCategoryDef()
>
> -- To do so, load all categories and seach for the Name string of the
> local catNotUsed = finale.FCCategoryDefs()
> catNotUsed:LoadAll()
>
> for cd in each(catNotUsed) do
> local catName = cd:CreateName()
>
> -- if a category with the name "ZZZ_NOT_USED" is found, get its ID
> and load that very category
> if catName.LuaString == "ZZZ_NOT_USED" then
> local catID = cd:GetID()
> moveToCat:Load(catID)
>
> -- just for debugging purposes, get the name again and display
> it in the console
> local moveToCatName = moveToCat:CreateName()
> print("NAME: ", moveToCatName.LuaString)
>
> end
> end
>
> --local catMoveToItemNo = catNotUsed:FindName(catMoveToName) --
> returns an object of type "userdata"
>
> -- prepare some FCString variables
> local tedName = finale.FCString()
> local tedDescr = finale.FCString()
>
> -- Now, get all textExpressionDefinitons
> local textexpressiondefs = finale.FCTextExpressionDefs()
> textexpressiondefs:LoadAll()
>
> for ted in each(textexpressiondefs) do
> --get ItemNo of this txtExprDef
> local tedItemNo = ted:GetItemNo()
>
> -- get the Category ID to which this txtExprDef is assigned to
> local tedCatID = ted:GetCategoryID()
>
> -- based on the retrieved category ID, load that very category and
> retrieve its name (for debug display)
> local cat = finale.FCCategoryDef();
> cat:Load(tedCatID)
>
> local catName = finale.FCString()
> cat:GetName(catName)
>
> -- Just as a test, get all textExpreDef from the category test and
> move them to "ZZZ_NOT_USED"
> -- Later on there should be a check, whether any of these items it
> NOT in use in the score - but how??? TODO
> if catName.LuaString == "TEST" then
> --ted.AssignToCategory(moveToCat) -- not working; the online
> documentation says "FCCategoryDef expected", the error console
> "'AssignToCategory' (FCTextExpressionDef expected, got __FCBase)"
> print(moveToCat:GetID())
> ted:SetCategoryID(moveToCat:GetID())
> local descr = finale.FCString()
> descr.LuaString = "Moved Item"
> ted:SetDescription(descr);
> end
>
> end
>
>
>
>
> *Robert Wildling*
> Göllnergasse 19/30 || A-1030 Vienna
> ph: +43 676 6089613
> @: robertwildling at gmail.com <mailto:robertwildling at gmail.com>
>
> 2016-05-11 15:39 GMT+02:00 <jwlua-request at jwmusic.nu
> <mailto:jwlua-request at jwmusic.nu>>:
>
> Send JWLua mailing list submissions to
> jwlua at jwmusic.nu <mailto:jwlua at jwmusic.nu>
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
> or, via email, send a message with subject or body 'help' to
> jwlua-request at jwmusic.nu <mailto:jwlua-request at jwmusic.nu>
>
> You can reach the person managing the list at
> jwlua-owner at jwmusic.nu <mailto:jwlua-owner at jwmusic.nu>
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of JWLua digest..."
>
>
> Today's Topics:
>
> 1. Creating a new Expression Category (Robert Wildling)
> 2. Re: Creating a new Expression Category (Jan Angerm?ller)
> 3. Re: FCStaffStyleDef:Load(...) always returns true (Chris)
> 4. Re: Creating a new Expression Category (Robert Wildling)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 11 May 2016 13:56:18 +0200
> From: Robert Wildling <robertwildling at gmail.com
> <mailto:robertwildling at gmail.com>>
> To: jwlua at jwmusic.nu <mailto:jwlua at jwmusic.nu>
> Subject: [JW Lua] Creating a new Expression Category
> Message-ID:
>
> <CAM9gVwSTQ8=DyuZotB6DmyYi-XQGO0-ZiWnz_02Z=NWwU=AJQQ at mail.gmail.com
> <mailto:AJQQ at mail.gmail.com>>
> Content-Type: text/plain; charset="utf-8"
>
> Hi,
>
> I am looking for a way to create a new Expression Category withe
> the name
> of "unused" (the intention is to move all unused textExprDefs and
> ShaeexprDefs to that category).
>
> Starting out, I thought, this can only be done via selecting a
> specific
> category and saving it using "SaveAs" and a new "ItemNo", like this:
>
> ``[lua]
> local dynCat = finale.FCCategoryDef()
> if dynCat:Load(2) then
> -- get the category name
> local catName = finale.FCString()
> dynCat:GetName(catName)
>
> -- save it anew
> dynCat:SaveNew()
>
> -- shows tha a new item number
> -- was generated (65535 ??? looks like an error...)
> print(dynCat:GetItemNo())
> end
> ``
>
> But even though the category is assigned a new number (is 65535 an
> indicator for an error here? look strange), no new category was
> created.
> And if the ItemNo of the original category was changed, a second
> run-through shouldn't work, since Load(2) shouldn't find anything
> at that
> position... but it does...
>
> I am very confused... any hints and/or help would be much appreciated!
> Thanks!
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20160511/42fed95e/attachment-0001.html>
>
> ------------------------------
>
> Message: 2
> Date: Wed, 11 May 2016 14:12:12 +0200
> From: Jan Angerm?ller <jan at angermueller.com
> <mailto:jan at angermueller.com>>
> To: "The JW Lua script plug-in." <jwlua at jwmusic.nu
> <mailto:jwlua at jwmusic.nu>>
> Subject: Re: [JW Lua] Creating a new Expression Category
> Message-ID: <38d7462a-ddd4-cad8-5c30-7fb50fc2828c at angermueller.com
> <mailto:38d7462a-ddd4-cad8-5c30-7fb50fc2828c at angermueller.com>>
> Content-Type: text/plain; charset="windows-1252"; Format="flowed"
>
> From the documentation
> http://www.finaletips.nu/frameworkref/class_f_c_category_def.html:
>
> "Please note that Finale does not allow plug-ins to create or delete
> category definitions."
>
>
> Am 11.05.2016 um 13:56 schrieb Robert Wildling:
> > Hi,
> >
> > I am looking for a way to create a new Expression Category withe the
> > name of "unused" (the intention is to move all unused
> textExprDefs and
> > ShaeexprDefs to that category).
> >
> > Starting out, I thought, this can only be done via selecting a
> > specific category and saving it using "SaveAs" and a new "ItemNo",
> > like this:
> >
> > ``[lua]
> > local dynCat = finale.FCCategoryDef()
> > if dynCat:Load(2) then
> > -- get the category name
> > local catName = finale.FCString()
> > dynCat:GetName(catName)
> >
> > -- save it anew
> > dynCat:SaveNew()
> >
> > -- shows tha a new item number
> > -- was generated (65535 ??? looks like an error...)
> > print(dynCat:GetItemNo())
> > end
> > ``
> >
> > But even though the category is assigned a new number (is 65535 an
> > indicator for an error here? look strange), no new category was
> > created. And if the ItemNo of the original category was changed, a
> > second run-through shouldn't work, since Load(2) shouldn't find
> > anything at that position... but it does...
> >
> > I am very confused... any hints and/or help would be much
> appreciated!
> > Thanks!
> >
> >
> > _______________________________________________
> > JWLua mailing list
> > JWLua at jwmusic.nu <mailto: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/20160511/39d4b744/attachment-0001.html>
>
> ------------------------------
>
> Message: 3
> Date: Wed, 11 May 2016 15:37:46 +0200
> From: Chris <marcel.denio at gmail.com <mailto:marcel.denio at gmail.com>>
> To: jwlua at jwmusic.nu <mailto:jwlua at jwmusic.nu>
> Subject: Re: [JW Lua] FCStaffStyleDef:Load(...) always returns true
> Message-ID: <57fc603d-4678-1507-c5e3-ea330daa3b16 at gmail.com
> <mailto:57fc603d-4678-1507-c5e3-ea330daa3b16 at gmail.com>>
> Content-Type: text/plain; charset="utf-8"; Format="flowed"
>
> Hello Jan
>
> The problem is that the list index (ItemNo) is broken:
> 1 2 3 4 5 6 7 8 9 10 .... 13 .... 20 ... 25 ......
> But why ???
>
> With this script, you retrieve the list (66 is your last index) :
>
> ---------------------------------------------
> for i =1,66 do
> local namestr=finale.FCString()
> local s=finale.FCStaffStyleDef()
> s:Load(i)
> s:GetName(namestr)
>
> if namestr.LuaString=="" then
> local name = finale.FCString()
> name.LuaString = "dummy " .. i
> s:SetName(name)
> s:Save()
> end
> end
> ---------------------------------------------
>
> Best regards
>
> Chris
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20160511/b214123e/attachment-0001.html>
>
> ------------------------------
>
> Message: 4
> Date: Wed, 11 May 2016 15:38:34 +0200
> From: Robert Wildling <robertwildling at gmail.com
> <mailto:robertwildling at gmail.com>>
> To: jwlua at jwmusic.nu <mailto:jwlua at jwmusic.nu>
> Subject: Re: [JW Lua] Creating a new Expression Category
> Message-ID:
>
> <CAM9gVwQx+AjmT_j091qYX8PXm7HtKJcW9Jw3-sTQFFU=n8Mp_g at mail.gmail.com
> <mailto:n8Mp_g at mail.gmail.com>>
> Content-Type: text/plain; charset="utf-8"
>
> Thanks, Jan!
>
> (Why do I not receive an email, when you post your answer? hmmm...)
>
> Does this also mean that I cannot move around TextExpressionDefs
> from one
> Cat to another? Provided that I can check whether the item is used
> in the
> score or not (which I still didn't find the proper method for...)
>
> Best,
> Robert
>
> 2016-05-11 13:56 GMT+02:00 Robert Wildling
> <robertwildling at gmail.com <mailto:robertwildling at gmail.com>>:
>
> > Hi,
> >
> > I am looking for a way to create a new Expression Category withe
> the name
> > of "unused" (the intention is to move all unused textExprDefs and
> > ShaeexprDefs to that category).
> >
> > Starting out, I thought, this can only be done via selecting a
> specific
> > category and saving it using "SaveAs" and a new "ItemNo", like this:
> >
> > ``[lua]
> > local dynCat = finale.FCCategoryDef()
> > if dynCat:Load(2) then
> > -- get the category name
> > local catName = finale.FCString()
> > dynCat:GetName(catName)
> >
> > -- save it anew
> > dynCat:SaveNew()
> >
> > -- shows tha a new item number
> > -- was generated (65535 ??? looks like an error...)
> > print(dynCat:GetItemNo())
> > end
> > ``
> >
> > But even though the category is assigned a new number (is 65535 an
> > indicator for an error here? look strange), no new category was
> created.
> > And if the ItemNo of the original category was changed, a second
> > run-through shouldn't work, since Load(2) shouldn't find
> anything at that
> > position... but it does...
> >
> > I am very confused... any hints and/or help would be much
> appreciated!
> > Thanks!
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20160511/0d4f4d61/attachment.html>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> JWLua mailing list
> JWLua at jwmusic.nu <mailto:JWLua at jwmusic.nu>
> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>
>
> ------------------------------
>
> End of JWLua Digest, Vol 34, Issue 11
> *************************************
>
>
>
>
> _______________________________________________
> 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/20160511/25166ba4/attachment-0001.html>
More information about the JWLua
mailing list