Staff height

• Mar 2, 2023 - 14:03

I'm wanting to get the height of a staff in order to calculate a position below it. But, the Staff object doesn't seem to have any relevant properties. I do see Element properties for staffLines and lineDistance, but I guess those are probably only applicable to "staff type change" objects (not that these seem to be exposed according to the API). I know the number of staff lines and their distance can vary through a score because of these changes, so internally in the code, when one wants to get the number of lines or line distance, you call a function and pass the tick, and this actually gets the property from the corresponding staffType object. But, it seems this isn't made available in the API, unless someone knows a workaround?

Stepping back, the problem I really want to solve is, I wish to set a segment annotation (a staff text, for example) to a given vertical position that is below the staff. The problem is I know the "pos" (measured from top staff line) I want to achieve but not the "offset" (measured from bottom staff line) that will achieve it.

I have a hack solution: temporarily disable autoplace for the element, set its offset to 0, and grab it's pos - that will tell me the staff height. Then I can restore the original values. But this puts an extra weird step onto the undo stack, plus it's just a hack.

Any ideas?


Comments

> I do see Element properties for staffLines and lineDistance, but I guess those are probably only applicable to "staff type change" objects

what is "staff type change" objects ?

https://musescore.org/en/node/302354
should be line distance * (number of lines-1), so on a default staff would be = 4
https://github.com/fp22june/MuseScoreTag362/blob/3b5857f0761c42574e8cb5…

can you access the settings in "staff/measure properties" with API?

Another hacky idea:

if at least two elements exist on diff ledger lines:

pagePos QPointF(23.5103, 15.5714)

posY 4
pagePos QPointF(25.4978, 19.5714)

stafflines.gif

Another more hacky idea:

maybe read the mscx?
https://github.com/fp22june/MuseScoreTag362/search?q=linedistance

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