[JW Lua] Adding a slur

Harald Schollmeyer hschollm at gmx.net
Mon Oct 29 09:54:12 CET 2018


Fellow scripters,

we are discussing a script for adding a slur in the german forum:
https://finaleforum.superflexible.net/v3/viewtopic.php?f=7&t=5228

I wrote the following script while still having open questions - see below.
=================================================================

function plugindef()
    finaleplugin.RequireSelection = true
    finaleplugin.MinFinaleVersion = "2025"
    finaleplugin.Author = "Harald Schollmeyer"
    finaleplugin.Version = "1.0"
    finaleplugin.Date = "29.10.2018"
    finaleplugin.AuthorEmail = "hschollm at gmx.net"
    finaleplugin.CategoryTags = "Measure, Region, Smartshape"
    return "AddSlur", "AddSlur", "Adds a slur spanning the selection"
end

-- function to create and assign an entry-attached slur
function MakeSlur( StartEntry, EndEntry)
     local smartshape = finale.FCSmartShape()
     smartshape.ShapeType = finale.SMARTSHAPE_SLURAUTO
     smartshape.EntryBased = true
     smartshape.BeatAttached= false
     smartshape.MakeHorizontal = false
     smartshape.PresetShape = true
     smartshape.Visible = true
     smartshape:SetSlurFlags( true )

     local leftseg = smartshape:GetTerminateSegmentLeft()
     leftseg.Measure = StartEntry.Measure
     leftseg.Staff = StartEntry.Staff
     leftseg:SetEntry(StartEntry)

     local rightseg = smartshape:GetTerminateSegmentRight()
     rightseg.Measure = EndEntry.Measure
     rightseg.Staff = EndEntry.Staff
     rightseg:SetEntry(EndEntry)

     smartshape:SaveNewEverything( StartEntry,EndEntry )
end

-- main program starts here
-- search first and last entry in selected region
local FirstEntry, LastEntry = nil, nil
for noteentry in eachentry(finenv.Region()) do
     if not FirstEntry then FirstEntry = noteentry end
     LastEntry = noteentry
end

-- if existing and not-identical entries are found, call function to add  
smart shape
if FirstEntry and LastEntry and (FirstEntry ~= LastEntry) then
MakeSlur( FirstEntry, LastEntry)
end


=================================================================
Questions:

1. obviously, FCSmartShapeEntryMark() isn't needed, although I would have  
thought, it would be necessary. What's it for?
2. smartshape:SaveNewEverything( NULL, NULL ) saves the smartshape as well  
as smartshape:SaveNewEverything( StartEntry,EndEntry ) although according  
to the documentation, only the second version would be correct
3. the FCSmartShape:SaveNewEverything documentation says: "For  
note-attached smart shapes, the frame collection that contains the entries  
need to be saved after the successful return from this method.". How do I  
save a frame collection? Using e.g. FCCellFrameHold (obviously more aimed  
at clef changes)?
4. FCSmartShape::SetSlurFlags( bool entrybased) says: "Configures the  
basic smart shape flags required for a slur.". What are these flags, are  
they of any importance for controlling slurs in JWLua scripts?

Thanks -
Harald


-- 
___________________________________
Harald Schollmeyer
Wesmarstr. 3a, 45659 Recklinghausen
Telefon: +4923614879188 und +491773125084
E-Mail: hschollm at gmx.net



More information about the JWLua mailing list