2011-01-14 4 views
5

다른 .jsx 스크립트를 완료하면 내 .jsx 스크립트를 어떻게 가질 수 있습니까?Adobe InDesign .jsx 스크립트는 .jsx 스크립트를 실행합니다.

어쩌면 이것이 내가 뭘하려고 오전 이해하는 데 도움이됩니다 도움이

// 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> 

희망?

답변

3

다음은 다른 스크립트를 실행하는 데 사용하는 ExtendScript의 일부입니다. 나는 After Effects에서 그것을 사용했지만, 그것은 아마 너무 InDesign에서 작동 :

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 = ""; 

접근 방식은 파일을 읽고 그것을 평가 후면입니다. (PS는 또 다른 좋은 태그는 여기에, 수정 ExtendScript 될 것입니다.) 참조 :

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


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

이 InDesign에서 작동합니다 : http://omino.com/pixelblog/2007/11/15/binary-files-in-extendscript/

+0

나는 그것을 읽는데 약간의 문제가있다. 내가 시작하고 싶은 스크립트 (PrintCard.jsx)를 어디에 두 겠는가? – jmituzas

+0

var theScriptFile = 새 파일 ("/ 절대/경로/to/PrintCard.jsx"); 하지만 ... 절대 경로가 필요할 수 있습니다 ... 어도비 애플 리케이션은 상대 경로에 대해 다르게 동작 할 수 있습니다. InDesign을 사용하여 새 파일 ("../ PrintCard.jsx") 또는 유사한 파일을 만들 수 있는지 확인해야합니다. 가능하다면 나는 절대적인 길을 피하려고 노력한다. –

+0

하하하 당신이 진술 한 이후로 다시 읽어야합니다 : new File ("/ path/to/file.jsx"); - 죄송합니다 ... – jmituzas

5

당신은 쉽게 당신이 (가) 있습니다 시점에서 실행됩니다 다른 스크립트를 포함 할 수 있습니다 CS3 이상.

+0

저를 위해 완벽하게 작동합니다! 고맙습니다! – Syjin

관련 문제