2013-10-23 42 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