I posted this in the Photoshop API forum and got no response. Maybe I'll have better luch here. ![]()
I have several ActionScript wrappers for Javascript code generated by the ScriptListener plug-in that manipulate Smart Filter layers. The code runs without any error under Windows. With Snow Leopard, it generates errors about the Set and Delete commands not being available for the smart Filter layers.
Suggestions about this would be appreciated.
Code samples follow.
Mitch
This code generates an error stating the "Set" command is not available:
private function applyNormalBlendToSmartFilterEffect():void {
try {
var idsetd:int = Photoshop.app.charIDToTypeID( "setd" );
var desc13:ActionDescriptor = new ActionDescriptor();
var idnull:int = new int;
var ref6:ActionReference = new ActionReference();
var idfilterFX:int = Photoshop.app.stringIDToTypeID( "filterFX" );
var idLyr:int = Photoshop.app.charIDToTypeID( "Lyr " );
var idOrdn:int = Photoshop.app.charIDToTypeID( "Ordn" );
var idTrgt:int = Photoshop.app.charIDToTypeID( "Trgt" );
var desc14:ActionDescriptor = new ActionDescriptor();
var idblendOptions:int = Photoshop.app.stringIDToTypeID( "blendOptions" );
var desc15:ActionDescriptor = new ActionDescriptor();
var idOpct:int = Photoshop.app.charIDToTypeID( "Opct" );
var idPrc:int = Photoshop.app.charIDToTypeID( "#Prc" );
var idMd:int = Photoshop.app.charIDToTypeID( "Md " );
var idBlnM:int = Photoshop.app.charIDToTypeID( "BlnM" );
var idDrkn:int = Photoshop.app.charIDToTypeID( "Nrml" );
catch(error:Error) {
"Error in applyNormalBlendToSmartFilterLayer(): " + error.message, "Error!", Alert.OK, Sprite(mx.core.Application.application));
This code generates an error stating the Delete command is not available.
private function deleteLayerEffectsMask():void {
try {
var idDlt:int = Photoshop.app.charIDToTypeID( "Dlt " );
var desc3:ActionDescriptor = new ActionDescriptor();
var idnull:int = new int;
var ref2:ActionReference = new ActionReference();
var idChnl:int = Photoshop.app.charIDToTypeID( "Chnl" );
var idfilterMask:int = Photoshop.app.stringIDToTypeID( "filterMask" );
catch(error:Error) {
"Error in deleteLayerEffectsMask(): " + error.message, "Error!", Alert.OK, Sprite(mx.core.Application.application));
}
}
Alert.show(
ref2.putEnumerated( idChnl, idChnl, idfilterMask );
desc3.putReference( idnull, ref2 );
Photoshop.app.executeAction( idDlt, desc3, DialogModes.NO );
}
}
}
Alert.show(
desc15.putEnumerated( idMd, idBlnM, idDrkn );
desc14.putObject( idblendOptions, idblendOptions, desc15 );
desc13.putObject( idfilterFX, idfilterFX, desc14 );
Photoshop.app.executeAction( idsetd, desc13, DialogModes.NO );
}
desc15.putUnitDouble( idOpct, idPrc, 100.000000 );
ref6.putEnumerated( idLyr, idOrdn, idTrgt );
desc13.putReference( idnull, ref6 );
ref6.putIndex( idfilterFX, 1 );
I can't say I've run your code, but any discrepancy between Windows and Mac in Photoshop makes me think of the issue Bob has described here: http://cookbooks.adobe.com/post_Creative_Suite_5_Extensions_and_Photos hop_CS5_Redu-17727.html
Have you given that a shot?
No, Zak. I wish it was. I had read Bob's cookbook entry before I asked.
I'm using DOM calls generated by the ScriptLIstener for Javascript. These are converted to ActionScript. They run fine under Windows.
The code I'm struggling with compiles fine and runs fine under Windows. It does not use timers or other OS generated events. It simply tries to access Smart Filter Layer properties. I'm using ScriptListener, because the Photoshop DOM does not support Smart Filter Layers.
I often use Smart Filter Layers which apply several filters in succession and with a different layer blend for the overall layer and the individual filters. For example, I might use Lighten with USM, Darken with USM (each with different settigs, perhaps) and then a Luminosity blend for the overall layer itself.
I wish the Photoshop libraries supported this. I'd prefer that to DOM calls. As Bob notes, they are a nuisance and inflexible. Unfortunately, they are still sometimes necessary.
I thank you for taking the time time to offer a suggestion.
Happy holidays!
Mitch
I haven't tried that, Bob. I've always modified the Javascript code, since it is very close to Action Script. The major differences, as I'm sure you know, is that Action Script is stronger typed than Javascript, so you have to add explicit type declarations to the Action Script.
I'll gladly send you the source code and the object code.
Thanks for checking this. I'll try your suggestion about EvalScript.
Mitch
Mitch,
I have found one other ActionDescriptor that doesn't work. That one was undocumented, so I didn't worry too much about it (things like that can change on you). That you might have found another makes me want to take a deeper look.
Everything I've tried in the past as ES has worked, so I think you should have a viable workaround. I am going to try your code behind the workaround for the Mac/PS event bug just to see what happens.
Regards
Bob
Thans, Bob.
I have avoided EvalScript from CSXS out of concern for performance. Plus it means a separate script file for each function.
OTOH, if it will get the panels to work so people can start using them, that would be wonderful.
The code that seems to cause issues is with the SmartFilter Layer Effects. As you know already, a Smart Filter Layer can apply multiple effects. My code usues that a lot to reduce the RAM requirements and file sizes by reducing the number of pixel layers. The code, for example, can sharpen separately the light and dark edge contours and use only one layer.
Your comment about missing ActionDescriptors does ake sense.
I've been a software developer too long not to understand that these things happen. I have long been impressed with the smart way that Adobe has built programmer extensibility into Photoshop.
http://www.thelightsright.com/BigKudosToPhotoshopEngineeringTeam
When you have a massive object model that has been adapted and extended in lots of ways, its easy to overlook something. ![]()
I'm guessing here . . . It appears that not many people are working with Smart Filter Layer Effects. Or you likely would have heard about this problem before.
If you're curious about what the code is all about, here's the link to the CS4 version.
http://www.thelightsright.com/TLRProCaptureSharpeningPanel
Thanks so much for your help.
Mitch
gmitchel wrote:
Thans, Bob.
I have avoided EvalScript from CSXS out of concern for performance. Plus it means a separate script file for each function.
There's no noticeable performance hit that I've seen.
You do not need separate scripts. You can create one script with all the functions you need and load it up when you create your panel. You can then run ExtendScript functions as easily as ActionScript ones using HostObject. Read Zak's post here: http://cookbooks.adobe.com/post_Communicating_between_JavaScript_and_t he_CS_SDK_us-17383.html
It's possible to use CSXSInterface.evalScript() as well, but HostObject is way better.
Harbs
Yes, I do now recall that I could use one file. Some of my early panels did nothing more than provide a CS4 panel for selecting among scripts.
I was not aware about the ease of embedding them. That's nice.
These are all very straight forward function calls. They might pass in a parameter or two, but the return would always be void.
I'll take a look at Zak's cookbook. Thanks.
Cheers,
Mitch
Mitch,
Could you email or post a photoshop file that has content that will support those calls (along with what layers and whatnot need to be selected for the calls to be valid)? email: bostucky@adobe.com
Thanks
Bob
I just sent them to bostucky@adobe.com
I'm getting the same error on Snow Leopard any way I try it (AS or ES).
I've got another customer reporting a similar error (command "X" not available), but only sporadically. But that one's on a Save command, and in both Win & Mac.
At this point, I don't know what to tell you other than I'll file a bug on it...
Bob
Perhaps I spoke too soon. I went back to look at it - I had a small error in the jsx.
This approach just worked for me on Snow Leopard...
The attached files, main.jsx is your TLRProCaptureSharpening.mxml, renamed (Extension Builder defaults to main.mxml) and modified to call the jsx. SmartFilterEffect.jsx contains your two erroring functions converted to jsx. Place it in the src folder.
Give it a try!
Bob
North America
Europe, Middle East and Africa
Asia Pacific