Plugin works in Musescore GUI, but not on command line

• May 16, 2023 - 04:54

Can anyone explain what I'm doing wrong here ? The plugin shown below works fine when I run it in Plugin Creator, but when run on the command line I get a pop-up: "Invalid Command, Command select-all not valid in current state", then ""Invalid Command, Command transpose-down not valid in current state". It returns a pdf of the input file unmodified. I am using v3.6.2 on Windows 10.

"C:\Program Files\MuseScore 3\bin\MuseScore3.exe" R27_TEST.mscx -p transpose_test.qml -o R27_TEST_DOWN.pdf

transpose_test.qml

import QtQuick 2.0
import MuseScore 3.0
MuseScore {
onRun:{
cmd("select-all");
cmd("transpose-down");
Qt.quit();

} }

I also tried v4.0.2; it first popped up the error "MuseScore4: Unknown option 'p'".
--plugin transpose_test.qml avoided the error messages, also returned the pdf unmodified. Many thanks for any assistance !


Comments

That plugin won't work in Mu4 anyway, due to the Qt.quit() it'd crash Mu4.
Andother issue with Mu4 is that the command line interface is pretty broken (it is in the works for 4.1)

Try
"C:\Program Files\MuseScore 3\bin\MuseScore3.exe" -p transpose_test.qml -o R27_TEST_DOWN.pdf R27_TEST.mscx
i.e. putting the source file last

In reply to by elsewhere

Thanks, but as a quick first test, I just tried invoking colornotes:
"C:\Program Files\MuseScore 3\bin\MuseScore3.exe" -p colornotes3_0.qml -o R27_TEST_DOWN.pdf R27_TEST.mscx
no error pop-ups, but PDF file is unchanged (all notes black).
It worked fine invoking it in the GUI, BTW

In reply to by BanjoJake

No success. I tried a few things and always get: select-all and/or escape not valid in this state...
EDIT: but you could imitate a batch procedure using

curScore.startCmd();
cmd("next-score")
curScore.endCmd();

(at least in MU3.6). I have loaded 35 files and ran a plugin with next-score on them without problems. The only fun fact to know is: next-score goes back to the first score after processing the last. So you need some "dummy" first file to stop the iteration

EDIT2: Also have a look at https://musescore.org/en/node/336449

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