【发布时间】:2014-05-09 05:42:31
【问题描述】:
我正在编写一个脚本以消除重复。到目前为止,我将在 Illustrator 中获得艺术作品的当前尺寸并以英寸为单位显示尺寸,但我无法弄清楚如何根据返回对话框。我试图让它与返回的宽度测量成比例地缩放艺术。然后它将根据艺术的新尺寸调整画板的大小(这部分有效)。这是我目前所拥有的
tell application "Adobe Illustrator"
activate
tell document 1
--define Spot1
set docColorSpace to color space
if (docColorSpace is CMYK) then
set SpotColor1 to {cyan:21.0, magenta:0, yellow:100.0, black:0.0}
else
set SpotColor1 to {red:206.0, green:219.0, blue:41.0}
end if
--color change first
set (path items whose fill color is not SpotColor1)'s fill color to SpotColor1
--get current size
set tempGroup to make new group item with properties {name:"TempGroup"} -- Create a temporary container group
duplicate every page item to beginning of group item "TempGroup" -- copy instances to it
set {w, h} to {width, height} of tempGroup -- get properties
delete tempGroup
display dialog "Width of Art: " & (w / 72) & return & "Height of Art: " & (h / 72)
--change to desired size PROBLEM SECTION
set ArtWidth to text returned of (display dialog "Please enter Art Width:" default answer "10")
try
if (w / 72) is greater than ArtWidth then
set sizeDifference to (ArtWidth - (w / 72)) as integer
else
if (w / 72) is less than ArtWidth then
set sizeDifference to ((w / 72) - ArtWidth) as integer
end if
end if
set has selected artwork of (every layer of document 1) to true
set everyPageItem to artItem
set x1orig to item 1 of activeArt
set y1orig to item 2 of activeArt
set x2orig to item 3 of activeArt
set y2orig to item 4 of activeArt
--not sure if activeArt
--determine new page size (add inch in each direction)
set x1new to (x1orig - sizeDifference) as real
set y1new to (y1orig + sizeDifference) as real
set x2new to (x2orig + sizeDifference) as real
set y2new to (y2orig - sizeDifference) as real
--set new art size
set artItem to {x1new, y1new, x2new, y2new}
--fit artboard to art
set tempGroup to make new group item with properties {name:"TempGroup"} -- Create a temporary container group
duplicate every page item to beginning of group item "TempGroup" -- copy instances to it
set {w, h} to {width, height} of tempGroup -- get properties
set theBounds to visible bounds of tempGroup
set artboard rectangle of first artboard to theBounds
delete tempGroup
-- one inch border
tell artboard 1
--get original page size
set artPage to artboard rectangle
set x1orig to item 1 of artPage
set y1orig to item 2 of artPage
set x2orig to item 3 of artPage
set y2orig to item 4 of artPage
--determine new page size (add inch in each direction)
set x1new to (x1orig - 72) as real
set y1new to (y1orig + 72) as real
set x2new to (x2orig + 72) as real
set y2new to (y2orig - 72) as real
--set new page size
set artboard rectangle to {x1new, y1new, x2new, y2new}
--print to rip, set path to folder
--hop out to finder, close & file folders where they go
end tell
end try
end tell
end tell
end
我觉得我忽略了一种更简单的方法 - 任何建议表示赞赏
【问题讨论】:
-
我已将此问题返回到编辑前的第一个版本,因为您已将我的答案应用于该问题。这使得答案不再真正回答问题。如果您仍然遇到同样的问题,请使用更多详细信息编辑问题。如果您对新代码有不同的问题,请提出一个新问题。
-
我的错误 - 对不起。我标记了已回答的问题。感谢您的帮助
-
您在此处提交的脚本确实对艺术进行了缩放,由我来找出计算差异并将其转换为缩放百分比的正确方法(现在它对艺术的缩放非常小)跨度>
标签: applescript adobe-illustrator