<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Jari,<br>
<br>
FCNoteEntryCell:FindEntryStartPosition sometimes returns unfavorable
results.<br>
<br>
It prioritizes main notes over grace notes, but it doesn't
prioritize:<br>
1.) visible notes over invisible notes (so currently an invisible
rest on layer 1 is prefered over a visible note on layer 2)<br>
2.) notes that are on the exact measure position over whole measure
rests that appear in the center of the measure<br>
(so at position 0 a rest on layer 1 that appears in the center of
the measure is prioritized over a note that appears on position 0 on
layer 2)<br>
3.) visible notes over notes that are hidden through a staff style<br>
<br>
The latter may be a bit difficult to implement, but the first two
options should be rather straight forward.<br>
This would be a great improvement of the function.<br>
<br>
Below is a workaround solution for 1) + 2).<br>
<br>
Best,<br>
Jan<br>
<a class="moz-txt-link-freetext" href="https://elbsound.studio">https://elbsound.studio</a><br>
<br>
function NewFindEntryStartPosition(entry,measurepos,notecell)<br>
-- look for better matching entries in other layers<br>
if (entry~=nil) then <br>
if entry.Visible<br>
and entry:IsRest() <br>
and (entry.Duration==4096) then<br>
local meas=finale.FCMeasure()<br>
meas:Load(entry.Measure)<br>
if meas:GetDuration()<=4096 then<br>
for e in each(notecell) do<br>
if (e.MeasurePos==measurepos)<br>
and (not e:IsRest() or (e.Duration~=4096))
then<br>
entry=e<br>
break<br>
end<br>
end<br>
end<br>
elseif (entry.Visible==false) then<br>
for e in each(notecell) do<br>
if (e.MeasurePos==measurepos)<br>
and e.Visible then<br>
entry=e<br>
break<br>
end<br>
end<br>
end<br>
end<br>
return entry<br>
end<br>
<br>
local
noteentrycell=finale.FCNoteEntryCell(finenv.Region().EndMeasure,finenv.Region().StartStaff)<br>
noteentrycell:Load()<br>
local
entry=NewFindEntryStartPosition(noteentrycell:FindEntryStartPosition(0,-1),0,noteentrycell)<br>
print(entry.LayerNumber)<br>
</body>
</html>