2017-07-16 7 views
0

この問題はInDesignに膨大な量のインライングラフィックスを配置する必要がありますが、私がJasmiteでiMacでInDesign CC2014で作業していますf [i] .insertionPoints [0] .rectangles.add({geometricBounds:

次のエラーが発生しました。メッセージは、ポップ・アップ:

エラーがスナップ:

error snap

誰かが私にこれについての光を与えるなら、私はとてもうれしいでしょう。

main(); 
 

 
function main() { 
 
var name, f, file, text, 
 
arr = []; 
 

 
if(app.documents.length != 0) { 
 
    var doc = app.activeDocument; 
 
    var folder = Folder.selectDialog("Choose a folder with images"); 
 

 
    if (folder != null) { 
 
     app.findObjectPreferences = app.changeGrepPreferences = NothingEnum.NOTHING; 
 
     app.findGrepPreferences.findWhat = "@[email protected]"; 
 
     f = doc.findGrep(true); 
 

 
     for (i = 0; i < f.length; i++) { 
 
      name = f[i].contents.replace(/@/g, ""); 
 
      file = new File(folder.fsName + "/" + name); 
 

 
      if (file.exists) { 
 
       f[i].contents = ""; 
 
       var rect = f[i].insertionPoints[0].rectangles.add({geometricBounds:[0,0, 60, 40.667 ]}); 
 
\t \t \t \t rect.place (file); 
 
\t \t \t \t rect.fit (FitOptions.FRAME_TO_CONTENT); 
 
       
 
      } 
 
      else { 
 
       arr.push("File doesn't exist '" + name + "'"); 
 
      } 
 
     } 
 

 
     app.findObjectPreferences = app.changeGrepPreferences = NothingEnum.NOTHING; 
 

 
     arr.push("------------------------------------------"); 
 
     text = arr.join("\r"); 
 
     writeToFile(text); 
 
    } 
 
} 
 
else{ 
 
    alert("Please open a document and try again."); 
 
} 
 
} 
 

 
function writeToFile(text) { 
 
var file = new File("~/Desktop/Place inline images.txt"); 
 
if (file.exists) { 
 
    file.open("e"); 
 
    file.seek(0, 2); 
 
} 
 
else { 
 
    file.open("w"); 
 
} 
 
file.write(text + "\r"); 
 
file.close(); 
 
}

答えて

1

問題がある - おそらく - 原因スクリプトが見つかりました。内容を編集し、コードの次の行でそれを参照のうえれます。 逆ループを使用して、後に行にf [i] .contents = ""を移動することをお勧めします。

main(); 

function main() { 
var name, f, cF, file, text, 
arr = []; 

if(app.documents.length != 0) { 
    var doc = app.activeDocument; 
    var folder = Folder.selectDialog("Choose a folder with images"); 

    if (folder != null) { 
     app.findObjectPreferences = app.changeGrepPreferences = NothingEnum.NOTHING; 
     app.findGrepPreferences.findWhat = "@[email protected]"; 
     f = doc.findGrep(true); 

     while(cF = f.pop()) { 
      name = cF.contents.replace(/@/g, ""); 
      file = new File(folder.fsName + "/" + name); 

      if (file.exists) { 
       var rect = cF.insertionPoints[0].rectangles.add({geometricBounds:[0,0, 60, 40.667 ]}); 
       rect.place (file); 
       rect.fit (FitOptions.FRAME_TO_CONTENT); 
       cF.contents = ""; 
      } 
      else { 
       arr.push("File doesn't exist '" + name + "'"); 
      } 
     } 

     app.findObjectPreferences = app.changeGrepPreferences = NothingEnum.NOTHING; 

     arr.push("------------------------------------------"); 
     text = arr.join("\r"); 
     writeToFile(text); 
    } 
} 
else{ 
    alert("Please open a document and try again."); 
} 
} 

function writeToFile(text) { 
var file = new File("~/Desktop/Place inline images.txt"); 
if (file.exists) { 
    file.open("e"); 
    file.seek(0, 2); 
} 
else { 
    file.open("w"); 
} 
file.write(text + "\r"); 
file.close(); 
} 
+0

かのtry/catch句を使用しますよう

何か。 –

+0

お返事ありがとうございます。はい、それは問題でした。既に取り除かれたか空になったものを置き換えることはできません。それは多くの助けとなりました。 – alejorojas2k

関連する問題