Changing a barline type via code
Is it possible to run a plugin that would change the currently selected barline? if not, is it possible to change the currently selected bar's barlines?
Is it possible to run a plugin that would change the currently selected barline? if not, is it possible to change the currently selected bar's barlines?
Do you still have an unanswered question? Please log in first to post your question.
Comments
According to https://musescore.github.io/MuseScore_PluginAPI_Docs/plugins/html/class… barlineType is exposed to the API for those elements, so perhaps that is the way forward?
var segment = measure.lastSegment;
var bar = segment.elementAt(0);
if (bar.type == Element.BAR_LINE) {
bar.barlineType = 32;
console.log("Last element is a barline (type=" + bar.userName() + ")");
} else {
console.log("Last element is not a barline (type=" + bar.userName() + ")");
}
Can you explain what you are trying to do in more detail? You don't need to run a plugin just to change barlines; the Barlines palette does this directly.
In reply to Can you explain what you are… by Marc Sabatella
I have some workflow that I want to optimize/automate where I change the barline types based on the workflow. My current issue is: "selecting a bar or a note in a bar, and running the plugin, would change the current bar starting barline to START_REPEAT" but it doesn't always work
This is the code I have so far, which doesn't always work
onRun: {
var selected = curScore.selection.elements[0];
In reply to I have some workflow that I… by Guyis
I'm afraid there is bug in MuseScore.
Check my code.
If you play it for changing the bar to regular/double/end repeat it works fine, the right bar is changed.
If you play it for changing the bar to start repeat, then the next bar is changed.
Play it on a note of the 1st, 2nd and 3rd measure to observe the difference of behaviour.
You could try to workaround it by selecting the previous bar, but this will be limited. I guess you won't be able to change the bar between the 1st and 2nd measure, because there is no previous bar to select.
In reply to I'm afraid there is bug in… by parkingb
added to notes
https://musescore.org/en/node/345122