Switching Between Scores

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Switching Between Scores

Martin Marris
Hi,

I used to know how to do this but cannot remember. If there are two files
open in Sibelius, how does a plugin switch between them, for instance to
copy an object from one file into another file?

I think it has something to do with using the Sibelius.NthScore() and the
write properties of Sibelius.ActiveScore (available since Sibelius 6), but
when I try this, nothing happens:

Firstscore = Sibelius.ActiveScore;
Secondscore = Sibelius.NthScore(2);
Sibelius.ActiveScore = Secondscore;

Thanks.



_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
Reply | Threaded
Open this post in threaded view
|

Re: Switching Between Scores

Bob Zawalich-3
You always have interesting questions!

Basically, as long as you have two open scores and you have score objects for them, you can get their selections and then copy from them and paste from. You do have to use clipboard zero if you are going between scores.

 I don’t know that I’ve ever used NthScore; I suspect it would work but you would probably have to  look at the file name to see which score it was. I typically start with an open score and then open or create another score when I’m doing that sort of thing but as long as you have two score objects that are valid it really doesn’t matter which one is the active score. You just deal with the selection object for each score.

Hope that makes some sense.

Bob

> On Feb 28, 2018, at 9:11 AM, Martin Marris <[hidden email]> wrote:
>
> Hi,
>
> I used to know how to do this but cannot remember. If there are two files
> open in Sibelius, how does a plugin switch between them, for instance to
> copy an object from one file into another file?
>
> I think it has something to do with using the Sibelius.NthScore() and the
> write properties of Sibelius.ActiveScore (available since Sibelius 6), but
> when I try this, nothing happens:
>
> Firstscore = Sibelius.ActiveScore;
> Secondscore = Sibelius.NthScore(2);
> Sibelius.ActiveScore = Secondscore;
>
> Thanks.
>
>
>
> _______________________________________________
> Plugin-dev mailing list
> [hidden email]
> http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com

_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
Reply | Threaded
Open this post in threaded view
|

Re: Switching Between Scores

Martin Marris
Hi Bob,

Let's say the user has opened two files. I know how to get the score object for the active score (score = Sibelius.ActiveScore). But how do I get the other score object? (These are files opened by the user, not files opened by the plugin.)

Sorry I know this is really elementary but I am stuck. I used to do a fair amount of this type of manipulation but cannot lay my hands on an actual past example.

Thanks!

Martin

-----Original Message-----
From: Plugin-dev [mailto:[hidden email]] On Behalf Of Bob Zawalich
Sent: Wednesday, February 28, 2018 13:40
To: A mailing list for Sibelius plug-in developers
Subject: Re: [Plugin-dev] Switching Between Scores

You always have interesting questions!

Basically, as long as you have two open scores and you have score objects for them, you can get their selections and then copy from them and paste from. You do have to use clipboard zero if you are going between scores.

 I don’t know that I’ve ever used NthScore; I suspect it would work but you would probably have to  look at the file name to see which score it was. I typically start with an open score and then open or create another score when I’m doing that sort of thing but as long as you have two score objects that are valid it really doesn’t matter which one is the active score. You just deal with the selection object for each score.

Hope that makes some sense.

Bob

> On Feb 28, 2018, at 9:11 AM, Martin Marris <[hidden email]> wrote:
>
> Hi,
>
> I used to know how to do this but cannot remember. If there are two
> files open in Sibelius, how does a plugin switch between them, for
> instance to copy an object from one file into another file?
>
> I think it has something to do with using the Sibelius.NthScore() and
> the write properties of Sibelius.ActiveScore (available since Sibelius
> 6), but when I try this, nothing happens:
>
> Firstscore = Sibelius.ActiveScore;
> Secondscore = Sibelius.NthScore(2);
> Sibelius.ActiveScore = Secondscore;
>
> Thanks.
>
>
>
> _______________________________________________
> Plugin-dev mailing list
> [hidden email]
> http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com

_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com


_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
Reply | Threaded
Open this post in threaded view
|

Re: Switching Between Scores

Bob Zawalich-3
I have a bunch of plugins that can operate on either the current score, all open scores or a folder of scores, and what you want is basically the 2nd case. So if we look in something like Score Original Version we find:

**************************************
numProcessed = 0;

for each score in Sibelius
{
        numProcessed = numProcessed + ProcessScoreNoSaveClose(score);
        // if you need to save or close, do it here (not typical - usually do not save or close open scores)

        // score.Save();
        // Sibelius.Close(False);
}

return numProcessed;

*****************************************

Sibelius.NthScore(score index from 0)
Returns the nth open score (zero-based), or null if the specified index is not valid.

should also get you a give score. The folder handling part of ScoreOriginalVersion  tries to deal with open scores as well.

It looks to see if any open scores come from the folder were are going to process

**********************************************
for each SIB file in folder
{
        iScore = IndexOfOpenScore(file.NameWithExt); // use this to make it easy to get at score for processing
        if (iScore != -1)
        {
                name = 'iscore' & numOpenScoresToProcess;
                @name = iScore;
                numOpenScoresToProcess = numOpenScoresToProcess + 1;
        }


**********************************************
        IndexOfOpenScore "(filenameScore) {
// return the NthScore index if the file is an open score, otherwise return -1. Needs Sib 6+

for i = 0 to Sibelius.ScoreCount
{
        if (filenameScore = Sibelius.NthScore(i).FileName)
        {
                //trace('IOS filename in, found name of open score, i: ' & filenameScore & ', ' & Sibelius.NthScore(i).FileName & ', ' & i);
                return i;
        }
}
return -1;}"
****************************************************

The for loop in IndexOfOpenScore shows a way to walk through open scores and identify them by score.FileName. Sibelius.ScoreCount is the number of open scores. There should be enough info from these examples of the plugins themselves to get you through.

I have at least a dozen plugins out there that use this sort of thing. I am attaching a template I use for such plugins, and you are welcome to reuse or take any bit you (or anyone else) might find useful. It has some instructions in the Run routine, and mostly you can get by with only changing the code in ProcessScoreNoSaveClose.

Ask again if this is not what you are looking for.

Bob

-----Original Message-----
From: Plugin-dev [mailto:[hidden email]] On Behalf Of Martin Marris
Sent: Wednesday, February 28, 2018 11:16 AM
To: 'A mailing list for Sibelius plug-in developers' <[hidden email]>
Subject: Re: [Plugin-dev] Switching Between Scores

Hi Bob,

Let's say the user has opened two files. I know how to get the score object for the active score (score = Sibelius.ActiveScore). But how do I get the other score object? (These are files opened by the user, not files opened by the plugin.)

Sorry I know this is really elementary but I am stuck. I used to do a fair amount of this type of manipulation but cannot lay my hands on an actual past example.

Thanks!

Martin

-----Original Message-----
From: Plugin-dev [mailto:[hidden email]] On Behalf Of Bob Zawalich
Sent: Wednesday, February 28, 2018 13:40
To: A mailing list for Sibelius plug-in developers
Subject: Re: [Plugin-dev] Switching Between Scores

You always have interesting questions!

Basically, as long as you have two open scores and you have score objects for them, you can get their selections and then copy from them and paste from. You do have to use clipboard zero if you are going between scores.

 I don’t know that I’ve ever used NthScore; I suspect it would work but you would probably have to  look at the file name to see which score it was. I typically start with an open score and then open or create another score when I’m doing that sort of thing but as long as you have two score objects that are valid it really doesn’t matter which one is the active score. You just deal with the selection object for each score.

Hope that makes some sense.

Bob

> On Feb 28, 2018, at 9:11 AM, Martin Marris <[hidden email]> wrote:
>
> Hi,
>
> I used to know how to do this but cannot remember. If there are two
> files open in Sibelius, how does a plugin switch between them, for
> instance to copy an object from one file into another file?
>
> I think it has something to do with using the Sibelius.NthScore() and
> the write properties of Sibelius.ActiveScore (available since Sibelius
> 6), but when I try this, nothing happens:
>
> Firstscore = Sibelius.ActiveScore;
> Secondscore = Sibelius.NthScore(2);
> Sibelius.ActiveScore = Secondscore;
>
> Thanks.
>
>
>
> _______________________________________________
> Plugin-dev mailing list
> [hidden email]
> http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com


_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com

_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com

MinimumPluginMultiScores.zip (9K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Switching Between Scores

Martin Marris
Hi Bob,

Sorry I am having trouble explaining what the issue is. There are two scores open. The human editor is working on Score A, but periodically needs to switch to Score B to run a plugin that searches B for a certain item and copies it to the clipboard, then the editor switches back to Score A to paste the item into A.

I am trying to simplify the editor's life so that they do not have to constantly switch manually between the scores. So while working on Score A, run a plugin which has a search field for what the editor wants to "fetch" from Score B. When you click OK, the plugin would fetch the item from Score B and paste it into the already highlighted position in Score A. The editor would never have to switch away from Score A.

The existing plugin that I wrote is very successful except for that tedious manual switching between files by the editor. BTW Score B is always the same file (it is a named, copy-protected resource file containing hundreds of boilerplate items). It is only Score A that changes name depending on the file the editor happens to be working on.

(So this is not a batch plugin processing files in a folder, it is for working on two files that are always open simultaneously.)

I hope that is clearer....

Thanks.


-----Original Message-----
From: Plugin-dev [mailto:[hidden email]] On Behalf Of Bob Zawalich
Sent: Wednesday, February 28, 2018 15:18
To: 'A mailing list for Sibelius plug-in developers'
Subject: Re: [Plugin-dev] Switching Between Scores

I have a bunch of plugins that can operate on either the current score, all open scores or a folder of scores, and what you want is basically the 2nd case. So if we look in something like Score Original Version we find:

**************************************
numProcessed = 0;

for each score in Sibelius
{
        numProcessed = numProcessed + ProcessScoreNoSaveClose(score);
        // if you need to save or close, do it here (not typical - usually do not save or close open scores)

        // score.Save();
        // Sibelius.Close(False);
}

return numProcessed;

*****************************************

Sibelius.NthScore(score index from 0)
Returns the nth open score (zero-based), or null if the specified index is not valid.

should also get you a give score. The folder handling part of ScoreOriginalVersion  tries to deal with open scores as well.

It looks to see if any open scores come from the folder were are going to process

**********************************************
for each SIB file in folder
{
        iScore = IndexOfOpenScore(file.NameWithExt); // use this to make it easy to get at score for processing
        if (iScore != -1)
        {
                name = 'iscore' & numOpenScoresToProcess;
                @name = iScore;
                numOpenScoresToProcess = numOpenScoresToProcess + 1;
        }


**********************************************
        IndexOfOpenScore "(filenameScore) {
// return the NthScore index if the file is an open score, otherwise return -1. Needs Sib 6+

for i = 0 to Sibelius.ScoreCount
{
        if (filenameScore = Sibelius.NthScore(i).FileName)
        {
                //trace('IOS filename in, found name of open score, i: ' & filenameScore & ', ' & Sibelius.NthScore(i).FileName & ', ' & i);
                return i;
        }
}
return -1;}"
****************************************************

The for loop in IndexOfOpenScore shows a way to walk through open scores and identify them by score.FileName. Sibelius.ScoreCount is the number of open scores. There should be enough info from these examples of the plugins themselves to get you through.

I have at least a dozen plugins out there that use this sort of thing. I am attaching a template I use for such plugins, and you are welcome to reuse or take any bit you (or anyone else) might find useful. It has some instructions in the Run routine, and mostly you can get by with only changing the code in ProcessScoreNoSaveClose.

Ask again if this is not what you are looking for.

Bob

-----Original Message-----
From: Plugin-dev [mailto:[hidden email]] On Behalf Of Martin Marris
Sent: Wednesday, February 28, 2018 11:16 AM
To: 'A mailing list for Sibelius plug-in developers' <[hidden email]>
Subject: Re: [Plugin-dev] Switching Between Scores

Hi Bob,

Let's say the user has opened two files. I know how to get the score object for the active score (score = Sibelius.ActiveScore). But how do I get the other score object? (These are files opened by the user, not files opened by the plugin.)

Sorry I know this is really elementary but I am stuck. I used to do a fair amount of this type of manipulation but cannot lay my hands on an actual past example.

Thanks!

Martin

-----Original Message-----
From: Plugin-dev [mailto:[hidden email]] On Behalf Of Bob Zawalich
Sent: Wednesday, February 28, 2018 13:40
To: A mailing list for Sibelius plug-in developers
Subject: Re: [Plugin-dev] Switching Between Scores

You always have interesting questions!

Basically, as long as you have two open scores and you have score objects for them, you can get their selections and then copy from them and paste from. You do have to use clipboard zero if you are going between scores.

 I don’t know that I’ve ever used NthScore; I suspect it would work but you would probably have to  look at the file name to see which score it was. I typically start with an open score and then open or create another score when I’m doing that sort of thing but as long as you have two score objects that are valid it really doesn’t matter which one is the active score. You just deal with the selection object for each score.

Hope that makes some sense.

Bob

> On Feb 28, 2018, at 9:11 AM, Martin Marris <[hidden email]> wrote:
>
> Hi,
>
> I used to know how to do this but cannot remember. If there are two
> files open in Sibelius, how does a plugin switch between them, for
> instance to copy an object from one file into another file?
>
> I think it has something to do with using the Sibelius.NthScore() and
> the write properties of Sibelius.ActiveScore (available since Sibelius
> 6), but when I try this, nothing happens:
>
> Firstscore = Sibelius.ActiveScore;
> Secondscore = Sibelius.NthScore(2);
> Sibelius.ActiveScore = Secondscore;
>
> Thanks.
>
>
>
> _______________________________________________
> Plugin-dev mailing list
> [hidden email]
> http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com

_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com


_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com


_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
Reply | Threaded
Open this post in threaded view
|

Re: Switching Between Scores

Bob Zawalich-3
Then it should be simple enough. At the start of the plugin  you know the filename for the resource score, so check the open scores to see if it is open; if not open it, and keep the score variable available, as a global variable if necessary. It should be fast enough to do this every time the plugin is run.

So you have that score and the active score. When the plugin is run use the recourse score object, validating it by the filename. Copy from it into clipboard 0 so it can paste cross-scores, then paste into the active score.

If I am missing something let me know but I think it should be pretty straightforward.

Code like this should be able to tell you if the score is open and available:

        IndexOfOpenScore "(filenameScore) {
// return the NthScore index if the file is an open score, otherwise return -1. Needs Sib 6+

for i = 0 to Sibelius.ScoreCount
{
        if (filenameScore = Sibelius.NthScore(i).FileName)
        {
                //trace('IOS filename in, found name of open score, i: ' & filenameScore & ', ' & Sibelius.NthScore(i).FileName & ', ' & i);
                return i;
        }
}
return -1;}"

You could have it return the score object if found, and null if not found. Or leave it as is and get the score from Sibelius.NthScore[i] if i != -1.



-----Original Message-----
From: Plugin-dev [mailto:[hidden email]] On Behalf Of Martin Marris
Sent: Wednesday, February 28, 2018 12:31 PM
To: 'A mailing list for Sibelius plug-in developers' <[hidden email]>
Subject: Re: [Plugin-dev] Switching Between Scores

Hi Bob,

Sorry I am having trouble explaining what the issue is. There are two scores open. The human editor is working on Score A, but periodically needs to switch to Score B to run a plugin that searches B for a certain item and copies it to the clipboard, then the editor switches back to Score A to paste the item into A.

I am trying to simplify the editor's life so that they do not have to constantly switch manually between the scores. So while working on Score A, run a plugin which has a search field for what the editor wants to "fetch" from Score B. When you click OK, the plugin would fetch the item from Score B and paste it into the already highlighted position in Score A. The editor would never have to switch away from Score A.

The existing plugin that I wrote is very successful except for that tedious manual switching between files by the editor. BTW Score B is always the same file (it is a named, copy-protected resource file containing hundreds of boilerplate items). It is only Score A that changes name depending on the file the editor happens to be working on.

(So this is not a batch plugin processing files in a folder, it is for working on two files that are always open simultaneously.)

I hope that is clearer....

Thanks.


-----Original Message-----
From: Plugin-dev [mailto:[hidden email]] On Behalf Of Bob Zawalich
Sent: Wednesday, February 28, 2018 15:18
To: 'A mailing list for Sibelius plug-in developers'
Subject: Re: [Plugin-dev] Switching Between Scores

I have a bunch of plugins that can operate on either the current score, all open scores or a folder of scores, and what you want is basically the 2nd case. So if we look in something like Score Original Version we find:

**************************************
numProcessed = 0;

for each score in Sibelius
{
        numProcessed = numProcessed + ProcessScoreNoSaveClose(score);
        // if you need to save or close, do it here (not typical - usually do not save or close open scores)

        // score.Save();
        // Sibelius.Close(False);
}

return numProcessed;

*****************************************

Sibelius.NthScore(score index from 0)
Returns the nth open score (zero-based), or null if the specified index is not valid.

should also get you a give score. The folder handling part of ScoreOriginalVersion  tries to deal with open scores as well.

It looks to see if any open scores come from the folder were are going to process

**********************************************
for each SIB file in folder
{
        iScore = IndexOfOpenScore(file.NameWithExt); // use this to make it easy to get at score for processing
        if (iScore != -1)
        {
                name = 'iscore' & numOpenScoresToProcess;
                @name = iScore;
                numOpenScoresToProcess = numOpenScoresToProcess + 1;
        }


**********************************************
        IndexOfOpenScore "(filenameScore) {
// return the NthScore index if the file is an open score, otherwise return -1. Needs Sib 6+

for i = 0 to Sibelius.ScoreCount
{
        if (filenameScore = Sibelius.NthScore(i).FileName)
        {
                //trace('IOS filename in, found name of open score, i: ' & filenameScore & ', ' & Sibelius.NthScore(i).FileName & ', ' & i);
                return i;
        }
}
return -1;}"
****************************************************

The for loop in IndexOfOpenScore shows a way to walk through open scores and identify them by score.FileName. Sibelius.ScoreCount is the number of open scores. There should be enough info from these examples of the plugins themselves to get you through.

I have at least a dozen plugins out there that use this sort of thing. I am attaching a template I use for such plugins, and you are welcome to reuse or take any bit you (or anyone else) might find useful. It has some instructions in the Run routine, and mostly you can get by with only changing the code in ProcessScoreNoSaveClose.

Ask again if this is not what you are looking for.

Bob

-----Original Message-----
From: Plugin-dev [mailto:[hidden email]] On Behalf Of Martin Marris
Sent: Wednesday, February 28, 2018 11:16 AM
To: 'A mailing list for Sibelius plug-in developers' <[hidden email]>
Subject: Re: [Plugin-dev] Switching Between Scores

Hi Bob,

Let's say the user has opened two files. I know how to get the score object for the active score (score = Sibelius.ActiveScore). But how do I get the other score object? (These are files opened by the user, not files opened by the plugin.)

Sorry I know this is really elementary but I am stuck. I used to do a fair amount of this type of manipulation but cannot lay my hands on an actual past example.

Thanks!

Martin

-----Original Message-----
From: Plugin-dev [mailto:[hidden email]] On Behalf Of Bob Zawalich
Sent: Wednesday, February 28, 2018 13:40
To: A mailing list for Sibelius plug-in developers
Subject: Re: [Plugin-dev] Switching Between Scores

You always have interesting questions!

Basically, as long as you have two open scores and you have score objects for them, you can get their selections and then copy from them and paste from. You do have to use clipboard zero if you are going between scores.

 I don’t know that I’ve ever used NthScore; I suspect it would work but you would probably have to  look at the file name to see which score it was. I typically start with an open score and then open or create another score when I’m doing that sort of thing but as long as you have two score objects that are valid it really doesn’t matter which one is the active score. You just deal with the selection object for each score.

Hope that makes some sense.

Bob

> On Feb 28, 2018, at 9:11 AM, Martin Marris <[hidden email]> wrote:
>
> Hi,
>
> I used to know how to do this but cannot remember. If there are two
> files open in Sibelius, how does a plugin switch between them, for
> instance to copy an object from one file into another file?
>
> I think it has something to do with using the Sibelius.NthScore() and
> the write properties of Sibelius.ActiveScore (available since Sibelius
> 6), but when I try this, nothing happens:
>
> Firstscore = Sibelius.ActiveScore;
> Secondscore = Sibelius.NthScore(2);
> Sibelius.ActiveScore = Secondscore;
>
> Thanks.
>
>
>
> _______________________________________________
> Plugin-dev mailing list
> [hidden email]
> http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com

_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com


_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com


_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com


_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
Reply | Threaded
Open this post in threaded view
|

Re: Switching Between Scores

Martin Marris
Hi Bob,

I haven't had any problem finding the Score B object, what is stumping me is how to switch to that score and run a "for each" loop on it. It runs it on the active score (Score A), regardless. As of Sib6, Sibelius.ActiveScore is supposed to be read/write but I cannot figure out how to get that to work for activating a particular (currently non-active, but open) score.

Confused....

Martin

-----Original Message-----
From: Plugin-dev [mailto:[hidden email]] On Behalf Of Bob Zawalich
Sent: Wednesday, February 28, 2018 15:45
To: 'A mailing list for Sibelius plug-in developers'
Subject: Re: [Plugin-dev] Switching Between Scores

Then it should be simple enough. At the start of the plugin  you know the filename for the resource score, so check the open scores to see if it is open; if not open it, and keep the score variable available, as a global variable if necessary. It should be fast enough to do this every time the plugin is run.

So you have that score and the active score. When the plugin is run use the recourse score object, validating it by the filename. Copy from it into clipboard 0 so it can paste cross-scores, then paste into the active score.

If I am missing something let me know but I think it should be pretty straightforward.

Code like this should be able to tell you if the score is open and available:

        IndexOfOpenScore "(filenameScore) {
// return the NthScore index if the file is an open score, otherwise return -1. Needs Sib 6+

for i = 0 to Sibelius.ScoreCount
{
        if (filenameScore = Sibelius.NthScore(i).FileName)
        {
                //trace('IOS filename in, found name of open score, i: ' & filenameScore & ', ' & Sibelius.NthScore(i).FileName & ', ' & i);
                return i;
        }
}
return -1;}"

You could have it return the score object if found, and null if not found. Or leave it as is and get the score from Sibelius.NthScore[i] if i != -1.



-----Original Message-----
From: Plugin-dev [mailto:[hidden email]] On Behalf Of Martin Marris
Sent: Wednesday, February 28, 2018 12:31 PM
To: 'A mailing list for Sibelius plug-in developers' <[hidden email]>
Subject: Re: [Plugin-dev] Switching Between Scores

Hi Bob,

Sorry I am having trouble explaining what the issue is. There are two scores open. The human editor is working on Score A, but periodically needs to switch to Score B to run a plugin that searches B for a certain item and copies it to the clipboard, then the editor switches back to Score A to paste the item into A.

I am trying to simplify the editor's life so that they do not have to constantly switch manually between the scores. So while working on Score A, run a plugin which has a search field for what the editor wants to "fetch" from Score B. When you click OK, the plugin would fetch the item from Score B and paste it into the already highlighted position in Score A. The editor would never have to switch away from Score A.

The existing plugin that I wrote is very successful except for that tedious manual switching between files by the editor. BTW Score B is always the same file (it is a named, copy-protected resource file containing hundreds of boilerplate items). It is only Score A that changes name depending on the file the editor happens to be working on.

(So this is not a batch plugin processing files in a folder, it is for working on two files that are always open simultaneously.)

I hope that is clearer....

Thanks.


-----Original Message-----
From: Plugin-dev [mailto:[hidden email]] On Behalf Of Bob Zawalich
Sent: Wednesday, February 28, 2018 15:18
To: 'A mailing list for Sibelius plug-in developers'
Subject: Re: [Plugin-dev] Switching Between Scores

I have a bunch of plugins that can operate on either the current score, all open scores or a folder of scores, and what you want is basically the 2nd case. So if we look in something like Score Original Version we find:

**************************************
numProcessed = 0;

for each score in Sibelius
{
        numProcessed = numProcessed + ProcessScoreNoSaveClose(score);
        // if you need to save or close, do it here (not typical - usually do not save or close open scores)

        // score.Save();
        // Sibelius.Close(False);
}

return numProcessed;

*****************************************

Sibelius.NthScore(score index from 0)
Returns the nth open score (zero-based), or null if the specified index is not valid.

should also get you a give score. The folder handling part of ScoreOriginalVersion  tries to deal with open scores as well.

It looks to see if any open scores come from the folder were are going to process

**********************************************
for each SIB file in folder
{
        iScore = IndexOfOpenScore(file.NameWithExt); // use this to make it easy to get at score for processing
        if (iScore != -1)
        {
                name = 'iscore' & numOpenScoresToProcess;
                @name = iScore;
                numOpenScoresToProcess = numOpenScoresToProcess + 1;
        }


**********************************************
        IndexOfOpenScore "(filenameScore) {
// return the NthScore index if the file is an open score, otherwise return -1. Needs Sib 6+

for i = 0 to Sibelius.ScoreCount
{
        if (filenameScore = Sibelius.NthScore(i).FileName)
        {
                //trace('IOS filename in, found name of open score, i: ' & filenameScore & ', ' & Sibelius.NthScore(i).FileName & ', ' & i);
                return i;
        }
}
return -1;}"
****************************************************

The for loop in IndexOfOpenScore shows a way to walk through open scores and identify them by score.FileName. Sibelius.ScoreCount is the number of open scores. There should be enough info from these examples of the plugins themselves to get you through.

I have at least a dozen plugins out there that use this sort of thing. I am attaching a template I use for such plugins, and you are welcome to reuse or take any bit you (or anyone else) might find useful. It has some instructions in the Run routine, and mostly you can get by with only changing the code in ProcessScoreNoSaveClose.

Ask again if this is not what you are looking for.

Bob

-----Original Message-----
From: Plugin-dev [mailto:[hidden email]] On Behalf Of Martin Marris
Sent: Wednesday, February 28, 2018 11:16 AM
To: 'A mailing list for Sibelius plug-in developers' <[hidden email]>
Subject: Re: [Plugin-dev] Switching Between Scores

Hi Bob,

Let's say the user has opened two files. I know how to get the score object for the active score (score = Sibelius.ActiveScore). But how do I get the other score object? (These are files opened by the user, not files opened by the plugin.)

Sorry I know this is really elementary but I am stuck. I used to do a fair amount of this type of manipulation but cannot lay my hands on an actual past example.

Thanks!

Martin

-----Original Message-----
From: Plugin-dev [mailto:[hidden email]] On Behalf Of Bob Zawalich
Sent: Wednesday, February 28, 2018 13:40
To: A mailing list for Sibelius plug-in developers
Subject: Re: [Plugin-dev] Switching Between Scores

You always have interesting questions!

Basically, as long as you have two open scores and you have score objects for them, you can get their selections and then copy from them and paste from. You do have to use clipboard zero if you are going between scores.

 I don’t know that I’ve ever used NthScore; I suspect it would work but you would probably have to  look at the file name to see which score it was. I typically start with an open score and then open or create another score when I’m doing that sort of thing but as long as you have two score objects that are valid it really doesn’t matter which one is the active score. You just deal with the selection object for each score.

Hope that makes some sense.

Bob

> On Feb 28, 2018, at 9:11 AM, Martin Marris <[hidden email]> wrote:
>
> Hi,
>
> I used to know how to do this but cannot remember. If there are two
> files open in Sibelius, how does a plugin switch between them, for
> instance to copy an object from one file into another file?
>
> I think it has something to do with using the Sibelius.NthScore() and
> the write properties of Sibelius.ActiveScore (available since Sibelius
> 6), but when I try this, nothing happens:
>
> Firstscore = Sibelius.ActiveScore;
> Secondscore = Sibelius.NthScore(2);
> Sibelius.ActiveScore = Secondscore;
>
> Thanks.
>
>
>
> _______________________________________________
> Plugin-dev mailing list
> [hidden email]
> http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com

_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com


_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com


_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com


_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com


_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
Reply | Threaded
Open this post in threaded view
|

Re: Switching Between Scores

Neil Sands
So you mean if you do

for each s in score
{
}

...then it ignores whatever is referred to in the score variable and
uses the active score instead?

On 28 February 2018 at 20:58, Martin Marris <[hidden email]> wrote:

> Hi Bob,
>
> I haven't had any problem finding the Score B object, what is stumping me is how to switch to that score and run a "for each" loop on it. It runs it on the active score (Score A), regardless. As of Sib6, Sibelius.ActiveScore is supposed to be read/write but I cannot figure out how to get that to work for activating a particular (currently non-active, but open) score.
>
> Confused....
>
> Martin
>
> -----Original Message-----
> From: Plugin-dev [mailto:[hidden email]] On Behalf Of Bob Zawalich
> Sent: Wednesday, February 28, 2018 15:45
> To: 'A mailing list for Sibelius plug-in developers'
> Subject: Re: [Plugin-dev] Switching Between Scores
>
> Then it should be simple enough. At the start of the plugin  you know the filename for the resource score, so check the open scores to see if it is open; if not open it, and keep the score variable available, as a global variable if necessary. It should be fast enough to do this every time the plugin is run.
>
> So you have that score and the active score. When the plugin is run use the recourse score object, validating it by the filename. Copy from it into clipboard 0 so it can paste cross-scores, then paste into the active score.
>
> If I am missing something let me know but I think it should be pretty straightforward.
>
> Code like this should be able to tell you if the score is open and available:
>
>         IndexOfOpenScore "(filenameScore) {
> // return the NthScore index if the file is an open score, otherwise return -1. Needs Sib 6+
>
> for i = 0 to Sibelius.ScoreCount
> {
>         if (filenameScore = Sibelius.NthScore(i).FileName)
>         {
>                 //trace('IOS filename in, found name of open score, i: ' & filenameScore & ', ' & Sibelius.NthScore(i).FileName & ', ' & i);
>                 return i;
>         }
> }
> return -1;}"
>
> You could have it return the score object if found, and null if not found. Or leave it as is and get the score from Sibelius.NthScore[i] if i != -1.
>
>
>
> -----Original Message-----
> From: Plugin-dev [mailto:[hidden email]] On Behalf Of Martin Marris
> Sent: Wednesday, February 28, 2018 12:31 PM
> To: 'A mailing list for Sibelius plug-in developers' <[hidden email]>
> Subject: Re: [Plugin-dev] Switching Between Scores
>
> Hi Bob,
>
> Sorry I am having trouble explaining what the issue is. There are two scores open. The human editor is working on Score A, but periodically needs to switch to Score B to run a plugin that searches B for a certain item and copies it to the clipboard, then the editor switches back to Score A to paste the item into A.
>
> I am trying to simplify the editor's life so that they do not have to constantly switch manually between the scores. So while working on Score A, run a plugin which has a search field for what the editor wants to "fetch" from Score B. When you click OK, the plugin would fetch the item from Score B and paste it into the already highlighted position in Score A. The editor would never have to switch away from Score A.
>
> The existing plugin that I wrote is very successful except for that tedious manual switching between files by the editor. BTW Score B is always the same file (it is a named, copy-protected resource file containing hundreds of boilerplate items). It is only Score A that changes name depending on the file the editor happens to be working on.
>
> (So this is not a batch plugin processing files in a folder, it is for working on two files that are always open simultaneously.)
>
> I hope that is clearer....
>
> Thanks.
>
>
> -----Original Message-----
> From: Plugin-dev [mailto:[hidden email]] On Behalf Of Bob Zawalich
> Sent: Wednesday, February 28, 2018 15:18
> To: 'A mailing list for Sibelius plug-in developers'
> Subject: Re: [Plugin-dev] Switching Between Scores
>
> I have a bunch of plugins that can operate on either the current score, all open scores or a folder of scores, and what you want is basically the 2nd case. So if we look in something like Score Original Version we find:
>
> **************************************
> numProcessed = 0;
>
> for each score in Sibelius
> {
>         numProcessed = numProcessed + ProcessScoreNoSaveClose(score);
>         // if you need to save or close, do it here (not typical - usually do not save or close open scores)
>
>         // score.Save();
>         // Sibelius.Close(False);
> }
>
> return numProcessed;
>
> *****************************************
>
> Sibelius.NthScore(score index from 0)
> Returns the nth open score (zero-based), or null if the specified index is not valid.
>
> should also get you a give score. The folder handling part of ScoreOriginalVersion  tries to deal with open scores as well.
>
> It looks to see if any open scores come from the folder were are going to process
>
> **********************************************
> for each SIB file in folder
> {
>         iScore = IndexOfOpenScore(file.NameWithExt); // use this to make it easy to get at score for processing
>         if (iScore != -1)
>         {
>                 name = 'iscore' & numOpenScoresToProcess;
>                 @name = iScore;
>                 numOpenScoresToProcess = numOpenScoresToProcess + 1;
>         }
>
>
> **********************************************
>         IndexOfOpenScore "(filenameScore) {
> // return the NthScore index if the file is an open score, otherwise return -1. Needs Sib 6+
>
> for i = 0 to Sibelius.ScoreCount
> {
>         if (filenameScore = Sibelius.NthScore(i).FileName)
>         {
>                 //trace('IOS filename in, found name of open score, i: ' & filenameScore & ', ' & Sibelius.NthScore(i).FileName & ', ' & i);
>                 return i;
>         }
> }
> return -1;}"
> ****************************************************
>
> The for loop in IndexOfOpenScore shows a way to walk through open scores and identify them by score.FileName. Sibelius.ScoreCount is the number of open scores. There should be enough info from these examples of the plugins themselves to get you through.
>
> I have at least a dozen plugins out there that use this sort of thing. I am attaching a template I use for such plugins, and you are welcome to reuse or take any bit you (or anyone else) might find useful. It has some instructions in the Run routine, and mostly you can get by with only changing the code in ProcessScoreNoSaveClose.
>
> Ask again if this is not what you are looking for.
>
> Bob
>
> -----Original Message-----
> From: Plugin-dev [mailto:[hidden email]] On Behalf Of Martin Marris
> Sent: Wednesday, February 28, 2018 11:16 AM
> To: 'A mailing list for Sibelius plug-in developers' <[hidden email]>
> Subject: Re: [Plugin-dev] Switching Between Scores
>
> Hi Bob,
>
> Let's say the user has opened two files. I know how to get the score object for the active score (score = Sibelius.ActiveScore). But how do I get the other score object? (These are files opened by the user, not files opened by the plugin.)
>
> Sorry I know this is really elementary but I am stuck. I used to do a fair amount of this type of manipulation but cannot lay my hands on an actual past example.
>
> Thanks!
>
> Martin
>
> -----Original Message-----
> From: Plugin-dev [mailto:[hidden email]] On Behalf Of Bob Zawalich
> Sent: Wednesday, February 28, 2018 13:40
> To: A mailing list for Sibelius plug-in developers
> Subject: Re: [Plugin-dev] Switching Between Scores
>
> You always have interesting questions!
>
> Basically, as long as you have two open scores and you have score objects for them, you can get their selections and then copy from them and paste from. You do have to use clipboard zero if you are going between scores.
>
>  I don’t know that I’ve ever used NthScore; I suspect it would work but you would probably have to  look at the file name to see which score it was. I typically start with an open score and then open or create another score when I’m doing that sort of thing but as long as you have two score objects that are valid it really doesn’t matter which one is the active score. You just deal with the selection object for each score.
>
> Hope that makes some sense.
>
> Bob
>
>> On Feb 28, 2018, at 9:11 AM, Martin Marris <[hidden email]> wrote:
>>
>> Hi,
>>
>> I used to know how to do this but cannot remember. If there are two
>> files open in Sibelius, how does a plugin switch between them, for
>> instance to copy an object from one file into another file?
>>
>> I think it has something to do with using the Sibelius.NthScore() and
>> the write properties of Sibelius.ActiveScore (available since Sibelius
>> 6), but when I try this, nothing happens:
>>
>> Firstscore = Sibelius.ActiveScore;
>> Secondscore = Sibelius.NthScore(2);
>> Sibelius.ActiveScore = Secondscore;
>>
>> Thanks.
>>
>>
>>
>> _______________________________________________
>> Plugin-dev mailing list
>> [hidden email]
>> http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
>
> _______________________________________________
> Plugin-dev mailing list
> [hidden email]
> http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
>
>
> _______________________________________________
> Plugin-dev mailing list
> [hidden email]
> http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
>
>
> _______________________________________________
> Plugin-dev mailing list
> [hidden email]
> http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
>
>
> _______________________________________________
> Plugin-dev mailing list
> [hidden email]
> http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
>
>
> _______________________________________________
> Plugin-dev mailing list
> [hidden email]
> http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com

_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
Reply | Threaded
Open this post in threaded view
|

Re: Switching Between Scores

Martin Marris
Hi Neil and Bob,

OK I got it working now. I found a typo in the code, and also I didn't realize that Sibelius.NthScore() uses a zero-based index, so I was off by one. A couple of lines of "trace" code nailed that down.

Finally getting somewhere. Trouble is I go sometimes many months without coding, and when I get back to it end up making some really obvious boo-boos.

Many thanks to both of you for your help.

Martin

-----Original Message-----
From: Plugin-dev [mailto:[hidden email]] On Behalf Of Neil Sands
Sent: Wednesday, February 28, 2018 16:06
To: A mailing list for Sibelius plug-in developers
Subject: Re: [Plugin-dev] Switching Between Scores

So you mean if you do

for each s in score
{
}

...then it ignores whatever is referred to in the score variable and uses the active score instead?

On 28 February 2018 at 20:58, Martin Marris <[hidden email]> wrote:

> Hi Bob,
>
> I haven't had any problem finding the Score B object, what is stumping me is how to switch to that score and run a "for each" loop on it. It runs it on the active score (Score A), regardless. As of Sib6, Sibelius.ActiveScore is supposed to be read/write but I cannot figure out how to get that to work for activating a particular (currently non-active, but open) score.
>
> Confused....
>
> Martin
>
> -----Original Message-----
> From: Plugin-dev [mailto:[hidden email]] On Behalf
> Of Bob Zawalich
> Sent: Wednesday, February 28, 2018 15:45
> To: 'A mailing list for Sibelius plug-in developers'
> Subject: Re: [Plugin-dev] Switching Between Scores
>
> Then it should be simple enough. At the start of the plugin  you know the filename for the resource score, so check the open scores to see if it is open; if not open it, and keep the score variable available, as a global variable if necessary. It should be fast enough to do this every time the plugin is run.
>
> So you have that score and the active score. When the plugin is run use the recourse score object, validating it by the filename. Copy from it into clipboard 0 so it can paste cross-scores, then paste into the active score.
>
> If I am missing something let me know but I think it should be pretty straightforward.
>
> Code like this should be able to tell you if the score is open and available:
>
>         IndexOfOpenScore "(filenameScore) { // return the NthScore
> index if the file is an open score, otherwise return -1. Needs Sib 6+
>
> for i = 0 to Sibelius.ScoreCount
> {
>         if (filenameScore = Sibelius.NthScore(i).FileName)
>         {
>                 //trace('IOS filename in, found name of open score, i: ' & filenameScore & ', ' & Sibelius.NthScore(i).FileName & ', ' & i);
>                 return i;
>         }
> }
> return -1;}"
>
> You could have it return the score object if found, and null if not found. Or leave it as is and get the score from Sibelius.NthScore[i] if i != -1.
>
>
>
> -----Original Message-----
> From: Plugin-dev [mailto:[hidden email]] On Behalf
> Of Martin Marris
> Sent: Wednesday, February 28, 2018 12:31 PM
> To: 'A mailing list for Sibelius plug-in developers'
> <[hidden email]>
> Subject: Re: [Plugin-dev] Switching Between Scores
>
> Hi Bob,
>
> Sorry I am having trouble explaining what the issue is. There are two scores open. The human editor is working on Score A, but periodically needs to switch to Score B to run a plugin that searches B for a certain item and copies it to the clipboard, then the editor switches back to Score A to paste the item into A.
>
> I am trying to simplify the editor's life so that they do not have to constantly switch manually between the scores. So while working on Score A, run a plugin which has a search field for what the editor wants to "fetch" from Score B. When you click OK, the plugin would fetch the item from Score B and paste it into the already highlighted position in Score A. The editor would never have to switch away from Score A.
>
> The existing plugin that I wrote is very successful except for that tedious manual switching between files by the editor. BTW Score B is always the same file (it is a named, copy-protected resource file containing hundreds of boilerplate items). It is only Score A that changes name depending on the file the editor happens to be working on.
>
> (So this is not a batch plugin processing files in a folder, it is for
> working on two files that are always open simultaneously.)
>
> I hope that is clearer....
>
> Thanks.
>
>
> -----Original Message-----
> From: Plugin-dev [mailto:[hidden email]] On Behalf
> Of Bob Zawalich
> Sent: Wednesday, February 28, 2018 15:18
> To: 'A mailing list for Sibelius plug-in developers'
> Subject: Re: [Plugin-dev] Switching Between Scores
>
> I have a bunch of plugins that can operate on either the current score, all open scores or a folder of scores, and what you want is basically the 2nd case. So if we look in something like Score Original Version we find:
>
> **************************************
> numProcessed = 0;
>
> for each score in Sibelius
> {
>         numProcessed = numProcessed + ProcessScoreNoSaveClose(score);
>         // if you need to save or close, do it here (not typical -
> usually do not save or close open scores)
>
>         // score.Save();
>         // Sibelius.Close(False);
> }
>
> return numProcessed;
>
> *****************************************
>
> Sibelius.NthScore(score index from 0)
> Returns the nth open score (zero-based), or null if the specified index is not valid.
>
> should also get you a give score. The folder handling part of ScoreOriginalVersion  tries to deal with open scores as well.
>
> It looks to see if any open scores come from the folder were are going
> to process
>
> **********************************************
> for each SIB file in folder
> {
>         iScore = IndexOfOpenScore(file.NameWithExt); // use this to make it easy to get at score for processing
>         if (iScore != -1)
>         {
>                 name = 'iscore' & numOpenScoresToProcess;
>                 @name = iScore;
>                 numOpenScoresToProcess = numOpenScoresToProcess + 1;
>         }
>
>
> **********************************************
>         IndexOfOpenScore "(filenameScore) { // return the NthScore
> index if the file is an open score, otherwise return -1. Needs Sib 6+
>
> for i = 0 to Sibelius.ScoreCount
> {
>         if (filenameScore = Sibelius.NthScore(i).FileName)
>         {
>                 //trace('IOS filename in, found name of open score, i: ' & filenameScore & ', ' & Sibelius.NthScore(i).FileName & ', ' & i);
>                 return i;
>         }
> }
> return -1;}"
> ****************************************************
>
> The for loop in IndexOfOpenScore shows a way to walk through open scores and identify them by score.FileName. Sibelius.ScoreCount is the number of open scores. There should be enough info from these examples of the plugins themselves to get you through.
>
> I have at least a dozen plugins out there that use this sort of thing. I am attaching a template I use for such plugins, and you are welcome to reuse or take any bit you (or anyone else) might find useful. It has some instructions in the Run routine, and mostly you can get by with only changing the code in ProcessScoreNoSaveClose.
>
> Ask again if this is not what you are looking for.
>
> Bob
>
> -----Original Message-----
> From: Plugin-dev [mailto:[hidden email]] On Behalf
> Of Martin Marris
> Sent: Wednesday, February 28, 2018 11:16 AM
> To: 'A mailing list for Sibelius plug-in developers'
> <[hidden email]>
> Subject: Re: [Plugin-dev] Switching Between Scores
>
> Hi Bob,
>
> Let's say the user has opened two files. I know how to get the score
> object for the active score (score = Sibelius.ActiveScore). But how do
> I get the other score object? (These are files opened by the user, not
> files opened by the plugin.)
>
> Sorry I know this is really elementary but I am stuck. I used to do a fair amount of this type of manipulation but cannot lay my hands on an actual past example.
>
> Thanks!
>
> Martin
>
> -----Original Message-----
> From: Plugin-dev [mailto:[hidden email]] On Behalf
> Of Bob Zawalich
> Sent: Wednesday, February 28, 2018 13:40
> To: A mailing list for Sibelius plug-in developers
> Subject: Re: [Plugin-dev] Switching Between Scores
>
> You always have interesting questions!
>
> Basically, as long as you have two open scores and you have score objects for them, you can get their selections and then copy from them and paste from. You do have to use clipboard zero if you are going between scores.
>
>  I don’t know that I’ve ever used NthScore; I suspect it would work but you would probably have to  look at the file name to see which score it was. I typically start with an open score and then open or create another score when I’m doing that sort of thing but as long as you have two score objects that are valid it really doesn’t matter which one is the active score. You just deal with the selection object for each score.
>
> Hope that makes some sense.
>
> Bob
>
>> On Feb 28, 2018, at 9:11 AM, Martin Marris <[hidden email]> wrote:
>>
>> Hi,
>>
>> I used to know how to do this but cannot remember. If there are two
>> files open in Sibelius, how does a plugin switch between them, for
>> instance to copy an object from one file into another file?
>>
>> I think it has something to do with using the Sibelius.NthScore() and
>> the write properties of Sibelius.ActiveScore (available since
>> Sibelius 6), but when I try this, nothing happens:
>>
>> Firstscore = Sibelius.ActiveScore;
>> Secondscore = Sibelius.NthScore(2);
>> Sibelius.ActiveScore = Secondscore;
>>
>> Thanks.
>>
>>
>>
>> _______________________________________________
>> Plugin-dev mailing list
>> [hidden email]
>> http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
>
> _______________________________________________
> Plugin-dev mailing list
> [hidden email]
> http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
>
>
> _______________________________________________
> Plugin-dev mailing list
> [hidden email]
> http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
>
>
> _______________________________________________
> Plugin-dev mailing list
> [hidden email]
> http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
>
>
> _______________________________________________
> Plugin-dev mailing list
> [hidden email]
> http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
>
>
> _______________________________________________
> Plugin-dev mailing list
> [hidden email]
> http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com

_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com


_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
Reply | Threaded
Open this post in threaded view
|

Re: Switching Between Scores

Neil Sands
I feel the same. I can't maintain fluency in Manuscript. I think I'm getting good at it, leave it for a while and come back in at square 1.

On 28 Feb 2018 9:57 pm, "Martin Marris" <[hidden email]> wrote:
Hi Neil and Bob,

OK I got it working now. I found a typo in the code, and also I didn't realize that Sibelius.NthScore() uses a zero-based index, so I was off by one. A couple of lines of "trace" code nailed that down.

Finally getting somewhere. Trouble is I go sometimes many months without coding, and when I get back to it end up making some really obvious boo-boos.

Many thanks to both of you for your help.

Martin

-----Original Message-----
From: Plugin-dev [mailto:[hidden email]] On Behalf Of Neil Sands
Sent: Wednesday, February 28, 2018 16:06
To: A mailing list for Sibelius plug-in developers
Subject: Re: [Plugin-dev] Switching Between Scores

So you mean if you do

for each s in score
{
}

...then it ignores whatever is referred to in the score variable and uses the active score instead?

On 28 February 2018 at 20:58, Martin Marris <[hidden email]> wrote:
> Hi Bob,
>
> I haven't had any problem finding the Score B object, what is stumping me is how to switch to that score and run a "for each" loop on it. It runs it on the active score (Score A), regardless. As of Sib6, Sibelius.ActiveScore is supposed to be read/write but I cannot figure out how to get that to work for activating a particular (currently non-active, but open) score.
>
> Confused....
>
> Martin
>
> -----Original Message-----
> From: Plugin-dev [mailto:[hidden email]] On Behalf
> Of Bob Zawalich
> Sent: Wednesday, February 28, 2018 15:45
> To: 'A mailing list for Sibelius plug-in developers'
> Subject: Re: [Plugin-dev] Switching Between Scores
>
> Then it should be simple enough. At the start of the plugin  you know the filename for the resource score, so check the open scores to see if it is open; if not open it, and keep the score variable available, as a global variable if necessary. It should be fast enough to do this every time the plugin is run.
>
> So you have that score and the active score. When the plugin is run use the recourse score object, validating it by the filename. Copy from it into clipboard 0 so it can paste cross-scores, then paste into the active score.
>
> If I am missing something let me know but I think it should be pretty straightforward.
>
> Code like this should be able to tell you if the score is open and available:
>
>         IndexOfOpenScore "(filenameScore) { // return the NthScore
> index if the file is an open score, otherwise return -1. Needs Sib 6+
>
> for i = 0 to Sibelius.ScoreCount
> {
>         if (filenameScore = Sibelius.NthScore(i).FileName)
>         {
>                 //trace('IOS filename in, found name of open score, i: ' & filenameScore & ', ' & Sibelius.NthScore(i).FileName & ', ' & i);
>                 return i;
>         }
> }
> return -1;}"
>
> You could have it return the score object if found, and null if not found. Or leave it as is and get the score from Sibelius.NthScore[i] if i != -1.
>
>
>
> -----Original Message-----
> From: Plugin-dev [mailto:[hidden email]] On Behalf
> Of Martin Marris
> Sent: Wednesday, February 28, 2018 12:31 PM
> To: 'A mailing list for Sibelius plug-in developers'
> <[hidden email]>
> Subject: Re: [Plugin-dev] Switching Between Scores
>
> Hi Bob,
>
> Sorry I am having trouble explaining what the issue is. There are two scores open. The human editor is working on Score A, but periodically needs to switch to Score B to run a plugin that searches B for a certain item and copies it to the clipboard, then the editor switches back to Score A to paste the item into A.
>
> I am trying to simplify the editor's life so that they do not have to constantly switch manually between the scores. So while working on Score A, run a plugin which has a search field for what the editor wants to "fetch" from Score B. When you click OK, the plugin would fetch the item from Score B and paste it into the already highlighted position in Score A. The editor would never have to switch away from Score A.
>
> The existing plugin that I wrote is very successful except for that tedious manual switching between files by the editor. BTW Score B is always the same file (it is a named, copy-protected resource file containing hundreds of boilerplate items). It is only Score A that changes name depending on the file the editor happens to be working on.
>
> (So this is not a batch plugin processing files in a folder, it is for
> working on two files that are always open simultaneously.)
>
> I hope that is clearer....
>
> Thanks.
>
>
> -----Original Message-----
> From: Plugin-dev [mailto:[hidden email]] On Behalf
> Of Bob Zawalich
> Sent: Wednesday, February 28, 2018 15:18
> To: 'A mailing list for Sibelius plug-in developers'
> Subject: Re: [Plugin-dev] Switching Between Scores
>
> I have a bunch of plugins that can operate on either the current score, all open scores or a folder of scores, and what you want is basically the 2nd case. So if we look in something like Score Original Version we find:
>
> **************************************
> numProcessed = 0;
>
> for each score in Sibelius
> {
>         numProcessed = numProcessed + ProcessScoreNoSaveClose(score);
>         // if you need to save or close, do it here (not typical -
> usually do not save or close open scores)
>
>         // score.Save();
>         // Sibelius.Close(False);
> }
>
> return numProcessed;
>
> *****************************************
>
> Sibelius.NthScore(score index from 0)
> Returns the nth open score (zero-based), or null if the specified index is not valid.
>
> should also get you a give score. The folder handling part of ScoreOriginalVersion  tries to deal with open scores as well.
>
> It looks to see if any open scores come from the folder were are going
> to process
>
> **********************************************
> for each SIB file in folder
> {
>         iScore = IndexOfOpenScore(file.NameWithExt); // use this to make it easy to get at score for processing
>         if (iScore != -1)
>         {
>                 name = 'iscore' & numOpenScoresToProcess;
>                 @name = iScore;
>                 numOpenScoresToProcess = numOpenScoresToProcess + 1;
>         }
>
>
> **********************************************
>         IndexOfOpenScore "(filenameScore) { // return the NthScore
> index if the file is an open score, otherwise return -1. Needs Sib 6+
>
> for i = 0 to Sibelius.ScoreCount
> {
>         if (filenameScore = Sibelius.NthScore(i).FileName)
>         {
>                 //trace('IOS filename in, found name of open score, i: ' & filenameScore & ', ' & Sibelius.NthScore(i).FileName & ', ' & i);
>                 return i;
>         }
> }
> return -1;}"
> ****************************************************
>
> The for loop in IndexOfOpenScore shows a way to walk through open scores and identify them by score.FileName. Sibelius.ScoreCount is the number of open scores. There should be enough info from these examples of the plugins themselves to get you through.
>
> I have at least a dozen plugins out there that use this sort of thing. I am attaching a template I use for such plugins, and you are welcome to reuse or take any bit you (or anyone else) might find useful. It has some instructions in the Run routine, and mostly you can get by with only changing the code in ProcessScoreNoSaveClose.
>
> Ask again if this is not what you are looking for.
>
> Bob
>
> -----Original Message-----
> From: Plugin-dev [mailto:[hidden email]] On Behalf
> Of Martin Marris
> Sent: Wednesday, February 28, 2018 11:16 AM
> To: 'A mailing list for Sibelius plug-in developers'
> <[hidden email]>
> Subject: Re: [Plugin-dev] Switching Between Scores
>
> Hi Bob,
>
> Let's say the user has opened two files. I know how to get the score
> object for the active score (score = Sibelius.ActiveScore). But how do
> I get the other score object? (These are files opened by the user, not
> files opened by the plugin.)
>
> Sorry I know this is really elementary but I am stuck. I used to do a fair amount of this type of manipulation but cannot lay my hands on an actual past example.
>
> Thanks!
>
> Martin
>
> -----Original Message-----
> From: Plugin-dev [mailto:[hidden email]] On Behalf
> Of Bob Zawalich
> Sent: Wednesday, February 28, 2018 13:40
> To: A mailing list for Sibelius plug-in developers
> Subject: Re: [Plugin-dev] Switching Between Scores
>
> You always have interesting questions!
>
> Basically, as long as you have two open scores and you have score objects for them, you can get their selections and then copy from them and paste from. You do have to use clipboard zero if you are going between scores.
>
>  I don’t know that I’ve ever used NthScore; I suspect it would work but you would probably have to  look at the file name to see which score it was. I typically start with an open score and then open or create another score when I’m doing that sort of thing but as long as you have two score objects that are valid it really doesn’t matter which one is the active score. You just deal with the selection object for each score.
>
> Hope that makes some sense.
>
> Bob
>
>> On Feb 28, 2018, at 9:11 AM, Martin Marris <[hidden email]> wrote:
>>
>> Hi,
>>
>> I used to know how to do this but cannot remember. If there are two
>> files open in Sibelius, how does a plugin switch between them, for
>> instance to copy an object from one file into another file?
>>
>> I think it has something to do with using the Sibelius.NthScore() and
>> the write properties of Sibelius.ActiveScore (available since
>> Sibelius 6), but when I try this, nothing happens:
>>
>> Firstscore = Sibelius.ActiveScore;
>> Secondscore = Sibelius.NthScore(2);
>> Sibelius.ActiveScore = Secondscore;
>>
>> Thanks.
>>
>>
>>
>> _______________________________________________
>> Plugin-dev mailing list
>> [hidden email]
>> http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
>
> _______________________________________________
> Plugin-dev mailing list
> [hidden email]
> http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
>
>
> _______________________________________________
> Plugin-dev mailing list
> [hidden email]
> http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
>
>
> _______________________________________________
> Plugin-dev mailing list
> [hidden email]
> http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
>
>
> _______________________________________________
> Plugin-dev mailing list
> [hidden email]
> http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
>
>
> _______________________________________________
> Plugin-dev mailing list
> [hidden email]
> http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com

_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com


_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com

_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com