curScore.selection.elements.length always returns 0

• Oct 13, 2024 - 22:43

Hi there
I'm trying to enumerate through elements in my score, but the following code (where I select all, get the list of elements in the selection) always returns 0, even if I have notes and text in my score:


curScore.startCmd()
curScore.selection.selectRange(0,curScore.lastSegment.tick + 1,0,numStaves);
var elems = curScore.selection.elements;
dialog.msg += "\nFound "+elems.length+" elems"; // Always returns 0
curScore.endCmd()

Any thoughts?


Comments

Try
curScore.startCmd()
curScore.selection.selectRange(0,curScore.lastSegment.tick + 1,0,curScore.nstaves);
curScore.endCmd()

and then
var elems...

Do you still have an unanswered question? Please log in first to post your question.