3

スクリプトが呼び出されて実行されると、ExtendScript Toolkit が起動して停止することがある理由はありますか? 通過するテキストがたくさんある場合は、おそらくそうだと思います。毎回そうであるとは限りません。スクリプトの下の写真を参照してください。

停止する場合は次の行で停止します: var new_string = this_text_frame.contents.replace(search_string, replace_string);

    // Version 3

function myReplace(search_string, replace_string) {
    var active_doc = app.activeDocument;
    var text_frames = active_doc.textFrames;
    if (text_frames.length > 0)
    {
        for (var i = 0 ; i < text_frames.length; i++)
        {
            var this_text_frame = text_frames[i];
            var new_string = this_text_frame.contents.replace(search_string, replace_string);
            if (new_string != this_text_frame.contents)
            {
                this_text_frame.contents = new_string;
                }
            }
        }
    }
myReplace(/^PRG.*/i, "");
myReplace(/.*EBOM.*/i, "");
myReplace(/^PH.*0000.*/i, "");
myReplace(/^PH.*00\/.*/i, "");
//  N or W  &  6 #'s   &   -S_    EX. N123456-S_  REPLACE with:  N123456-S???    (THIS NEEDS TO BE ABOVE  _ REPLACED BY SPACE)
myReplace(/([NW]\d{6}-S)_/i, "$1??? ");

myReplace(/_/gi, " ");
//  6 #'s   &  - or no -  &  7 #'s   &  1 to 3 #'s   &  -    EX: 123456-1234567/123-  REPLACE with:  -123456-
myReplace(/(\d{6})-?\d{7}\/\d\d?\d?-/i, "-$1-");
myReplace(/(\d{6})-?\d{7}-\/\d\d?\d?-/i, "-$1-");

myReplace(/([NW]\d{6}-S)-INS-\d\d\/\d\d?-/i, "$1??? ");

myReplace(/-INS-\d\d\/\d\d?-/i, "* ");

//  -  That is only followed by one more -  &   Not having PIA   &  -  &   2 to 3 #'s   &   /   &   1 to 3 #'s   &   -      EX:   -7NPSJ_RH-001/9-   REPLACE with  * & Space
myReplace(/-[^-]*-\d\d\d?\/\d\d?\d?-/i, "* ");

myReplace(/ ?ASSEMBLY/gi, " ASY");
myReplace(/ ASS?Y+$| ASS?Y - | ASS?Y -| ASS?Y | ASS?Y- | ASS?Y-/gi, " ASY - ");

myReplace(/(MCA-|DS-?C1-?)/i, "-");

myReplace(/^DS-|^DI-|^PH-|MCA|^PAF-|^PAF|^FDR-|^FDR/i, "");

myReplace(/VIEW ([a-z])/i, "TTEMPP $1");

myReplace(/ ?\(?V?I?EW\)| ?\(?VIE[W)]?|^W\)| ?\(VI+$|^ ?\(VI| ?\(V+$|^ ?\(V| ?\(+$|^ ?\)/i, "");

myReplace(/TTEMPP ([a-z])/i, "VIEW $1");

myReplace(/([NW]\d{6}-S)-/i, "$1??? ");
myReplace(/([NW]\d{6}-S)\/.-/i, "$1??? ");

//   Needs to be in this order
myReplace(/ AND /i, "&");
myReplace(/WASHER/i, "WSHR");
myReplace(/BOLT/i, "BLT");
myReplace(/STUD/i, "STU");
myReplace(/([SCREW|SC|NUT|BLT|STU])&WSHR/i, "$1 & WSHR");
myReplace(/\?\?\? SCREW &/i, "??? SC &");
myReplace(/\?\?\? SC [^&]/i, "??? SCREW ");
myReplace(/(\?\?\? SC & WSHR).*/i, "$1");
myReplace(/(\?\?\? SCREW).*/i, "$1");
myReplace(/(\?\?\? NUT & WSHR).*/i, "$1");
myReplace(/\?\?\? NUT [^&].*/i, "??? NUT");
myReplace(/(\?\?\? BLT & WSHR).*/i, "$1");
myReplace(/\?\?\? BLT [^&].*/i, "??? BLT");
myReplace(/(\?\?\? STU & WSHR).*/i, "$1");
myReplace(/\?\?\? STU [^&].*/i, "??? STU");

myReplace(/--/gi, "-");


if ( app.documents.length > 0 && app.activeDocument.textFrames.length > 0 ) {
// Set the value of the word to look for
searchWord1 = "*";
//searchWord2 = "The";

// Iterate through all words in the document
// the words that match searchWord
for ( i = 0; i < app.activeDocument.textFrames.length; i++ ) {
textArt = activeDocument.textFrames[i];
for ( j = 0; j < textArt.characters.length; j++) {
word = textArt.characters[j];
if ( word.contents == searchWord1 ) {

word.verticalScale = 120;
word.horizontalScale = 140;
word.baselineShift = -3;
}
}
}
}

[img]http://i.imgur.com/9IRy9.jpg[/img]

この JavaScript は、AppleScript から実行するための呼び出しです。

    set Apps_Folder to (path to applications folder as text)
set Scripts_Path to "Adobe Illustrator CS5:Presets.localized:en_US:Scripts:"
set JS_FileName to "Text Find & Replace.jsx"
--
try
    set JS_File to Apps_Folder & Scripts_Path & JS_FileName as alias
    tell application "Adobe Illustrator"
        do javascript JS_File show debugger on runtime error
    end tell
on error
    display dialog "Script file '" & JS_FileName & "' NOT found?" giving up after 2
end try
4

3 に答える 3

1

エラーコードを検索しましたか?

1346458189 ('MRAP')  

ESTKの最下部にあります。ここを見てください http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/pdf/illustrator/scripting/cs6/Readme.txt

「MRAP」ではなく「PARM」ですが、数は合っています。

「Illustrator エラーが発生しました: 1346458189 ('PARM')」アラート (1459349)
影響: JavaScript
問題:このアラートは 、ExtendScript Toolkit から Illustrator で
不注意に記述されたスクリプトを繰り返し実行すると表示されることがあります。

各スクリプトの実行は、
Illustrator 内の同じ永続的な ExtendScript エンジン内で実行されます。最終的な効果は、ExtendScript エンジンの状態が、 以前
に実行されたすべてのスクリプトにわたって累積されることです。

スクリプト コードに関する次の問題により、この問題が発生する可能性があります。

  • 初期化されていない変数の読み取り。
  • 異なる
    スクリプトの 2 つのグローバルが同じ名前を持つ場合など、グローバル名前空間が競合します。

スクリプトには、初期化されていない変数がいくつかあります

searchWord1 = "*"; 

textArt = activeDocument.textFrames[i];

word = textArt.characters[j];
于 2012-12-20T13:28:57.733 に答える