Why is Element.symbol undefined
I want to get the kind of clef/time signature/key signature from an element class like this:
if (e.type == Element.CLEF || e.type == Element.KEYSIG || e.type == Element.TIMESIG) {
console.log("symID " + e.symbol);
}
Despite having this property according to the docs, this always reads "undefined"
Comments
You could use the excellent Element Analyser plugin to view the score's object model and properties in detail. This should yield some clues. Make sure to test on a few bars first of all because it is processor intensive and may appear to have crashed.
https://musescore.org/en/project/element-analyser
In reply to You could use the excellent… by yonah_ag
I tried that and the symbol property is not listed despite being in the docs. Also there seems to be no other field to indicate the clef type
In reply to I tried that and the symbol… by harmony8
Docs must be wrong / out of date.
Maybe the property name is slightly different.
In reply to Docs must be wrong. Maybe… by yonah_ag
Maybe
ElementType.CLEF
etc.?In reply to Maybe ElementType.CLEF etc? by Jojo-Schmitz
Yes the element is of type Element.CLEF. but how to get the symID like gclef or fclef
In reply to Yes the element is of type… by harmony8
Not
ElementType.CLEF
?In reply to Not ElementType.CLEF? by Jojo-Schmitz
Probably yes. I just repeated what is written in the if check in the code I provided
In reply to Probably yes. I just… by harmony8
What does it shown with
In reply to What does it shown with if … by Jojo-Schmitz
undefined
In reply to undefined by harmony8
following is my understanding, if the main plugin dev dmitrio95 were here, you could have a reliable answer.
clef is drawn, but is not technically symbol. symbols are Master palette > symbols category objects
e.symbol shows symID
API_PROPERTY( symbol, SYMBOL )
https://github.com/fp22june/MuseScoreTag362/blob/3b5857f0761c42574e8cb5…
which is valid for symbol objects
https://github.com/fp22june/MuseScoreTag362/blob/3b5857f0761c42574e8cb5…
https://github.com/fp22june/MuseScoreTag362/blob/3b5857f0761c42574e8cb5…
the info of clef OP want should be CLEF_TYPE
https://github.com/fp22june/MuseScoreTag362/blob/3b5857f0761c42574e8cb5…
but it is not exposed
https://github.com/fp22june/MuseScoreTag362/blob/3b5857f0761c42574e8cb5…
a snippet for adding symbol object
https://musescore.org/en/node/320673#iconsym
can't find a way to get clef info yet, added to https://musescore.org/en/handbook/developers-handbook/plugins-3x
In reply to following is my… by msfp
I found a stable workaround for now: using Element.posY. This gives the staffline a clef is "on" which is always 1 for bass clef and 3 for g clef. Not perfect but a start.