Copy link to clipboard
Copied
Hi,
Is there a way in javascript to block the refresh of photoshop ?
I'm having a script that is hiding and showing layers, but as I have hundreds of them, and photoshop refreshing the interface each time I change the visibility of a layer, it gets extremly slow ...
I'm only interested but the end result, not the in-between steps.
If you have any idea, please let me know !
Thanks a lot,
Julien
Copy link to clipboard
Copied
var idsetd = charIDToTypeID( "setd" );
var desc3 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref2 = new ActionReference();
var idPrpr = charIDToTypeID( "Prpr" );
var idPbkO = charIDToTypeID( "PbkO" );
ref2.putProperty( idPrpr, idPbkO );
var idcapp = charIDToTypeID( "capp" );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref2.putEnumerated( idcapp, idOrdn, idTrgt );
desc3.putReference( idnull, ref2 );
var idT = charIDToTypeID( "T " );
var desc4 = new ActionDescriptor();
var idperformance = stringIDToTypeID( "performance" );
var idperformance = stringIDToTypeID( "performance" );
var idaccelerated = stringIDToTypeID( "accelerated" );
desc4.putEnumerated( idperformance, idperformance, idaccelerated );
var idPbkO = charIDToTypeID( "PbkO" );
desc3.putObject( idT, idPbkO, desc4 );
executeAction( idsetd, desc3, DialogModes.NO );
Copy link to clipboard
Copied
I have CS6 on Win 7 64 bit and the above code gives me an error: illegal argument.
Any help? My scripts are running quite slow due to all of the image refreshing and I'd love to be able to block that.
Copy link to clipboard
Copied
Some times this forum's software strips out what it thinks are extra spaces in text. Make sure that charIDToTypeID( "T " ) has 3 spaces inside the quotes. CharIDs must have 4 characters.
Copy link to clipboard
Copied
Thank you. That solved my problem.
Copy link to clipboard
Copied
Chuck Uebele:
I tried this code but I didn't see a change. Isn't it turned on by default in last Photoshop versions?
Copy link to clipboard
Copied
It might be. I haven't really checked but I know I used to have to put it in some of my scripts so that they would change from acceleration mode to step mode for things like manual cropping, and some other applications.
Copy link to clipboard
Copied
This is equivalent of setting the PlaybackOptions in the Actions panel:
The code it gives in the SL (cleaned) is as follows – CC2017:
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var reference = new ActionReference();
var descriptor2 = new ActionDescriptor();
reference.putProperty( s2t( "property" ), s2t( "playbackOptions" ));
reference.putEnumerated( s2t( "application" ), s2t( "ordinal" ), s2t( "targetEnum" ));
descriptor.putReference( s2t( "null" ), reference );
descriptor2.putEnumerated( s2t( "performance" ), s2t( "performance" ), s2t( "accelerated" ));
descriptor.putObject( s2t( "to" ), s2t( "playbackOptions" ), descriptor2 );
executeAction( s2t( "set" ), descriptor, DialogModes.NO );
Hope this helps,
Davide
Copy link to clipboard
Copied
Thanks David... now it makes sense.
So I assume that scripts in modern Photoshop are accelerated by default.