Last active
January 10, 2020 01:55
-
-
Save MarshySwamp/26e66344b8e5f8b5594afa06f8582f74 to your computer and use it in GitHub Desktop.
Code Snippet: Add New Art Layer Named “Red” (4 different approaches)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //community.adobe.com/t5/photoshop/modify-script-to-create-a-specific-name-for-new-layer/m-p/10843395#M295794 | |
| /* | |
| // Standard DOM code: | |
| app.activeDocument.artLayers.add(); | |
| app.activeDocument.activeLayer.name = 'Red'; | |
| */ | |
| /* | |
| // ActionDescriptor Code: | |
| sTT = stringIDToTypeID; (ref = new ActionReference()).putClass(sTT('layer')); | |
| (dsc1 = new ActionDescriptor()).putReference(sTT('null'), ref); | |
| (dsc2 = new ActionDescriptor()).putString(sTT('name'), 'Red') | |
| dsc1.putObject(sTT('using'), sTT('layer'), dsc2) | |
| executeAction(sTT('make'), dsc1) | |
| */ | |
| /* | |
| // Standard ScriptListener AM Code: | |
| var idMk = charIDToTypeID( "Mk " ); | |
| var desc9 = new ActionDescriptor(); | |
| var idnull = charIDToTypeID( "null" ); | |
| var ref1 = new ActionReference(); | |
| var idLyr = charIDToTypeID( "Lyr " ); | |
| ref1.putClass( idLyr ); | |
| desc9.putReference( idnull, ref1 ); | |
| var idUsng = charIDToTypeID( "Usng" ); | |
| var desc10 = new ActionDescriptor(); | |
| var idNm = charIDToTypeID( "Nm " ); | |
| desc10.putString( idNm, """Red""" ); | |
| var idLyr = charIDToTypeID( "Lyr " ); | |
| desc9.putObject( idUsng, idLyr, desc10 ); | |
| var idLyrI = charIDToTypeID( "LyrI" ); | |
| desc9.putInteger( idLyrI, 2 ); | |
| executeAction( idMk, desc9, DialogModes.NO ); | |
| */ | |
| /* | |
| // AM Code Through Clean SL: | |
| make("Red", 2); | |
| function make(name2, layerID) { | |
| var c2t = function (s) { | |
| return app.charIDToTypeID(s); | |
| }; | |
| var s2t = function (s) { | |
| return app.stringIDToTypeID(s); | |
| }; | |
| var descriptor = new ActionDescriptor(); | |
| var descriptor2 = new ActionDescriptor(); | |
| var reference = new ActionReference(); | |
| reference.putClass( s2t( "layer" )); | |
| descriptor2.putReference( c2t( "null" ), reference ); | |
| descriptor.putString( s2t( "name" ), name2 ); | |
| descriptor2.putObject( s2t( "using" ), s2t( "layer" ), descriptor ); | |
| descriptor2.putInteger( s2t( "layerID" ), layerID ); | |
| executeAction( s2t( "make" ), descriptor2, DialogModes.NO ); | |
| } | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment