Applescript Illustrator缩放艺术到返回对话框
此脚本的第一部分查找艺术尺寸,并返回以英寸为单位的尺寸- 我希望这个问题,然后问什么大小,使宽度,然后输入数字,并让Illustrator规模的艺术宽度在返回的对话框。 我想弄清楚这算什么。 起初,比例比例似乎是正确的,但需要扩大比例 百分比必须超过100%(即125%或150%等) 我无法使用if之间的else来编译脚本,因此我确信我在这里遗漏了一些东西Applescript Illustrator缩放艺术到返回对话框,applescript,Applescript,此脚本的第一部分查找艺术尺寸,并返回以英寸为单位的尺寸- 我希望这个问题,然后问什么大小,使宽度,然后输入数字,并让Illustrator规模的艺术宽度在返回的对话框。 我想弄清楚这算什么。 起初,比例比例似乎是正确的,但需要扩大比例 百分比必须超过100%(即125%或150%等) 我无法使用if之间的else来编译脚本,因此我确信我在这里遗漏了一些东西 tell application "Adobe Illustrator" activate tell document 1 --de
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 newWidth to text returned of (display dialog "Please enter Art Width:" default answer "100")
tell application "Adobe Illustrator"
set artWidth to width of tempGroup
set sizeDifference to (newWidth / artWidth) * 100
try
if newWidth is equal to artWidth then
set scalePercentage to 100
end if
if newWidth is greater than artWidth then
set scalePercentage to (100 + sizeDifference)
end if
if newWidth is less than artWidth then
set scalePercentage to (100 - sizeDifference)
end if
end tell
end
我感谢你的建议。我意识到javascript可能是Illustrator的最佳选择
但是,我试图通过理解一些applescripts来了解我的方法,然后再进入更高级的领域。提前谢谢。我在玩数学游戏后找到了答案。 问题是Illustrator不处理英寸,只处理点 因此(w/72)(h/72)部分在获得尺寸时。 72点=1英寸,因此数学必须将点转换为英寸。 像这样
tell application "Adobe Illustrator"
activate
tell document 1
--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)
--resize
set newWidth to text returned of (display dialog "Please enter Art Width:" default answer "10")
set artWidth to width of tempGroup
set sum to (artWidth / newWidth * 100)
set scalePercentage to (72 / sum * 10000)
scale tempGroup horizontal scale scalePercentage vertical scale scalePercentage
end tell
end tell
end