{ Initialize "() { AddToPluginsMenu(_PluginMenuName, 'Run'); }" _PluginMenuName "Symbols Swap System and Staff" _VersionText "Version " _InitialText "Initial text" zg_VersionNumber "010700" _msgVersionTooEarly "This plug-in requires at least Sibelius version " zg_Sib6Version "6200" zg_Sib7Version "7130" Run "() { // Originally written Bob Zawalich 2011. // Manuscript changes will not let this be run in earlier versions of Sibelius versionMin = 0 + zg_Sib6Version; if (Sibelius.ProgramVersion < versionMin) { MyMessageBox(_msgVersionTooEarly & BuildSibVersionText(versionMin) & '.'); return False; } if (Sibelius.ScoreCount = 0) { MyMessageBox(_ScoreError); return False; } // update zg_VersionNumber when changes are made. dlg_Version = BuildVersionText(zg_VersionNumber); score = Sibelius.ActiveScore; selection = score.Selection; if (score.StaffCount = 0) { MyMessageBox(_ScoreError); return False; } fProcessEntireScore = False; fEmptySel = IsEmptySelection(score) ; if (fEmptySel) { fContinue = MyYesNoMessageBox(_msgSelectWholeScore); //True means Yes, continue and process score if (fContinue = False) { return False; // they said no, so stop the plugin } fProcessEntireScore = True; } //if (fEmptySel or (dlg_fDoNotShowDialog = False)) // set up empty sel special if you don't want to select all if no sel //if (dlg_fDoNotShowDialog = False) //{ //ok = DoDialog(DisplayDialog); //if (ok = False) //{ // return False; //} //} if (fProcessEntireScore = True) { selection.SelectPassage(1, score.SystemStaff.BarCount, 1, score.StaffCount); // select all staff items } score.Redraw = False; num = ProcessSelection(score, selection); score.Redraw = True; }" Version "() { // this is a version number that can be compared numerically, of the form // Major version (2 digits) & Minor Version (2 digts) & Patch (2 digits) return 0 + zg_VersionNumber;}" BuildVersionText "(versionNumber) { // this assumes that versionNumber is of the form // Major version (2 digits) & Minor Version (2 digts) & Patch (2 digits) // it builds up text version of the version number so only a single value needs to be updated str = '' & versionNumber; vText = _VersionText & Substring(str, 0, 2) & '.' & Substring(str, 2, 2) & '.' & Substring(str, 4, 2); return vText; }" FormatVersion "(ver) { len = Length(ver); // until version 2020.1, the version number was an integer of the form //(major version) * 1000 + (minor version) * 100 + (revision) * 10. //So Sibelius at the time of this writing would //be 8.3.1 would be returned as 8310. // The numbers were originally 4-digit numbers. This only allowed for a single digit minor version, and when Sibelius went to a Year form of the version, it took 2 // digits of year, as version 2018.7.x would show up as 18.7.x // In 2020.1, the format was changed to YearMonthSubversion (YYYYMMPP), for example Sibelius 2020.1.0 will show: 20200100 // This format will always be 8 digits, and Month and Subversion will have leading zeros if required. if (len < 8) // format prior to 2020.1 { major = (ver / 1000); minor = (ver % 1000) / 100; revision = (ver % 100); digitLow = revision % 10; if (digitLow = 0) { revision = revision / 10; } vText = major & '.' & minor & '.' & revision; return vText; } else { //YYYYMMPP: strip off all 4 digits of YYYY. Get 2 for month, 2 for version. // add 0 to last 2 fields for make into an integer, stripping the leading zero strYear = Substring(ver, 0, 4); strMonth = 0 + Substring(ver, 4, 2); strSubVer = 0 + Substring(ver, 6, 2); //trace('FormatVersion year, month, version: ' & strYear & ', ' & strMonth & ', ' & strSubVer); vText = strYear & '.' & strMonth & '.' & strSubVer; return vText; }}" BuildSibVersionText "(ver) { return FormatVersion(ver); }" DoDialog "(dialog) { ReopenDialog = True; dlg_fReopen = False; dialog.Title = '' & _PluginMenuName & ' - ' & dlg_Version & ' - ' & g_strAuthor; while (ReopenDialog = True) { if (Sibelius.ShowDialog(dialog,Self) = False) { return False; } if (ValidateDialog() = False) { dlg_fReopen = True; } if (dlg_fReopen = False) { ReopenDialog = False; } dlg_fReopen = False; } return True;}" dlg_fReopen "False" MyMessageBox "(string) { Sibelius.MessageBox(_PluginMenuName & ': ' & string);}" _ScoreError "Please open a score with one or more staves and run the plugin again." IsEmptySelection "(score) { for each obj in score.Selection { if (IsObject(obj)) { if ((obj.Type = 'SymbolItem') or (obj.Type = 'SystemSymbolItem')) { return False; } } } } return True; // only if nothing in selection }" _msgSelectWholeScore "No symbols are selected, so do you want this operation to apply to the whole score?" MyYesNoMessageBox "(string) { return Sibelius.YesNoMessageBox(_PluginMenuName & ': ' & string);}" ValidateDialog "() { // Validate user data here. If there are problems, use MyMessageBox to give a message // and return False to return to the dialog. return True;}" ProcessSelection "(score, selection) { arsStaff = CreateSparseArray(); arsSystem = CreateSparseArray(); arsSymNew = CreateSparseArray(); sysStaff = score.SystemStaff; for each SymbolItem sym in selection { arsStaff.Push(sym); } for each SystemSymbolItem ssym in selection { arsSystem.Push(ssym); } //REVIEW other properties? for i = 0 to arsStaff.Length { sym = arsStaff[i]; barnum = sym.ParentBar.BarNumber; barSys = sysStaff.NthBar(barnum); ssymNew = barSys.AddSymbol(sym.Position, sym.Index); if (ssymNew != null) { fTransferDxDy = True; TransferBarObjectProperties(sym, ssymNew, fTransferDxDy); arsSymNew.Push(ssymNew); } sym.Delete(); } // System to staff = put in staff 1 for i = 0 to arsSystem.Length { ssym = arsSystem[i]; barnum = ssym.ParentBar.BarNumber; barStaff = score.NthStaff(1).NthBar(barnum); symStaffNew = barStaff.AddSymbol(ssym.Position, ssym.Index); if (symStaffNew != null) { fTransferDxDy = True; TransferBarObjectProperties(ssym, symStaffNew, fTransferDxDy); arsSymNew.Push(symStaffNew); } ssym.Delete(); } if (arsSymNew.Length > 0) { selection.Clear(); for i = 0 to arsSymNew.Length { sym = arsSymNew[i]; sym.Select(); } }}" DisplayDialog "Dialog" { Title "Plugin" X "306" Y "245" Width "304" Height "151" Controls { Text { Title ID "IDC_STATIC3" X "4" Y "4" Width "286" Height "68" RightAlign "0" Value "_InitialText" Method SetFocus "0" } RadioButton { Title "RadioButton" ID "IDC_RADIO" X "7" Y "78" Width "66" Height "12" StartGroup "1" Value Method SetFocus "1" } RadioButton { Title "RadioButton" X "7" Y "92" Width "66" Height "13" ID "IDC_RADIO2" StartGroup "0" Value Method SetFocus "0" } CheckBox { Title "Do not show this dialog (this Sibelius session)" X "7" Y "107" Width "162" Height "12" ID "IDC_DLFDONOTSHOWDIALOG_CHECK" Value "dlg_fDoNotShowDialog" Method SetFocus "0" } Button { Title "Cancel" ID "IDC_BUTTON2" X "174" Y "107" Width "56" Height "14" DefaultButton "0" Value Method SetFocus "0" EndDialog "0" } Button { Title "OK" ID "IDC_BUTTON" X "235" Y "107" Width "56" Height "14" DefaultButton "1" Value Method SetFocus "0" EndDialog "1" } } } dlg_Version "Version 01.07.00" dlg_fDoNotShowDialog "false" g_strAuthor "by Bob Zawalich" TransferBarObjectProperties "(objSource, objDest, fTransferDxDy) { if ((objSource = null) or (IsObject(objSource) = False)) { return False; } if (fTransferDxDy) { objDest.Dx = objSource.Dx; objDest.Dy = objSource.Dy; } // tricky - objsource can be in multiple voices though not in all. // voicenumber will be 0 if multiple voices set. Does not necessarily mean all voices are set // the bitField Voices is used to transfer multiple voices from one object to another. Should be just the thing here. objDest.Voices = objSource.Voices; //trace('TransferBarObjectProperties voicenumber, voices, voices present: ' & objDest.VoiceNumber & ', ' & objDest.Voices); //for iVoice = 1 to 5 //{ // trace('iVoice, inVoice: ' & iVoice & ', ' & objDest.GetIsInVoice(iVoice)); //} objDest.Hidden = objSource.Hidden; //trace('Hidden, s, d: ' & objSource.Hidden & ', ' & objDest.Hidden); objDest.Color = objSource.Color; // REVIEW for notes, they must be selected. Use NotePropertiesLib for transferring Note props // REVIEW: only really sure to work for Lines or Symbols if ((objSource.Type = 'SymbolItem') or (objSource.Type = 'SystemSymbolItem')) { objDest.Size = objSource.Size; } else { objDest.CueSize = objSource.CueSize; // this will apply to all non-symbol objcts } if (objSource.IsALine) { objDest.RhDy = objSource.RhDy; if (Sibelius.ProgramVersion >= zg_Sib6Version) { //trace('Replacing line RhDx. Old style = ' & objSource.StyleId & 'RhDx = ' & objSource.RhDx); objDest.RhDx = objSource.RhDx; } } if (Sibelius.ProgramVersion >= zg_Sib6Version) { objDest.DrawOrder = objSource.DrawOrder; // Magnetic layout setting is kind of indirect. Inline form of GetMagLayoutSetting ml = DefaultDodge; if (objSource.UsesMagneticLayoutSettingOverridden = False) { ml = DefaultDodge; } else { if (objSource.UsesMagneticLayout) { ml = AlwaysDodge; } else { ml = SuppressDodge; } } objDest.UsesMagneticLayout = ml; //trace('PS mag layout new old: ' & objDest.UsesMagneticLayout & ', ' & objSource.UsesMagneticLayout); } if (Sibelius.ProgramVersion >= zg_Sib7Version) { objDest.ColorAlpha = objSource.ColorAlpha; } return True; }" GetMagLayoutSetting "(obj) { if (obj.UsesMagneticLayoutSettingOverridden = False) { return DefaultDodge; } // overridden so must be Always or Suppress if (obj.UsesMagneticLayout) { return AlwaysDodge; } return SuppressDodge;}" }