Illustrator- Set position of selection

I am the process of learning Applescript. In Adobe Illustrator 10, I get an error when I try to set the position of a selection. Using a translation matrix works, but that moves the object relative to it’s current position, I want to be able to move it to a specific position, relative to another object regardless of where the selected object may be. Below is a condenced version of the part I’m struggling with. When I ask the script to set the position, if I use the selections name (i.e group item 8 of document 1) instead of using the variable name it works fine. I am sure there is an obvious answer but I can not find it. Does anyone have any suggestions?

tell application “Adobe Illustrator 10”
activate
set artToMove to selection
set moveVariable to 300
set position of artToMove of document 1 to {(moveVariable), (300)}
end tell

This below is using a translation matrix, it works and does does not come up with an error message.

tell application “Adobe Illustrator 10”
activate
set artToMove to selection
set moveVariable to 300
set moveMatrix to get translation matrix delta x moveVariable
transform artToMove using moveMatrix
end tell[/u]

The selection is a list, so the list doesn’t understand the position property. Also, Illustrator doesn’t have a ‘selection’ AppleScript object in its dictionary, so there is no ‘position of selection’ to set. Instead, you have to find the position of your selection for yourself, find it’s offset from the position where you want to place it, then create a translation matrix for it and apply to every item of ‘selection’.

Finding the position of the selection isn’t easy, but it’s not tough either. You have to write some handlers to find the upper-left-most object and use its position.

If you need more help than that, I’ve got a bounds of selection handler, so if you still can’t get your script to work, I can post it.

Also be sure to download the Illustrator Scripting Guide from Adobe’s site. http://partners.adobe.com/asn/developer/scripting/main.html

Thanks for the info and explanation. I had actually ended up taking the approach that you suggest (find the location I want the art be, find it’s current location, use a translation matrix to move each item the difference) it works well, and does just what I want it to do.

It just seemed to me that “set position of selection” should work, partcularly if the selection is only one item. The ‘list’ thing still has me a little confused.