2011-01-14 20 views
5

Başka bir .jsx komut dosyasını çalıştırdığınızda .jsx komut dosyasını nasıl alabilirim?Adobe InDesign .jsx script execute .jsx komut dosyası

Belki de bu benim yapmaya çalıştığım anlamak yardımcı olacaktır: yardımcı

// WebCard.jsx file 

function mySnippet(){ 
    //<fragment> 
    var myPageName, myFilePath, myFile; 
    var myDocument = app.documents.item(0); 
    var myBaseName = myDocument.name; 
    for(var myCounter = 0; myCounter < myDocument.pages.length; myCounter++){ 
     myPageName = myDocument.pages.item(myCounter).name; 
     app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange; 
     app.jpegExportPreferences.resolution = 96; 
     app.jpegExportPreferences.pageString = myPageName; 

      switch(myPageName) { 
     case "1" : myPageName = "EN FRONT WebCard"; 
      docType = "Web/Web Cards" break; 
     case "2" : myPageName = "EN BACK WebCard"; 
      docType = "Web/Web Cards" break; 
     case "3" : myPageName = "ES FRONT WebCard"; 
      docType = "Web/Web Cards" break; 
     case "4" : myPageName = "ES BACK WebCard"; 
      docType = "Web/Web Cards" break; 

    } 
     fileName = group + " " + myPageName + " " + date + ".jpg"; 

     myFilePath = dirPath + docType + "/" + fileName; 
     myDocument.exportFile(ExportFormat.jpg, File(myFilePath), false); 
    } 
    //</fragment> 
} 
//</snippet> 
       // execute PrintCard.jsx file 


//<teardown> 
function myTeardown(){ 
} 
//</teardown> 

Umut?

cevap

3

Diğer komut dosyalarını başlatmak için kullandığım bazı ExtendScript parçalarının bir kısmı; Ben After Effects içinde kullandım, ama muhtemelen çok InDesign çalışmak:

var theScriptFile = new File("/path/to/file.jsx"); 

var oldCurrentFolder = Folder.current; 
Folder.current = theScriptFile.parent; 

theScriptFile.open(); 
var theScriptContents = theScriptFile.read(); 
theScriptFile.close(); 

gCurrentScriptFile = theScriptFile; 

if(doDebug) 
    debugger; 

// You have entered the debugger in Launcher... 
// to debug the script you've launched, step 
// into the eval() function below. 
// 
eval("{" + theScriptContents + "}"); 

Folder.current = oldCurrentFolder; 
gCurrentScriptFile = ""; 

yaklaşım dosyasını okuyup eval etmektir. (PS başka bir iyi etiketi burada, ExtendScript olacaktır.) Ayrıca bakınız:

// ... Do something (will be executed before teardown script) 


#include "../path/to/teardown/script.jsx" 
// the path can be absolute or relative. 

Bu InDesign'da çalışması gerekir: http://omino.com/pixelblog/2007/11/15/binary-files-in-extendscript/

+0

Okumada biraz sorun yaşıyorum, başlatmak istediğim senaryoyu nereye yerleştiririm (PrintCard.jsx)? – jmituzas

+0

varScriptFile = new File ("/ absolute/path/to/PrintCard.jsx"); ama ... mutlak yola ihtiyacın olabilir ... adobe uygulamaları göreli yollar hakkında farklı davranabilir; Yeni Dosya ("../ PrintCard.jsx") veya benzeri yapıp yapamayacağınızı görmek için InDesign ile denemeniz gerekir; Mümkünse, düşündüğüm mutlak yoldan kaçınmaya çalışın. –

+0

Hahaha Belirttiğinizden beri tekrar okumalıydım: yeni Dosya ("/ yol/to/file.jsx"); - Bu konuda üzgünüm ... – jmituzas

5

Kolayca bunu dahil nerede noktada idam edilecek başka senaryo içerebilir CS3'ten yukarı doğru.

+0

Benim için mükemmel çalışıyor! Teşekkür ederim! – Syjin