[JW Lua] Deleting Page Text

Jan Angermüller jan at angermueller.com
Wed Dec 9 08:17:15 CET 2020


Hi Martin,

IIRC you shouldn't call SaveAll() afterwards, here is a code snippet 
that I found somewhere in my plug-ins.
The original script does a bit more, so you don't need to have it that 
complicated. I just copied the lines from my script.
You can also use eachbackwards() for a backwards loop.

local pts=finale.FCPageTexts()
pts:LoadAll()
local systemdividers={}
for p in each(pts) do
     table.insert(systemdividers,{p.ItemCmper,p.ItemInci})
end

local pagetext=finale.FCPageText()
for i=#systemdividers,1,-1 do
       pagetext:Load(systemdividers[i][1],systemdividers[i][2])
       pagetext:DeleteData()
  end

Best,
Jan


Am 09.12.2020 um 08:09 schrieb Martin Marris:
>
> Greetings,
>
> I am trying to remove PageText items completely. I can delete the 
> child TextBlock element, leaving a blank string. But the parent 
> PageText item remains (in the form of visible, empty text handles all 
> over the score.).
>
> This is the code I am using to delete the child TextBlock data:
>
> local pagetexts = finale.FCPageTexts()
>
> pagetexts:LoadAll()
>
> local size = 0
>
> for pagetext in each(pagetexts) do
>
> size = size + 1 --this creates index data to be used in a later “for” loop
>
> local textblock = pagetext:CreateTextBlock()
>
> if textblock then
>
> textblock:DeleteData()
>
> end
>
> end
>
> pagetexts:SaveAll()
>
> And this is one of my many attempts to then delete the PageText items 
> themselves:
>
> local pagetexts = finale.FCPageTexts()
>
> pagetexts:LoadAll()
>
> for i = size, 1, -1 do --traverse backwards to avoid problems with 
> iteration of deleted objects
>
> pagetexts:DeleteDataForItem(i)
>
> end
>
> pagetexts:SaveAll()
>
> I have also tried all sorts of permutation of DeleteData(), 
> DeepDeleteData(), and ClearAll().
>
> It is almost as if the PageTexts collection is itself a child of 
> another object that needs to be deleted, too.
>
> Suggestions? Thanks!
>
> Martin Marris
>
>
> _______________________________________________
> JWLua mailing list
> JWLua at jwmusic.nu
> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu

-- 
Jan Angermüller
Dipl.-Ing.(FH) Dipl.-Jur.
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/20201209/12e851bf/attachment.htm>


More information about the JWLua mailing list