-
Notifications
You must be signed in to change notification settings - Fork 2
/
[IG]_Cleanup_documet.jsx
94 lines (82 loc) · 3.49 KB
/
[IG]_Cleanup_documet.jsx
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// **************************** Photoshop Script *************************//
// ***********************************************************************//
//
// ** [IG]_Cleanup_document
// ** @description Remove from document:
// - Guides
// - Layer comps
// - Alpha Channels
// - Patch items
//
// **
// ** @author Igor Grinchesku <igor.grinchesku@gmail.com>
// ** @github https://github.com/Arahnoid/IG-Photoshop-Scripts
// ** @date August 7, 2014
// ** @require Adobe Photoshop CS5, or higher
// ** @instalation https://github.com/Arahnoid/IG-Photoshop-Scripts
//
// ***********************************************************************//
// BEGIN__HARVEST_EXCEPTION_ZSTRING
<javascriptresource>
<name>$$$/JavaScripts/[IG]_Cleanup_document/Menu=[IG] Cleanup document</name>
<category>IG</category>
<enableinfo>true</enableinfo>
<eventid>5be806f7-1621-4e9a-bf3b-9559bf21f1a1</eventid>
</javascriptresource>
// END__HARVEST_EXCEPTION_ZSTRING
// #target photoshop
app.bringToFront();
// ********************************** START ******************************//
/** Store Units Settings ===================================================**/
var startRulerUnits = app.preferences.rulerUnits,
startTypeUnits = app.preferences.typeUnits,
startDisplayDialogs = app.displayDialogs;
// Set Adobe Photoshop to use pixels and display no dialogs
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.PIXELS;
app.displayDialogs = DialogModes.NO;
/** End - Store Units Settings =============================================**/
// Setting doc variable
try {
var doc = app.activeDocument;
} catch (e) {
throw new Error(alert('You need to have opened at least one document'));
}
///////////////////////////////////////////////////////////////////////////////
// Script
///////////////////////////////////////////////////////////////////////////////
if (app.documents.length > 0) { // If any document is opened
var doc = app.activeDocument;
var answer = confirm(
'This script will remove: \n ' +
'Layer Comps,\n ' +
'All Guides, Additional Alpha channels in Channels palette,\n ' +
'Path Items', false, 'Clean document!');
// If user agree do
if (answer) {
doc.layerComps.removeAll(); // Remove Layer Comps
doc.chanels.removeAll(); // Remove all channels
doc.pathItems.removeAll(); // Remove Path items
clearGuides();
}
}
//===========================================================================//
// Functions
//===========================================================================//
function clearGuides() { // Remove Guides
var idDlt = charIDToTypeID('Dlt ');
var desc5 = new ActionDescriptor();
var idnull = charIDToTypeID('null');
var ref1 = new ActionReference();
var idGd = charIDToTypeID('Gd ');
var idOrdn = charIDToTypeID('Ordn');
var idAl = charIDToTypeID('Al ');
ref1.putEnumerated(idGd, idOrdn, idAl);
desc5.putReference(idnull, ref1);
executeAction(idDlt, desc5, DialogModes.NO);
}
/** Restore Units Settings ================================================ **/
app.preferences.rulerUnits = startRulerUnits;
app.preferences.typeUnits = startTypeUnits;
app.displayDialogs = startDisplayDialogs;
/** End - Restored Units Settings ========================================= **/