MuseScore2 to Musescore3 : pagenumber pagepos ?

• Feb 24, 2020 - 07:20

Hello

I migrate a personal plugins from MuseScore.2 (which works fine), to MusScore.3.
I have an issue to retrieve in MuseScore.3 the properties available in MuseScore.2 : pagenumber ans pagePos

  • pagenumber
    I need the pagenumber of a cursor.
    In MuseScore.2 it is cursor.measure.parent.parent.pagenumber. It works fine.
    In MuseScore.3 , I can't find this property, nor inspect cursor.measure.parent.parent (crash)
    function logInspect(o, oname) {
    console.log("object " + oname + " <" + o.objectName + ">" );
    for(var p in o){
    var t=typeof o[p];
    console.log(" " + p + " / " + t )
    }
    cursor.rewind(0);
    logInspect(cursor.measure.parent, "cursor.measure.parent"): => OK contains parent
    logInspect(cursor.measure.parent.parent, "cursor.measure.parent.parent"): => crash

  • pagepos
    I need the absolute position of a note in the page.
    In MuseScore.2 : mnote= cursor.element.note[0] . mnote.pagePos.x , mnote.pagePos.y , mnote.bbox.width , mnote.bbox.height. It works fine.
    In MuseScore.3 , pagePos disappears...

  • dolayout
    For info : I understand that score.doLayout() is replaced by a score.startCmd() ... score.endCmd()

  • purpose of my plugins
    Used with MuseScore line command
    input : a MusicXML file and my ad-hoc plugins-MuseScore
    Output : jpeg pages with score rendering, text file with fraphical positions of the notes

Enclosed a draft of my MuseScore3 plugins, which does not work yet. As soon it will work, I will publish feed-back for other users who need similar functionalities
Thank you for your support
Franck Revolle
www.expresseur.com

Attachment Size
expresseur_scan.qml 4.26 KB

Comments

Yes, it looks like pagePos and pagenumber properties are indeed missing after transition from MuseScore 2.X. Actually for most elements (with some exceptions like beams) position in page coordinates can be obtained with something like this:

function getPagePos(e) {
    var pos = Qt.point(0, 0);
    while (e) {
        pos.x += e.posX;
        pos.y += e.posY;
        e = e.parent;
    }
    return pos;
}

I have just submitted a pull request restoring these properties, if this PR gets merged these properties should be available in future versions of MuseScore:
https://github.com/musescore/MuseScore/pull/5986

Tested .. Seems OK. Thank you for the upgrade
Sample of the code attached :
pagenr : cursor.measure.parent.parent.pagenumber
posx : mnote.pagePos.x
posy : mnote.pagePos.y
boxwidth : mnote.bbox.width
boxheight : mnote.bbox.height

Attachment Size
expresseur_scan.qml 4.28 KB

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