[JW Lua] Deleting all parts

Jan Angermüller jan at angermueller.com
Wed Aug 9 08:54:24 CEST 2017


Jari et al,

what is the best way to delete all parts in a script?

Do I need SwitchTo?    (both options seem to work)
Do I need DeepDeleteData or DeleteData?  (both options seem to work)

The script below seems to delete the parts, but when I click on 
"Document->Edit Part->..." right after running the script it still lists 
all parts.
Only when I open Document->Manage Parts after running the script I see 
that all parts have been deleted. And after looking into Manage Parts 
"Document->Edit Part->..." also has cleared its list.
So I am not sure, if everything was really deleted correctly through the 
script.
It could also be that this is a Finale bug: the menu structure 
("Document->Edit Part") is not updated correctly or at all through a 
plugin call.

Code snippet:
local parts=finale.FCParts()
parts:LoadAll()
for p in eachbackwards(parts) do
     if p.ID~=finale.PARTID_SCORE then
         p:SwitchTo()
             p:DeepDeleteData()
         p:SwitchBack()
     end
end

Best,
Jan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20170809/cb4e692a/attachment.htm>


More information about the JWLua mailing list