如何在indesign上将图像放置到选定的矩形

时间:2016-08-18 18:44:54

标签: applescript filemaker adobe-indesign

我创建了一个AppleScript来告诉另一个程序获取某个图像链接并将该特定图像放入一个新的矩形,该矩形也是通过applescript创建到打开的indesign文档上的。它很棒!现在我想采用相同的AppleScript而不是创建一个新的矩形对象,我希望它被放置在一个选定的矩形上。

这是我的剧本:

FileMaker Pro脚本步骤:

set upclink to cell "itemupc" of current record

InDesign AppleScript:

tell application "Adobe InDesign CS6"
    activate
    set itemlink to "Volumes:ImageByUPC:" & upclink & ".eps" --Creates ImageByUPC image link to place   
    set myDocument to active document --User's active document becomes document to place image  
    tell myDocument
        set noColor to swatch "None" --same as transparent          
        set myRectangle to make rectangle with properties {fill color:noColor, stroke color:noColor, geometric bounds:{0, 0, 3, 3}} --creates new rec at top of doc     
        place alias (itemlink) on myRectangle --InDesign's place function       
        fit myRectangle given proportionally --scales image
        fit myRectangle given center content --scales image     
    end tell
end tell

我知道我需要将myRectangle设置为当前矩形(不知何故)而不是新的矩形。但是不能让它正常工作。

谢谢!

1 个答案:

答案 0 :(得分:0)

使用活动文档的选择来引用所选矩形。试试这个:

tell application "Adobe InDesign CS6"
    activate
    set itemlink to "Volumes:ImageByUPC:" & upclink & ".eps" --Creates ImageByUPC image link to place   
    set myDocument to active document --User's active document becomes document to place image  
    tell myDocument
        set noColor to swatch "None" --same as transparent          
        set myRectangle to item 1 of selection of myDocument  -- reference selected rectangle
        place alias (itemlink) on myRectangle --InDesign's place function       
        fit myRectangle given proportionally --scales image
        fit myRectangle given center content --scales image     
    end tell
end tell