任何想法爲什麼有時候腳本被調用來運行它會啓動ExtendScript Toolkit &只是失速?我想也許有很多文字需要通過。不確定每次都是這種情況。請參閱下面的腳本。爲什麼腳本有時會啓動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
我試過這個http://pastebin.com/sNyNSB1h但它不工作。這是正確的軌道和接近解決方案? – Brianedl
不對,這更糟糕。 ;(看看這個.https://gist.github.com/4351305但是這隻查找字符內容,第一個腳本中的searchTerms是RegExp語法,所以你必須使用String.search或者String.replace與他們http://www.w3schools.com/jsref/jsref_obj_regexp.asp – fabianmoronzirfas
這是非常有益的,謝謝,我會與它合作,並嘗試學習更多的腳本我希望你有一個良好的聖誕節和新年! – Brianedl