help with removeElement, ties, and other questions
Hi, I have a couple of random questions regarding some plugin functions. Here goes:
-
I want to delete everything in a selection without using cmd("delete") because that will create a separate undo history. so im trying to delete the selection using the plugin, specifically:
var e = curScore.selection.elements for (var i in e) { removeElement(e[i]); }
Using that, I´m able to remove all the elements, except tulpets!! even if i use:
if (e[i].type==Element.tuplet) { removeElement(e[i].tuplet); }
Why is that? what am i missing here?
But, If there are any chords present in the selection, removeElement seems to stop after deleting the bottom note of the first chord and does not delete anything after that. Very strange... So it seems to me that there is a special way to delete chords?
however, I am able to delete chords and tuplets using a the segment approach:
while(cursor.segment && cursor.tick < endTick ) {
var e = cursor.element;
if(e.tuplet) {
removeElement(e.tuplet); // must specifically remove tuplets
}
else {
removeElement(e);
}
cursor.next();
}
though, this method does not delete trills, hairpins, chord symbols...
I feel there is a better way to solve this using the first approach, though i have no idea how.
Could anyone please explain to me what is happening here?
-
Is there a way for a plugin to continue a count from an previous run. In other words, i need to access a variable´s value from the last time i run the plugin. Any clue how to do thtat?
-
Is is possible to change an existing note´s duration from it´s properties without having to delete it and add it again with a different duration? ( i need to preserve tiebacks /slurs and any articulation dynamics etc.. attached to that note)
-
I´ve studied the code for the retrograde plugin and have been using a similar way to copy and paste notes. How can i detect if a tie exists on a note/chord? and how can i add ties to notes?
I appreciate all the help I can get.
Comments
musescore3
> removeElement seems to stop after deleting the one note
confirmed, don't know why.
> delete chords
you could try removeElement(e[0].parent), also see debugger info below
> persistence between plugin runs
see "for tagging a score or score part with custom data"
https://musescore.org/en/handbook/developers-handbook/plugins-3x#:~:tex…
> change duration preserve attachments
cmd('double-duration') etc but that creates undo steps
> check tie
.tieForward and .tieBack see
https://musescore.org/en/node/330798
shttps://musescore.github.io/MuseScore_PluginAPI_Docs/plugins/html/class…
there's a useful debugger so that you can cut down trial and error runs, see "Use the debugger by doing the following steps"
https://musescore.org/en/handbook/developers-handbook/plugins-3x#:~:tex…
cmd("delete") creates a separate undo history and updates the visual, curScore.endCmd() updates the visual, otherwise the visual may or may not be updated to match the latest data. .ash86 must know this already, I'm writing in case other dev miss it.
In reply to musescore3 > removeElement… by msfp
Hi msfp, thanks for the reply. i got some updates.
> removeElement seems to stop after deleting the one note
I was able to remove chord by searching for NOTE element not CHORD element:
this, however,
works if you get the element via cursor.element but not via selection.elements. seems quite odd. Maybe someone could confirm that.
In reply to Hi msfp, thanks for the… by .ash86
See the new version of the New RetroGrade plugin on removing elements
https://musescore.org/en/project/new-retrograde