# -*- coding: ISO-8859-1 -*- """ capellaScript -- 28.05.2007 Hans H. Lampe >>> Tonartvorzeichnung entfernen (Version 1.0 - 28.05.2007)||| Mit diesem Skript kann die Tonartvorzeichnung am Anfang der Notenzeilen z.B. für Orchester-Instrumente, wie Trompeten, Hörner oder Pauken entfernt werden. ||Die entsprechenden Alterationen befinden sich dann direkt an den Noten.|| Bitte den Cursor für die automatische Zeilenwahl in die entsprechende Notenzeile setzen, oder die gewünschte Notenzeile im nachfolgenden Dialog wählen.||| Rückmeldungen bitte an Hans H. Lampe:|HansHermann.Lampe@t-online.de <<< """ # -------- Cursorzeile ermitteln --------- # staffList = activeScore().voiceList() staffIndex = 0 sel = curSelection() if sel <> 0: (sy,st,vo,no) = sel[0] system = activeScore().system(sy) staff = system.staff(st) # ------ Aktuellen Eintrag im Mustersystem bestimmen ------- # i = 0 for descr in staffList: if staff.index() == system.staffIndexFromDescr(descr): staffIndex = i i += 1 # -------- Dialogbox --------- # labStaff1 = Label('Notenzeile des Instruments wählen (durch Cursorpositionierung automatisch vorgewählt)') selStaff = ComboBox(staffList, value = staffIndex, width = 19) labStaff2 = Label(' "Beschreibung" der Notenzeile im Mustersystem', width=38) dlg = Dialog(' Tonartvorzeichnung entfernen', VBox([ HBox([labStaff1]), (''), HBox([selStaff, labStaff2]), ] ) ) # Tonartvorzeichnung entfernen #============================= from caplib.capDOM import ScoreChange import xml.dom.minidom DOC = xml.dom.minidom.Document import tempfile, codecs def deleteKey(score): for system in score.getElementsByTagName('system'): for staff in system.getElementsByTagName('staff'): layout = staff.getAttribute('layout') if layout != staffList[selStaff.value()]: continue keySign = staff.getElementsByTagName('keySign') if keySign != []: keySign = staff.getElementsByTagName('keySign')[0] fifths = keySign.getAttribute('fifths') keySign.setAttribute('fifths','0') class newScoreChange(ScoreChange): def changeScore(self, score): global scriptAction, doc doc = score.parentNode deleteKey(score) # ------ Hauptprogramm ------ # activeScore().registerUndo("Vorzeichnung entfernen") if dlg.run(): if activeScore(): activeScore().registerUndo("Vorzeichnung entfernen") tempInput = tempfile.mktemp('.capx') # für aktuelle aktive Partitur # tempOutput = tempfile.mktemp('.capx') activeScore().write(tempInput) newScoreChange(tempInput, tempOutput) # Tonartvorzeichnung entfernen activeScore().read(tempOutput) os.remove(tempInput) os.remove(tempOutput)