local min_beamed_duration = finale.THIRTYSECOND_NOTE local duration_alignment = finale.EIGHTH_NOTE -- This function returns true if the secondary beams should break -- before the note entry function IsBreakableEntry(entry) -- Check that the current entry is valid for secondary beam breaks: if entry.BeamBeat then return false end if entry:IsRest() then return false end if entry.Duration >= min_beamed_duration * 2 then return false end -- Check that the previous note entry is valid for secondary beam breaks: local previousentry = entry:Previous() if not previousentry then return false end if previousentry:IsRest() then return false end if previousentry.Duration >= min_beamed_duration * 2 then return false end -- Return true if the measure position is on eight note boundary return ((entry.MeasurePos % duration_alignment) == 0) end for noteentry in eachentrysaved(finenv.Region()) do local sbbm = finale.FCSecondaryBeamBreakMod() sbbm:SetNoteEntry(noteentry) if IsBreakableEntry(noteentry) then local loaded = sbbm:LoadFirst() sbbm:SetBreakAll(true) if loaded then -- Save existing data sbbm:Save() else -- Create new data sbbm:SaveNew() end end end