This page contains some longer scripts that are "feature complete" in terms of their interaction with the Finale user. For shorter script examples, please refer to the page with [[jwlua:quickscripts|quick scripts]]. The [[jwlua:harpglisssample|Using JW Lua - Create Harp Gliss]] page also contains a full script that might be of interest. ==== Locked Systems Per Page ==== This script will create page layouts with a predefined number of systems per page, by setting the page break attribute to the measure that should break a page. (Finale will only break a page if the measure with the page break attribute appears first on a system.) First, the script provides a user input dialog with 3 options: * Number of systems per page * Start page * Max number of pages that should be processed Please note the syntax for using a static member function in //JW Lua//, in this case ''UpdateFullLayout()'' in the ''FCStaffSystems'' class, which can be called using the syntax: ''finale.FCStaffSystems.UpdateFullLayout()''. function plugindef() -- This function and the 'finaleplugin' namespace -- are both reserved for the plug-in definition. finaleplugin.Author = "Jari Williamsson" finaleplugin.CategoryTags = "Layout, Page, System, UI" return "Locked Systems Per Page", "Locked Systems Per Page", "Creates a predefined number of systems per page (by inserting page breaks)." end -- Show user dialog box local dialog = finenv.UserValueInput() dialog.Title = "Systems Per Page" dialog:SetTypes("Number", "Number", "Number") dialog:SetDescriptions("Number of systems per page:", "Start at page:", "Do it for max no of pages:") dialog:SetInitValues(6, 1, 999) local returnvalues = dialog:Execute() if not returnvalues then return end local systemsperpage = returnvalues[1] local currentprocesspage = returnvalues[2] local maxnoofprocesspages = returnvalues[3] if (systemsperpage < 1) then print ("Input error: Invalid number of systems per page.") return end if currentprocesspage < 1 then print ("Input error: Invalid start page number.") return end local pages = finale.FCPages() local pageprocesscounter = 0 while true do -- Reload the page layout every time, since the layout contents changes finale.FCStaffSystems.UpdateFullLayout() if pageprocesscounter > maxnoofprocesspages then break end pages:LoadAll() if pages.Count < currentprocesspage then break end -- Create the local-scope variables before any goto:s local system = finale.FCStaffSystem() local measure = finale.FCMeasure() -- Get the page layout to process page = pages:GetItemAt(currentprocesspage - 1) local firstsysnumber = page:GetFirstSystem() local lastsysnumber = page:CalcLastSystem() -- Skip pages with no system layout, such as empty pages if firstsysnumber < 1 then goto continue end if lastsysnumber < 1 then goto continue end -- Check if the page contains enough systems to split the contents if (lastsysnumber - firstsysnumber + 1) < systemsperpage then print ("Can't continue. Page", page:GetItemNo(), "contains less than", systemsperpage, "systems.") return end -- Load the system where the break should appear system:Load(firstsysnumber + systemsperpage) if (system.FirstMeasure < 1) then goto continue end -- Change the measure attribute of the first measure to a page break measure:Load(system.FirstMeasure) measure.PageBreak = true measure:Save() -- Process the next page :: continue :: currentprocesspage = currentprocesspage + 1 pageprocesscounter = pageprocesscounter + 1 end ==== Create Tacet ==== This script creates a tacet for the selected region, regardless of if the section contains music or how the measures has been configured regarding multimeasure breaks. It requires that the Automatic Update for multimeasure rests is OFF for the file. Before the tacet , a user alert is displayed. The script also requires a selected region (//JW Lua// will automatically tell the user if a region isn't selected). Specifying the multimeasure rest preference record 1 doesn't really matter here (any value would load the same preference data), but generally speaking for single-instance preference records, it's good practice to load preference record 1 anyway. function plugindef() -- This function and the 'finaleplugin' namespace -- are both reserved for the plug-in definition. finaleplugin.RequireSelection = true finaleplugin.CategoryTags = "Layout, Measure, Rest" return "Create Tacet", "Create Tacet", "Creates a full tacet 'measure' for the selected region." end -- Load the multimeasure rest prefs local mmrestprefs = finale.FCMultiMeasureRestPrefs() mmrestprefs:Load(1) -- Will not continue if auto-update of mm rests is ON if mmrestprefs.AutoUpdate then print ("Automatic Update is ON in the multimeasure preferences.") return end local ui = finenv.UI() if ui:AlertYesNo("Do you want to create a tacet section in this part? All music in the region will be hidden.", "Are you sure?") ~= finale.YESRETURN then return end local region = finenv.Region() -- Delete all old mm rests from the region -- (In this case, it's safe to delete from the start, since no relocation of data records takes place.) local mmrests = finale.FCMultiMeasureRests() mmrests:LoadAll() for mm in each (mmrests) do if region:IsMeasureIncluded(mm.StartMeasure) or region:IsMeasureIncluded(mm.EndMeasure) then mm:DeleteData() end end local mm = finale.FCMultiMeasureRest() mm.StartMeasure = region.StartMeasure mm.EndMeasure = region.EndMeasure -- Copy from the default MM rest definition mm.NumberHorizontalAdjust = mmrestprefs.NumberHorizontalAdjust mm.NumberVerticalAdjust = mmrestprefs.NumberVerticalAdjust mm.ShapeEndAdjust = mmrestprefs.ShapeEndAdjust mm.ShapeID = mmrestprefs.ShapeID mm.ShapeStartAdjust = mmrestprefs.ShapeStartAdjust mm.StartNumberingAt = 20000 -- A really high value here to hide the number mm.SymbolSpace = mmrestprefs.SymbolSpace mm.UseSymbols = mmrestprefs.UseSymbols mm.UseSymbolsLessThan = mmrestprefs.UseSymbolsLessThan mm.Width = mmrestprefs.Width mm:Save()