Illustrator CS5 + put one object behind another

How can I move one object behind another? The attached script used to work, but now it evidently no longer does. Any ideas? I am stumped.

TIA


tell application "Adobe Ilustrator"
set thisDoc to current document
	tell thisDoc
					tell layer "At Scale"
						move page item "DCS_Display_Copy" to after page item "DCS"
					end tell
				end tell
end tell

Hi. Illustrator’s objects are positioned based on index; the frontmost item always being the first. This should move an item to above the third position, which would be behind the first.


tell application "Illustrator CS"'s document 1	
	move page item 1 to page item 3
end tell

error message:

“can’t get page item 1”

why did you break J. Lo’s heart? :stuck_out_tongue:

Works fine for me!

ah…I mis-copied the code…oopsy

so there is still no way to grab these things by name and manipulate them? What I really need is to put a piece of artwork behind another specifically named piece, without having to get the index of every piece of artwork on the layer…

Hello, again. If you specifically set the name property of these objects in advance, then a name can be used instead of an index, however, there is no facility for identifying these “labels””as in InDesign”and you’ll have to verify them manually. If the names are correct, your initial code should work; parentheses might help, if not.

tell application "Illustrator CS"'s document 1
	  tell layer "At Scale" to move (page item "DCS_Display_Copy") to after (page item "DCS")
end tell

aha!

the problem was this:

I had set the NOTE of the objects I wanted to move in the Attributes panel, but I had not set the NAME of the objects in the Layers panel. That’s why it worked before and didn’t work now…I must have changed previous function from “set name of selection to” into “set note of selection to”

Excellent. Thanks, you have been very helpful!

Cheers
:slight_smile: