Change a barline with a plugin
Hi,
Could someone explain to me how to change a barline with a plugin please ?
I've made some attempts through newElement(Element.BARLINE) and through var seg.segmentType but I cannot find a way. Everything made Musescore crash and I didn't manage to find examples.
Thank you !
Comments
If you get a BarLine element you should be able to change
barlineType
,barlineSpan
,barlineSpanFrom
andbarlineSpanTo
for it according to https://musescore.github.io/MuseScore_PluginAPI_Docs/plugins/html/class…In reply to If you get a BarLine element… by jeetee
As for finding barlines, you could start from
curScore.firstSegment()
and just follow thesegment.next
chain until you find one of the barlinetypes (see https://musescore.github.io/MuseScore_PluginAPI_Docs/plugins/html/names…)In reply to As for finding barlines, you… by jeetee
Thank you very much for your advices. I managed to do it by modifying a existing barline instead of creating one. This is what I've done :
My only problem is that I don't manage to access to the enum BarLineType that is shown here : https://musescore.github.io/MuseScore_PluginAPI_Docs/plugins/html/names…
I wrote 2 because it is the value of one of the barline on the doc, but do you have any idea on the proper way to write the several values of the enum please ? Thank you !
In reply to Thank you very much for your… by millermix
The BarLineType enum values are available as per that link, but the enum itself is not exposed according to https://musescore.github.io/MuseScore_PluginAPI_Docs/plugins/html/class…
What you could do is create your own local mapping object to use as an enum instead. See this quickly thrown together example which changes barlines to DOUBLE if they appear within the first 10 segments of a score.
In reply to Thank you very much for your… by millermix
May be off topic.
I think, You can get last barline simpler by
curScore.lastSegment.elementAt(0)