使用Appelscript和InDesign创建Pantone颜色表

时间:2018-10-05 10:20:38

标签: applescript adobe-indesign pantone

要检查在我自己的打印机上打印的Pantone颜色是否与Pantone的官方色板相同,我正在尝试创建具有所有Pantone颜色的色表。

到目前为止,这是我的applescript。它使用列表中的第一个Pantone颜色(包括下面的标签)创建带有六个矩形的第一行。 我在用其余的颜色矩形创建下一行时遇到了麻烦(Pantone颜色的列表更长)

tell application "Adobe InDesign CC 2017"
set pantone to {"PANTONE 159 C", "PANTONE Yellow C", "PANTONE Yellow 012 C", "PANTONE Orange 021 C", "PANTONE Warm Red C", "PANTONE Red 032 C", "PANTONE Rubine Red C", "PANTONE Rhodamine Red C", "PANTONE Purple C", "PANTONE Violet C", "PANTONE Blue 072 C", "PANTONE Reflex Blue C", "PANTONE Process Blue C", "PANTONE Green C", "PANTONE Black C", "PANTONE Yellow 0131 C", "PANTONE Red 0331 C", "PANTONE Magenta 0521 C", "PANTONE Violet 0631 C", "PANTONE Blue 0821 C", "PANTONE Green 0921 C", "PANTONE Black 0961 C", "PANTONE 801 C", "PANTONE 802 C", "PANTONE 803 C", "PANTONE 804 C", "PANTONE 805 C", "PANTONE 806 C", "PANTONE 807 C", "PANTONE 871 C", "PANTONE 872 C", "PANTONE 873 C", "PANTONE 874 C", "PANTONE 875 C", "PANTONE 876 C", "PANTONE 877 C", "PANTONE Medium Yellow C", "PANTONE Bright Orange C", "PANTONE Bright Red C", "PANTONE Strong Red C", "PANTONE Pink C", "PANTONE Medium Purple C", "PANTONE Dark Blue C", "PANTONE Medium Blue C", "PANTONE Bright Green C", "PANTONE Neutral Black C", "PANTONE 100 C"}

set myY1 to 3
set myX1 to {3, 10, 17, 24, 31, 38}
set myY2 to 6
set myX2 to {9, 16, 23, 30, 37, 44}

set x to 0

repeat 6 times
    tell page 1 of document 1
        set x to (x + 1)
        make new rectangle with properties {fill color:(item x of pantone), geometric bounds:{myY1, (item x of myX1), myY2, (item x of myX2)}}

        set textFrame1 to make text frame with properties {geometric bounds:{myY1 + 3.2, (item x of myX1), myY2 + 1, (item x of myX2)}, contents:(item x of pantone)}
        set theStory to parent story of contents of textFrame1
        set properties of theStory to {justification:center align, point size:8, applied font:"Arial"}
    end tell
end repeat

结束告诉

2 个答案:

答案 0 :(得分:0)

在InDesign中,矩形的坐标为左上角的X / Y和右下角的X / Y,其值基于“首选项”中的水平/垂直测量单位。 在您的脚本中,第一行的左上角为X(垂直)= 6.2和Y(水平)= 3,10,17,24,31,38,右下角为X = 9,2和Y = 9,16 ,23,30,37,44。

这意味着您的矩形高3个单位,宽6个。相反,我将使用变量_High = 3和_Wide = 6。

根据您的脚本,起始垂直位置为_StartVert = 6.2,起始水平位置为_StartHor = 3。

2个矩形之间的水平间隔是1(每7个和6个宽),我假设您还希望2行之间具有相同的垂直间隔。然后_SpaceCol和_SpaceRow设置为1。

最后但并非最不重要的是,每行矩形的数量在_RectPerRow = 6中设置。

使用MOD和DIV运算符,很容易确定任何矩形RefNum(RefNum从1到最大矩形数)的左上角位置。

下面的脚本计算每个矩形的位置:

set {_high, _Wide} to {3, 6} -- high, wide of each rectangle
set {_StartVer, _StartHor} to {6.2, 3} -- position of first rectangle top left
set {_SpaceRow, _SpaceCol} to {1, 1} -- space vertical/horizontal between 2 rectangles
set _RecPerRow to 6 -- 6 rectangles per row
set _MaxRect to 18 -- total number of rectangles to draw


repeat with RecNum from 1 to _MaxRect
    -- Calculates the position of top/left corner of each rectangle
    set X to _StartVer + ((RecNum - 1) div _RecPerRow) * (_SpaceRow + _high)
    set Y to _StartHor + ((RecNum - 1) mod _RecPerRow) * (_SpaceCol + _Wide)

    set myRectangle to {X, Y, X + _high, Y + _Wide} -- defines the complete rectangle

    log "RecNum=" & RecNum & "  x=" & X & "  Y=" & Y & "   x1=" & (X + _high) & "    y1=" & (Y + _Wide) 
end repeat

我离开日志行,以便您检查矩形的坐标是否正确。

在这种情况下,您将绘制18个矩形(_MaxRect),所以将绘制3行,每行6个(RecPerRow = 6)。

我让您使用这些矩形为“制作新矩形”和“制作文字框架”添加特定的InDesign指令。 当然,您的变量Pantone必须包含_MaxRect值(此处为18!)。

答案 1 :(得分:0)

在pbell的帮助下,我成功完成了脚本。由于所有的PANTONE颜色都有点长,但是可以用。感谢您的所有帮助。

EXEC SSISDB.catalog.start_execution @ex_id;