0

I created an applescript to tell another program to take a certain image link and place that particular image into a new rectangle that was also created through the applescript onto an opened indesign document. It works great! Now I want to take that same applescript and instead of creating a new rectangle object, i want it to be placed on a selected rectangle instead.

Here is my script:

FileMaker Pro Script Step:

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

I know I need to set myRectangle to the current rectangle (somehow) instead of a new rectangle being made. But can't get it to properly work.

Thanks!

Nicolai Kant
  • 1,391
  • 1
  • 9
  • 23
Mike Volpe
  • 23
  • 5

1 Answers1

0

Use selection of the active document to reference selected rectangle. Try this:

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
Nicolai Kant
  • 1,391
  • 1
  • 9
  • 23