Skip to main content
Participant
June 9, 2009
Question

AppleScript Control over Curves Adjustment Layer

  • June 9, 2009
  • 1 reply
  • 1612 views

Hi,

I would like to create a new Curves Adjustment Layer for the current document using AppleScript.  Then, I would like to be able to manipulate the curve data from within my script.  Is this possible?  I have not found a sample that illustrates doing this.

I am working on Photoshop CS3 Extended on a MacBook Pro.

Thank you

-- Bennett

This topic has been closed for replies.

1 reply

Paul Riggott
Inspiring
June 9, 2009

I don't think you can do it with AppleScript, you would have to use ScriptListner, as an example

http://www.ps-scripts.com/bb/viewtopic.php?t=2498

Muppet_Mark-QAl63s
Inspiring
June 9, 2009

No Adjustment Layers for sure with AppleScript and CS2 could not say for CS3. I do have a bunch of ScriptListener Functions that I call from AppleScript and pass variables into the recorded function. I may well have a ready made example of Curves Adjustment Layer but can't check until back at the work mac in the morning. With these you set the required data on creation no access to it after that.

Muppet_Mark-QAl63s
Inspiring
June 10, 2009

Here is a sample of a pre-built Curves Layer Adjustment. It should make some sense. In this you can see how to set 5 curve points and adjust the composite channels with the option of grouping the layer to a previous one.

tell application "Adobe Photoshop CS2"

activate

set Doc_Ref to the current document

tell Doc_Ref

set {ah, av, bh, bv, ch, cv, dh, dv, eh, ev, group} to {0, 0, 63, 53, 124, 127, 192, 204, 255, 255, true}

set myJS to "AdjustCurvesLayer();

// The Adjustment Layer Recorded Function

function AdjustCurvesLayer() {

  function cTID(s) { return app.charIDToTypeID(s); };

  function sTID(s) { return app.stringIDToTypeID(s); };

    var desc1 = new ActionDescriptor();

        var ref1 = new ActionReference();

        ref1.putClass( cTID('AdjL') );

    desc1.putReference( cTID('null'), ref1 );

        var desc2 = new ActionDescriptor();

        desc2.putBoolean( cTID('Grup'), " & group & " ); // Group to previous layer boolean

            var desc3 = new ActionDescriptor();

                var list3 = new ActionList();

                    var desc4 = new ActionDescriptor();

                        var ref2 = new ActionReference();

                        ref2.putEnumerated( cTID('Chnl'), cTID('Chnl'), cTID('Cmps') ); // Comosite Channels

                    desc4.putReference( cTID('Chnl'), ref2 );

                        var list4 = new ActionList();

                            var desc5 = new ActionDescriptor();

                            desc5.putDouble( cTID('Hrzn'), " & ah & " ); // Point 1

                            desc5.putDouble( cTID('Vrtc'), " & av & " ); // Point 1

                        list4.putObject( cTID('Pnt '), desc5 );

                            var desc6 = new ActionDescriptor();

                            desc6.putDouble( cTID('Hrzn'), " & bh & " ); // Point 2

                            desc6.putDouble( cTID('Vrtc'), " & bv & " ); // Point 2

                        list4.putObject( cTID('Pnt '), desc6 );

                            var desc7 = new ActionDescriptor();

                            desc7.putDouble( cTID('Hrzn'), " & ch & " ); // Point 3

                            desc7.putDouble( cTID('Vrtc'), " & cv & " ); // Point 3

                        list4.putObject( cTID('Pnt '), desc7 );

                            var desc8 = new ActionDescriptor();

                            desc8.putDouble( cTID('Hrzn'), " & dh & " ); // Point 4

                            desc8.putDouble( cTID('Vrtc'), " & dv & " ); // Point 4

                        list4.putObject( cTID('Pnt '), desc8 );

                            var desc9 = new ActionDescriptor();

                            desc9.putDouble( cTID('Hrzn'), " & eh & " ); // Point 5

                            desc9.putDouble( cTID('Vrtc'), " & ev & " ); // Point 5

                        list4.putObject( cTID('Pnt '), desc9 );

                    desc4.putList( cTID('Crv '), list4 );

                list3.putObject( cTID('CrvA'), desc4 );

            desc3.putList( cTID('Adjs'), list3 );

        desc2.putObject( cTID('Type'), cTID('Crvs'), desc3 );

    desc1.putObject( cTID('Usng'), cTID('AdjL'), desc2 );

    executeAction( cTID('Mk  '), desc1, DialogModes.NO );

};"

do javascript myJS show debugger on runtime error

end tell

end tell