[JW Lua] (For 0.05) Copy System Layout
Jari Williamsson
jari.williamsson at mailbox.swipnet.se
Tue Sep 17 20:02:30 CEST 2013
Hello All!
On the SHSU list, Steve Fiskum wanted a feature to just copy the system
layout between parts "before TGTools is obsolete". So here's a script
that should do that - it works with 0.05 (available soon). It uses the
popup list feature of 0.05.
Best regards,
Jari Williamsson
-------------- next part --------------
function plugindef()
-- This function and the 'finaleplugin' namespace
-- are both reserved for the plug-in definition.
finaleplugin.CategoryTags = "Layout, System, UI"
return "Copy System Layout", "Copy System Layout", "Copies the system margin values between parts."
end
local part = finale.FCPart(finale.PARTID_CURRENT)
if part:IsScore() then
print("You're in a score...")
return
end
-- Read all parts and assemble those who aren't the current part
local parts = finale.FCParts()
parts:LoadAll()
local lookuptable = {}
local otherparts = {}
local lookuptableidx = 1
for part in each(parts) do
if not part:IsScore() and not part:IsCurrent() then
local partstring = part:GetName()
table.insert(otherparts, partstring.LuaString)
lookuptable[lookuptableidx] = part
lookuptableidx = lookuptableidx + 1
end
end
if lookuptableidx == 1 then
print ("No parts to copy from")
return
end
-- Display the other parts in dialog box
local dialog = finenv.UserValueInput()
dialog:SetTypes("NumberedList")
dialog:SetDescriptions("Copy system layout from:")
dialog:SetInitValues(1)
dialog:SetLists(otherparts)
dialog.Title = "Copy System Layout"
local returnvalues = dialog:Execute()
if returnvalues == nil then return end
-- Read the other part's systems
local otherpart = lookuptable[returnvalues[1]]
otherpart:SwitchTo()
local othersystems = finale.FCStaffSystems()
othersystems:LoadAll()
otherpart:SwitchBack()
-- Apply to current part
local thesesystems = finale.FCStaffSystems()
thesesystems:LoadAll()
for system in each(thesesystems) do
if system.ItemNo > othersystems:GetCount() then break end
local othersystem = othersystems:GetItemAt(system.ItemNo - 1)
-- Copy system margin values
system.LeftMargin = othersystem.LeftMargin
system.RightMargin = othersystem.RightMargin
system.BottomMargin = othersystem.BottomMargin
system.TopMargin = othersystem.TopMargin
system.SpaceAbove = othersystem.SpaceAbove
system:Save()
end
More information about the JWLua
mailing list