Skip to content

Commit 74b1a87

Browse files
committed
Update ties_remove_dangling.lua
1 parent 09baa8b commit 74b1a87

File tree

1 file changed

+51
-35
lines changed

1 file changed

+51
-35
lines changed

src/ties_remove_dangling.lua

+51-35
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
function plugindef()
2-
-- This function and the 'finaleplugin' namespace
3-
-- are both reserved for the plug-in definition.
4-
finaleplugin.Author = "Jacob Winkler"
5-
finaleplugin.Copyright = "2022"
6-
finaleplugin.Version = "1.1"
7-
finaleplugin.Date = "2022-09-04"
8-
finaleplugin.AuthorEmail = "[email protected]"
9-
finaleplugin.AdditionalMenuOptions = [[
2+
-- This function and the 'finaleplugin' namespace
3+
-- are both reserved for the plug-in definition.
4+
finaleplugin.Author = "Jacob Winkler"
5+
finaleplugin.Copyright = "2024"
6+
finaleplugin.Version = "1.2&"
7+
finaleplugin.Date = "2024-02-06"
8+
finaleplugin.AuthorEmail = "[email protected]"
9+
finaleplugin.AdditionalMenuOptions = [[
1010
Ties: Replace Dangling w/Slurs
1111
]]
12-
finaleplugin.AdditionalUndoText = [[
12+
finaleplugin.AdditionalUndoText = [[
1313
Ties: Replace Dangling w/Slurs
1414
]]
15-
finaleplugin.AdditionalDescriptions = [[
15+
finaleplugin.AdditionalDescriptions = [[
1616
Removes dangling ties and replaces them with slurs
1717
]]
18-
finaleplugin.AdditionalPrefixes = [[
18+
finaleplugin.AdditionalPrefixes = [[
1919
replace_with_slur = true
2020
]]
21-
finaleplugin.Notes = [[
21+
finaleplugin.Notes = [[
2222
TIES: REMOVE DANGLING
2323
2424
This script will search for 'dangling ties' - ties that go to rests rather than other notes - and either remove them or replace them with slurs.
2525
]]
26-
return "Ties: Remove Dangling", "Ties: Remove Dangling", "Removes dangling ties (ties that go nowhere)."
26+
return "Ties: Remove Dangling", "Ties: Remove Dangling", "Removes dangling ties (ties that go nowhere)."
2727
end
2828

2929
replace_with_slur = replace_with_slur or false
@@ -32,30 +32,46 @@ local tie = require("library.tie")
3232
local smartshape = require("library.smartshape")
3333

3434
local music_region = finale.FCMusicRegion()
35-
music_region:SetFullDocument()
35+
music_region:SetCurrentSelection()
36+
37+
if music_region:IsEmpty() then
38+
local str1 = finale.FCString()
39+
local str2 = finale.FCString()
40+
str1.LuaString = "Process whole document?"
41+
str2.LuaString = "No Selection."
42+
local ui = finenv.UI()
43+
local result = ui:AlertYesNo(str1.LuaString, str2.LuaString)
44+
if result == 2 then
45+
music_region:SetFullDocument()
46+
else
47+
goto bypass
48+
end
49+
end
3650

3751
for working_staff = music_region:GetStartStaff(), music_region:GetEndStaff() do
38-
for layer_num = 0, 3, 1 do
39-
local note_entry_layer = finale.FCNoteEntryLayer(layer_num, working_staff, music_region.StartMeasure, music_region.EndMeasure)
40-
note_entry_layer:Load()
41-
for index = 0, note_entry_layer.Count-1, 1 do
42-
local entry = note_entry_layer:GetRegionItemAt(index, music_region)
43-
if entry and entry:IsTied() then
44-
for note in each(entry) do
45-
local tie_must_exist = true
46-
local tied_note = tie.calc_tied_to(note, tie_must_exist)
47-
if not tied_note then
48-
note.Tie = false
49-
if replace_with_slur then
50-
local next_entry = note_entry_layer:GetRegionItemAt(index + 1, music_region)
51-
if next_entry then
52-
smartshape.add_entry_based_smartshape(entry, next_entry)
53-
end
54-
end
55-
end
56-
end
52+
for layer_num = 0, 3, 1 do
53+
local note_entry_layer = finale.FCNoteEntryLayer(layer_num, working_staff, music_region.StartMeasure, music_region.EndMeasure)
54+
note_entry_layer:Load()
55+
for index = 0, note_entry_layer.Count-1, 1 do
56+
local entry = note_entry_layer:GetRegionItemAt(index, music_region)
57+
if entry and entry:IsTied() then
58+
for note in each(entry) do
59+
local tie_must_exist = true
60+
local tied_note = tie.calc_tied_to(note, tie_must_exist)
61+
if not tied_note then
62+
note.Tie = false
63+
if replace_with_slur then
64+
local next_entry = note_entry_layer:GetRegionItemAt(index + 1, music_region)
65+
if next_entry then
66+
smartshape.add_entry_based_smartshape(entry, next_entry)
67+
end
5768
end
69+
end
5870
end
59-
note_entry_layer:Save()
71+
end
6072
end
61-
end
73+
note_entry_layer:Save()
74+
end
75+
end
76+
77+
::bypass::

0 commit comments

Comments
 (0)