首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用applescript保存插画文件

使用applescript保存插画文件
EN

Stack Overflow用户
提问于 2014-05-01 09:53:25
回答 2查看 3.6K关注 0票数 2

我目前正在尝试自动化一个过程,通过这个过程,我获取一个.ai文件,将其保存到桌面上,然后将所有文本更改为大纲,并将另一个副本保存到桌面上,并将_OL添加到桌面上。

代码语言:javascript
运行
复制
IN> server/elements.ai
OUT> desktop/elements.ai & desktop/elements_OL.ai

感谢Tim,它现在保存了,但是它不会选择文本来将其转换为大纲。

如果有人能帮我做这件事,我会非常感激,我在工作中一遍又一遍地做同样的工作,让它自动化将是最好的。

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

代码语言:javascript
运行
复制
 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
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-05-08 18:13:48

工作答案见底部!

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

代码语言:javascript
运行
复制
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}

兼容性选项:插画师10 / Illustrator 11 / Illustrator 12 / Illustrator 13 / Illustrator 14 / Illustrator 15 / Illustrator 3/ Illustrator 8/ Illustrator 9/日文3-创建什么Illustrator文件格式版本(默认:插画15 )

更新:工作保存

代码语言:javascript
运行
复制
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

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

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

享受:)

更新使用如下:

代码语言:javascript
运行
复制
    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

完成了!好好享受吧。

票数 1
EN

Stack Overflow用户

发布于 2014-05-08 14:07:38

您可以只获得fullPath,但不包括扩展,然后将_OL.ai添加到该扩展的末尾:

代码语言:javascript
运行
复制
set olPath to text 1 thru ((length of fullPath) - 3) of fullPath & "_OL.ai"
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23405462

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档