Messages in this thread

ApplyStyle() doesn't work on long file path - Raven Cheuk, 28 Nov 05:48PM
     Re: ApplyStyle() doesn't work on long file path - Robin Walker, 28 Nov 05:59PM
         Re: ApplyStyle() doesn't work on long file path - Raven Cheuk, 29 Nov 01:23AM
         Re: ApplyStyle() doesn't work on long file path - Bob Zawalich, 29 Nov 03:21AM
             Re: ApplyStyle() doesn't work on long file path - Raven Cheuk, 29 Nov 05:54AM
                 Re: ApplyStyle() doesn't work on long file path - Bob Zawalich, 29 Nov 09:14AM

ApplyStyle() doesn't work on long file path
Posted by Raven Cheuk - 28 Nov 05:48PM
I want to import the house style via a plugin.
However, I discover that the ApplyStyle() only works for short path name C:\XXX.lib. If the file path is long than this, there will be no effect on the score.

Below is the code that demonstrates my problem.
The first 4 ApplyStyle() don't work, only the last one with the shortest path name works.

What's going on here? Can anyone explain it to me?


{
Initialize "(){ AddToPluginsMenu('Import house','Run'); }"
Run "() {

score=Sibelius.ActiveScore;
score.ApplyStyle('C:\ProgramData\Avid\Sibelius\Resources\Jazz Inkpen2.lib','ALLSTYLES');
Sibelius.MessageBox('1');
score.ApplyStyle('C:\ProgramData\Avid\Sibelius\Jazz Inkpen2.lib','ALLSTYLES');
Sibelius.MessageBox('2');
score.ApplyStyle('C:\ProgramData\Avid\Jazz Inkpen2.lib','ALLSTYLES');
Sibelius.MessageBox('3');
score.ApplyStyle('C:\ProgramData\Jazz Inkpen2.lib','ALLSTYLES');
Sibelius.MessageBox('4');
score.ApplyStyle('C:\Jazz Inkpen2.lib','ALLSTYLES');
}"
}

Back to top | All threads
 
Re: ApplyStyle() doesn't work on long file path
Posted by Robin Walker - 28 Nov 05:59PM
I don't quite understand what you are trying to achieve. The final ApplyStyle will overwrite all the earlier ones, whether they work or not. Can you provide more information on what you mean by "The first 4 ApplyStyle() don't work"? In what sense do they "not work"? What are the symptoms?

--
Sibelius 8.4/7.5.1/7.1.3/6.2/5.2.5, PhotoScore Ult 8.0.4, Dolet 6.6 for Sibelius, Windows 10 64-bit 16GB. Desktop no-name, Microsoft Surface Book.

Back to top | All threads
 
Re: ApplyStyle() doesn't work on long file path
Posted by Raven Cheuk - 29 Nov 01:23AM
I know the final ApplyStyle will overwrite all the earlier ones, that's why I add a Sibelius.MessageBox() right after each of them to see the effect.

What I want to achieve is to import the house style.

Here’s the problem I am having now.
I tried score.ApplyStyle('C:\ProgramData\Avid\Sibelius\Resources\Jazz Inkpen2.lib','ALLSTYLES');
But the score has no change at all after running the plugin.

Then I move the .lib file one level earlier and use
score.ApplyStyle('C:\ProgramData\Avid\Sibelius\Jazz Inkpen2.lib','ALLSTYLES');
But the score have no change at all

Then I move the .lib file even one level earlier and use
score.ApplyStyle('C:\ProgramData\Avid\Jazz Inkpen2.lib','ALLSTYLES');
Again the score has no change at all

Again I move the .lib file one level earlier and use
score.ApplyStyle('C:\ProgramData\Jazz Inkpen2.lib','ALLSTYLES');
Again the score has no change at all

Fianally I move the .lib file one level earlier and use
score.ApplyStyle('C:\Jazz Inkpen2.lib','ALLSTYLES');
The house style successfully imported and the score style changed.

Back to top | All threads
 
Re: ApplyStyle() doesn't work on long file path
Posted by Bob Zawalich - 29 Nov 03:21AM (edited 29 Nov 03:27AM)
There are MessageBox calls between the calls to ApplyStyle, so I assume the idea is to apply a style and then bring up a message box and visually inspect for changes.

Unfortunately, the redraw timing is such that you may not see the change in the score at those points in time.

Are you sure that the paths you are using are valid and there is a file at those locations? You might try using Sibelius.FileExists(pathname) to check.

If they do exist I am not sure what to say. The Add Notehead Names plugins seem to work with a full path.

I am also not sure it a single "\" works. A lot of times you need to use "\\" in a literal string. The plugins I have seen that work are building up path names from components, and they use the Sibelius.PathSeparator variable, as in

pluginsFolder = utils.GetSibeliusPluginsFolder();
fileName = pluginsFolder & Sibelius.PathSeparator & HouseStyle & '.lib';

In this case, the house style is being found in the Plugins subfolder, which is not typical - usually it looks in the House Styles Folder. But it alt least indicates that you should be able to specify a file path.

Try FileExists and see if the correct path is being sent. I am personally skeptical about the backslash, even though the ManuScript document says to do it that way.



--
Bob

An experienced user of Sibelius. Sib 1.2 - 8, Windows 10 Pro 64 bit, 32 G RAM. Year 2016.
For plugin categories see http://www.sibeliusblog.com/tips/sibelius-download-page-plug-ins/

Back to top | All threads
 
Re: ApplyStyle() doesn't work on long file path
Posted by Raven Cheuk - 29 Nov 05:54AM
> Try FileExists and see if the correct path is being sent. I am personally skeptical about the backslash, even though the ManuScript document says to do it that way.
>
>
>
> --
> Bob
>
> An experienced user of Sibelius. Sib 1.2 - 8, Windows 10 Pro 64 bit, 32 G RAM. Year 2016.
> For plugin categories see http://www.sibeliusblog.com/tips/sibelius-download-page-plug-ins/

Hi Bob,
Your suggestion is very helpful.
By using the the FileExists function, I can see that all of them return as false except in the path "C:\Jazz Inkpen2.lib"

So I tried to add double backslash to all the paths. Then all the FileExists return as true. You're right, the problem is the backslash.

Alternatively, I discovered that if the house style is located in the original folder, i.e.
"C:\ProgramData\Avid\Sibelius\Resources\en.lproj\House Styles"
There is no need to type in the full path in the ApplyStyle() function. Just the file name such as "Jazz Inkpen2.lib" will do the job.

Thanks Bob!
The problem has been solved! :)

Back to top | All threads
 
Re: ApplyStyle() doesn't work on long file path
Posted by Bob Zawalich - 29 Nov 09:14AM
As the ManuScript doc says in ApplyStyle:

"The style file parameter can either be a full path to
the file, or just the name of one of the styles that appears in the House Style > Import House Style dialog"

So indeed, just the file name will work for loaded House Style files.

--
Bob

An experienced user of Sibelius. Sib 1.2 - 8, Windows 10 Pro 64 bit, 32 G RAM. Year 2016.
For plugin categories see http://www.sibeliusblog.com/tips/sibelius-download-page-plug-ins/

Back to top | All threads
 

Quick reply

To add a reply to the end of this thread, type it below, then click Reply.

(.sib, .png and .jpg only)

Messages in this thread

ApplyStyle() doesn't work on long file path - Raven Cheuk, 28 Nov 05:48PM
     Re: ApplyStyle() doesn't work on long file path - Robin Walker, 28 Nov 05:59PM
         Re: ApplyStyle() doesn't work on long file path - Raven Cheuk, 29 Nov 01:23AM
         Re: ApplyStyle() doesn't work on long file path - Bob Zawalich, 29 Nov 03:21AM
             Re: ApplyStyle() doesn't work on long file path - Raven Cheuk, 29 Nov 05:54AM
                 Re: ApplyStyle() doesn't work on long file path - Bob Zawalich, 29 Nov 09:14AM