2011-01-14 24 views
5

別の.jsxスクリプトの実行が完了したら、.jsxスクリプトを作成するにはどうすればよいですか?Adob​​e 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 = ""; 

アプローチは、ファイルを読んで、それをevalにあります。 (PS別の良いタグは、ここでは、ExtendScriptのだろう。)も参照してください:これは、InDesignで動作するはず

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


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

http://omino.com/pixelblog/2007/11/15/binary-files-in-extendscript/

+0

私はそれを読むのに少し問題があります。私はどこで起動したいのですか(PrintCard.jsx)? – jmituzas

+0

var TheScriptFile =新しいファイル( "/ absolute/path/to/PrintCard.jsx");しかし...あなたは絶対パスが必要かもしれません... Adob​​eアプリケーションは相対パスに関して異なる動作をするかもしれません。 InDesignで新しいFile( "../ PrintCard.jsx")などを実行できるかどうか試してみる必要があります。可能であれば、私が思う絶対的な道を避けてみてください。 –

+0

私は新しいファイル( "/ path/to/file.jsx"); - それについて申し訳ありません... – jmituzas

5

あなたが簡単にあなたがそれを含める時点で実行される別のスクリプトを含めることができますCS3から上へ

+0

私のために完全に動作します!ありがとうございました! – Syjin

関連する問題