My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* Toggles the layer between a solid and gradient fill.
* Written by Richard Z. - richkzad@gmail.com
*
* Thanks to Yasuyuki Higuchi and Scott Weichert for tips on how to reproduce
* the functionality by creating an action in Photoshop CS3 and then running
* it in Photoshop CS4
* http://www.adobeforums.com/webx?128@@.59b6e5bb
*
* Thanks to xbytor for writing a script that would convert an action into
* JavaScript to help understand what was really going on.
* http://ps-scripts.cvs.sourceforge.net/*checkout*/ps-scripts/xtools/apps/ActionToJavascript.jsx
*/

var changeFill = new ActionDescriptor(),
layerRef = new ActionReference();

layerRef.putEnumerated(
stringIDToTypeID('contentLayer'),
charIDToTypeID('Ordn'),
charIDToTypeID('Trgt')
);

changeFill.putReference(
charIDToTypeID('null'),
layerRef
);

try {

var layerKind = typeIDToStringID(executeActionGet(layerRef).getList(charIDToTypeID('Adjs')).getObjectType(0));

changeFill.putClass(
charIDToTypeID('T '),
stringIDToTypeID(
'gradientLayer' == layerKind ? 'solidColorLayer' : 'gradientLayer'
)
);

executeAction(charIDToTypeID('setd'), changeFill, DialogModes.ALL);

} catch (e) { }

Change log

r4 by richkzad on Nov 9, 2008   Diff
Added thanks.
Go to: 
Project members, sign in to write a code review

Older revisions

r3 by richkzad on Nov 9, 2008   Diff
Now actually just switches the fill
type of the original layer, and
displays the proper dialogs.
r2 by richkzad on Nov 8, 2008   Diff
Adding the initial script.
All revisions of this file

File info

Size: 1241 bytes, 42 lines
Powered by Google Project Hosting