Article View: adobe.scripting.indesign
Article #73Re: [CS3 JS] event crashes InDesign
From: Kasyan_Servetsky
Date: Fri, 27 Mar 2009 17:33
Date: Fri, 27 Mar 2009 17:33
88 lines
7179 bytes
7179 bytes
Hi Rasmus,
Here is an example of scripted plug-in — very simple yet useful for me.
Its goal is to check color settings in InDesign and Photoshop after a document opens. We use two profiles at work: one for the main part of our magazine and another profile for its cover and the inset for another magazine. Sometimes, although rarely, we forget to switch on the correct setting.
That's where the plug-in comes to the aid. After a document opens it checks if the file name contains certain characters – e.g. if file name starts with "Obl_" that means that this is a cover and the script checks the color settings, if they are not correct it gives warning.
Here is short description of how to do it:
Create a new scripted plug-in project from APIDTemplate.indd file.
Open APID panel
Enter 'docLoaded' into Event Filter field and press Enter
Here is the script that does the job (the script file is generated in the same folder as indd-file):
if (theItem.eventCode == "docLoaded") {
var gKasmyDoc = app.activeDocument;
var gKasDocumentName = app.activeDocument.name;
KasCheckProfile();
KasinfoFromPS();
}
function KasCheckProfile(){
var myIssueNumber = parseInt(gKasDocumentName.substr(2, 3));
if (gKasDocumentName.substr(0, 2) == "Q_" && myIssueNumber >= 730 && myIssueNumber <= 999 && gKasDocumentName.match("_Vshivka") == null){
if (app.colorSettings.workingSpaceCMYK != "ISO Web Coated"){
alert("Внимание! Для газеты должен использоваться провиль \"ISO Web Coated\", а установлен. — " + app.colorSettings.workingSpaceCMYK);
}
}
if (gKasDocumentName.substr(0, 2) == "Q_" && myIssueNumber >= 730 && myIssueNumber <= 999 && gKasDocumentName.match("_Vshivka") != null){
if (app.colorSettings.workingSpaceCMYK != "ImationMatchprn175lpi_avr.icc "){
alert("Внимание! Для вшивки должен использоваться провиль \"ImationMatchprn175lpi_avr.icc\", а установлен. — " + app.colorSettings.workingSpaceCMYK);
}
}
else if (gKasDocumentName.substr(0, 4) == "Obl_"){
if (app.colorSettings.workingSpaceCMYK != "ImationMatchprn175lpi_avr.icc "){
// alert("Внимание! Для обложки должен использоваться провиль \"ImationMatchprn175lpi_avr.icc\", а установлен. — " + app.colorSettings.workingSpaceCMYK);
if (confirm("Внимание! Для обложки должен использоваться провиль \"ImationMatchprn175lpi_avr.icc\", а установлен. — " + app.colorSettings.workingSpaceCMYK)) {
app.colorSettings.cmsSettings = "Listovaya Mashina";
}
}
}
}
function KasinfoFromPS() {
var bt = new BridgeTalk;
bt.target = "photoshop";
bt.body = "app.colorSettings;"
bt.onResult = function(resObj) {
var myResult = resObj.body;
KascheckPsColorSettings(myResult);
}
bt.send();
}
function KascheckPsColorSettings(myColorSettings){
var myIssueNumber = parseInt(gKasDocumentName.substr(2, 3));
if (gKasDocumentName.substr(0, 2) == "Q_" && myIssueNumber >= 730 && myIssueNumber <= 999 && gKasDocumentName.match("_Vshivka") == null){
if (myColorSettings != "ISO Web Coated"){
alert("Внимание в Photoshop! Для газеты должен использоваться провиль \"ISO Web Coated\", а установлен. — \"" + myColorSettings + "\"");
}
}
if (gKasDocumentName.substr(0, 2) == "Q_" && myIssueNumber >= 730 && myIssueNumber <= 999 && gKasDocumentName.match("_Vshivka") != null){
if (myColorSettings != "Listovaya Mashina"){
alert("Внимание в Photoshop! Для вшивки должен использоваться провиль \"ImationMatchprn175lpi_avr.icc\", а установлен. — \"" + myColorSettings + "\"");
}
}
else if (gKasDocumentName.substr(0, 4) == "Obl_"){
if (myColorSettings != "Listovaya Mashina"){
alert("Внимание в Photoshop! Для обложки должен использоваться провиль \"ImationMatchprn175lpi_avr.icc\", а установлен. — \"" + myColorSettings + "\"");
}
}
}
You can put your own stuff into the script:
if (theItem.eventCode == "docLoaded") {
// do your stuff here
}
And finally generate the plug-in.
Kasyan
Technical Details
Message-ID:
<59b86a93.2@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!news2.glorb.com!newshub.sdsu.edu!webcrossingReferences:
<59b86a93.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,d51bfd07ae7dff66 X-Google-Attributes: gidf939a,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Kasyan_Servetsky@adobeforums.com Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!news2.glorb.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.scripting.indesign Subject: Re: [CS3 JS] event crashes InDesign Message-ID: <59b86a93.2@webcrossing.la2eafNXanI> Date: Fri, 27 Mar 2009 10:33:28 -0700 References: <59b86a93.-1@webcrossing.la2eafNXanI> Lines: 125 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit