Plugin for adding a line break following a rest

• Apr 24, 2025 - 21:06

I have a routine written by ChatGPT. Not being a C++ programmer, I thought it might be worth the try. But it goes into a loop. I did sort of figure out how to do these things in Musescore 3 and 4. I am using 4.5.1 now.

Could someone please let me know how to add a line break following a rest -- and how to loop through the music to do it in one fell swoop. That way I get each verse with a line break after it. I tried coding this in the XML but load ignores the breaks. The routine to add the breaks after loading the XML is below and a sample of the music I want to add it to. Basically I am sculpting this unique presentation for e-books on the music embedded in the Hebrew Bible a chapter at a time. I'm about half way through the required 60,000 SVG images by line and it would save a lot of clicks to get the first step done automatically.

Thanks in advance

Bob

Attachment Size
lineBreaksAfterRests.qml 708 bytes
LEVITICUS-002.XML 176.28 KB

Comments

I tried rewriting the plugin with positive logic, this time it didn't do anything, so I wonder if maybe inserting a line break is not a supported function. -- or it's clear that I don't know how to do what I would like to do.

import QtQuick 2.0
import MuseScore 3.0

MuseScore {

onRun: {
    var cursor = curScore.newCursor();
    cursor.staff = 0;
    cursor.voice = 0;
    cursor.rewind(0);
    curScore.startCmd();
    while (cursor.segment) {
        if ((cursor.element.type == Element.REST)) {
            cursor.measure.lineBreak = true;
                }
        cursor.next();
        }

    curScore.endCmd();

    quit();
}

}
The log after correcting typos is something I don't understand...
ActionsDispatcher::doDispatch | try call action: action://extensions/v1/linebreaksafterrests.qml?action=main
2025-04-26T17:58:57.904 | ERROR | main_thread | ::operator | error: qrc:/qml/MuseScore/Inspector/notation/notes/NoteSettings.qml:102:9: QML StackLayout: Binding loop detected for property "height"

2025-04-26T17:58:57.904 | WARN | main_thread | Qt | qrc:/qml/MuseScore/Inspector/notation/notes/NoteSettings.qml:102:9: QML StackLayout: Binding loop detected for property "height"

In reply to by ILPEPITO

Yes, it is what I want. I already tried coding the line breaks into the XML but I couldn't get it to work correctly. The line breaks were in the XML after the single rest in each line, but when the XML loads, they appeared somewhat randomly.

I've attached a before and after image of what I hope might happen. I still have a lot of cleanup to do, but it would reduce manual work by 10,000 carriage returns.

Thank you for your response. Your routine looked promising, but when I copy it to my location for plugins, it didn't do anything.

The log reads: action://extensions/v1/linebreaksafterrests.qml?action=main but there was no visible change in the score. It finds the plugin OK.

Thank you for the help

Attachment Size
afterimage.PNG 37.57 KB
beforeimage.PNG 40.17 KB

In reply to by Bob MacDonald1

For some strange reason, the 'simple modification' does not actually work on your xml file (while it works elsewhere). So I had to completely rewrite it according to my criteria and this also works on your xml file: in order for the 'system-breaks' to be applied you have to select the whole score, or the part you want to process.
Processing time may take a few seconds, depending on the length of the file.

Attachment Size
lineBreaksAfterRests_5.qml 759 bytes

In reply to by ILPEPITO

Thank you very much for this. I have got it to work. ָI have just done 2 more chapters and you have reduced the effort on my eyes and hands by 1/3 to 1/2 for each chapter. With 350 chapters to go, that is a big saving -- probably 10 minutes per chapter - 60 hours work. Not to mention the related stress. It makes it easier to consider redoing some if I find other changes that affect the 450 chapters already done. Many thanks again
I'm documenting the project and there's a long history of its development on my blog meafar.blogspot.ca if anyone is interested. I'll ask the publisher if we can do a special coupon. The first volume on the book of Job is ready for reading and singing. If they give me one, I'll post it here.
Bob

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