【问题标题】:Saving illustrator file using applescript使用 applescript 保存 illustrator 文件
【发布时间】:2015-06-11 15:02:46
【问题描述】:

我目前正在尝试自动化一个过程,即我获取一个 .ai 文件,将其保存到桌面,然后将所有文本更改为轮廓,并将另一个副本保存到桌面,并在名称中添加 _OL,例如

IN> server/elements.ai
OUT> desktop/elements.ai & desktop/elements_OL.ai

感谢 Tim Joe,它现在可以保存,但它不会选择文本以将其转换为轮廓。

如果有人可以帮助我,我将不胜感激,我会在工作中一遍又一遍地执行相同的过程,让它自动化将是最好的。

这是我目前所得到的(已修改为包括保存选项、插画版本和文件路径作为字符串)

 set saveLocation to ((path to desktop) as string) --place to save the files
set theFile to choose file --choose .ai file to get outlines on
tell application "Finder" to set fileName to name of theFile
set fullPath to (saveLocation & fileName) --file path of new .ai
set olPath to fullPath & "_OL.ai" --file path of new .ai with outlines


tell application "Adobe Illustrator"
activate
open theFile without dialogs
save current document in file fullPath as Illustrator with options {class:Illustrator save options, compatibility:Illustrator 15, font subset threshold:0.0, embed linked files:true, save multiple artboards:false} --save file to desktop
selectobjectsonactiveartboard --select all
convert to paths --convert all text to outlines
display dialog "pause"
save current document in file olPath as Illustrator with options {class:Illustrator save options, compatibility:Illustrator 15, font subset threshold:0.0, embed linked files:true, save multiple artboards:false} --save another copy to desktop with name + _OL.ai 
quit
end tell

【问题讨论】:

  • 你编码的 Ai 版本是什么?
  • 这是 Adob​​e Illustrator CS5.1
  • 查看我的更新。使用别名时,更改它们时将它们设为字符串
  • 我在上面看到的唯一问题是 Illustrator 15 需要在兼容性之后:在 {} 内。你以前有过。保存行应如下所示:“将文件 olPath 中的当前文档保存为 Illustrator 选项 {class:Illustrator 保存选项,兼容性:Illustrator 15,字体子集阈值:0.0,嵌入链接文件:true,保存多个画板:false}”
  • 感谢您的帮助,它现在正在保存,不幸的是现在它正在保存我了解到它不喜欢“全选”命令-_-

标签: applescript adobe-illustrator


【解决方案1】:

查看底部的有效答案!

我总是使用保存选项,这可能是原因。

save theCurrentFile in file NewFileNamePath as as Illustrator ¬
                with options {class:Illustrator save options ¬
                , compatibility:Illustrator 15 ¬
                , font subset threshold:0.0 ¬
                , embed linked files:false ¬
                , save multiple art boards:false}

兼容性选项:Illustrator 10 / Illustrator 11 / Illustrator 12 / Illustrator 13 / Illustrator 14 / Illustrator 15 / Illustrator 3 / Illustrator 8 / Illustrator 9 / Japanese 3 -- 要创建的 Illustrator 文件格式版本(默认:Illustrator 15)

更新:工作保存

set saveLocation to ((path to desktop) as string) --You were missing as string so it was making an array. The array adds "," making an invalid save location.
set theFile to choose file --choose .ai file to get outlines on
tell application "Finder" to set fileName to name of theFile
set fullPath to saveLocation & fileName --file path of new .ai
--set olPath to fullPath & "_OL.ai" --file path of new .ai with outlines

log fullPath
tell application "Adobe Illustrator"
    activate
    open theFile without dialogs
    save current document in file fullPath as Illustrator with options {class:Illustrator save options, compatibility:Illustrator 15, font subset threshold:0.0, embed linked files:false, save multiple artboards:false}

end tell

简而言之,缺少的两件事:

  • 兼容性:Illustrator 15 -- 必须有版本号,你是 错过了
  • 将 saveLocation 设置为((桌面路径)作为字符串)- 需要 一个字符串

享受:)

更新使用这个:

    set saveLocation to ((path to desktop) as string) --place to save the files
set theFile to choose file --choose .ai file to get outlines on
tell application "Finder" to set fileName to name of theFile
tell application "Finder" to set fileNameExention to name extension of theFile
set trimNumber to (((count fileNameExention) + 2) * -1) -- add two to include period and placment
set fileName to (characters 1 thru -4 of fileName) as string -- get just the file name with not extention
set fullPath to (saveLocation & fileName) --file path of new .ai
set VectorPath to fullPath & ".ai"
set olPath to fullPath & "_OL.ai" --file path of new .ai with outlines

tell application id "com.adobe.Illustrator"
    activate
    open theFile without dialogs
    save current document in file VectorPath as Illustrator with options {class:Illustrator save options, compatibility:Illustrator 15, font subset threshold:0.0, embed linked files:true, save multiple artboards:false} --save file to desktop
    convert to paths (every text frame of current document)
    display dialog "pause"
    save current document in file olPath as Illustrator with options {class:Illustrator save options, compatibility:Illustrator 15, font subset threshold:0.0, embed linked files:true, save multiple artboards:false} --save another copy to desktop with name + _OL.ai 
    quit
end tell

完成!享受吧。

【讨论】:

  • 我试了一下,但现在我收到错误“无法将某些数据转换为预期类型”我不得不稍微更改您的代码以使其编译并将修改后的代码放入我的问题,我写错了吗?
  • 您需要一个兼容版本。 Illustrator 无效 Illustrator 15 有效。我看看有没有其他的
  • 我修复了路径,所以它是一个字符串,但是在我将数字 15 放在 illustrator 之后,我得到“枚举错误”。 15 也是 CS5 的意思吗?
  • Illustrator 15 是一个插画家术语,只能在插画家告诉块内定义。获得我能想到的枚举错误的唯一方法。您能否发布最新版本的脚本。我的最后一次更新是经过测试和工作的,但只做了第一次打开文件并保存一次的保存。
  • 这是adobe的后端代码。 17=CC 16=CS6 15=CS5/CS5.5 以此类推。因为你在 CS5.1 上,所以你想要 15。我正在更新你需要的东西。今天早上有一些空闲时间。
【解决方案2】:

您可以只获取 fullPath 但不包括扩展名,然后在其末尾添加 _OL.ai

set olPath to text 1 thru ((length of fullPath) - 3) of fullPath & "_OL.ai"

【讨论】:

  • 自从提出这个问题后,我已经弄清楚了那部分,但无论如何还是谢谢 :) 我想你可能也不知道为什么 illustrator 文件没有保存?