此脚本的第一部分找到艺术品尺寸,并以英寸为单位返回尺寸 - 我想要这个然后询问宽度然后输入数字的大小,并让Illustrator将艺术缩放到返回的对话框中的宽度。 我试图弄清楚计算在哪里。 起初看来,比例百分比是正确的,但要放大 百分比必须超过100%(即125%或150%等) 我无法通过我的if之间的其他内容编译脚本,所以我确定我在这里遗漏了一些东西。
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一起使用的方式 但在尝试更先进的东西之前,我试图通过了解一些苹果脚本。提前谢谢。
答案 0 :(得分:0)
在玩完数学后我找到了答案。 问题是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