2013-10-23 71 views
0

開始使用Illustrator腳本並嘗試編寫一個腳本,該腳本允許我通過輸入更改變量並生效保存設置。保存選項我想改變是如下:Illustrator保存選項和使用變量設置

-- Save and overwrite 
save theCurrentFile in file WorkPath as Illustrator ¬ 
    with options {class:Illustrator save options ¬ 
    , compatibility:Illustrator 14 ¬ 
    , embed linked files:true ¬ 
    , font subset threshold:0.0} 

我希望能夠向兼容性更改爲一個變量,但無論我設置的變量,我無法理解它。我是在這樣的事情之後:

--Variable 
set CompatibilityType to "Illustrator 14" 

-- Save and overwrite 
save theCurrentFile in file WorkPath as Illustrator ¬ 
    with options {class:Illustrator save options ¬ 
    , compatibility:CompatibilityType ¬ 
    , embed linked files:true ¬ 
    , font subset threshold:0.0} 

我在想什麼,這不想工作。我在一個屬性列表中做了類似的事情。

回答

1

兼容性表示爲在Illustrator字典中定義的枚舉,而不是字符串。您正在嘗試使用"Illustrator 14"來表示兼容版本。你需要的是Illustrator 14。注意缺乏引號。您可以使用以下子例程將字符串轉換爲即時枚舉。當然,如果你願意,你可以改變字符串表示。這些只是我使用的。

set CompatibilityType to my convertIllustratorVersion("CS4") 

save theCurrentFile in file WorkPath as Illustrator ¬ 
    with options {class:Illustrator save options ¬ 
    , compatibility:CompatibilityType ¬ 
    , embed linked files:true ¬ 
    , font subset threshold:0.0} 

on convertIllustratorVersion(originalVersion) 
    using terms from application "Adobe Illustrator" 
     set versions to {"CS", "CS2", "CS3", "CS4", "CS5"} 
     set enums to {Illustrator 11, Illustrator 12, Illustrator 13, Illustrator 14, Illustrator 15} 
    end using terms from 

    repeat with i from 1 to (count versions) 
     if originalVersion is item i of versions then 
      return item i of enums 
     end if 
    end repeat 

    error (quoted form of originalVersion & " is not a valid Illustrator version") 
end convertVersionNumber