I’m trying to select objects based on properties. It’s easy to loop through the entire list of objects and make decisions based on true/false, but I’d like to do it more elegantly.
tell application "Adobe Illustrator"
position of selection contains {3.859375}
end tell
that will return a true/false.
However, I can’t make additional selections based on this. The following code, and various permutations, do not work:
tell application "Adobe Illustrator"
set selection to (every text frame of document 1 whose properties contains {position:3.859375})
end tell
I know you mention elegant, i don’t think this really comes under that mantel its more of a work round
which is probably not what you want.
Its not that easy as you say to single out an item within a list and make a selection from it, getting the selection using the whole property was a bit easier but this so far is the only way i could do it.
Blank document with 1 single rectangle (selected) in it.
tell application "Adobe Illustrator"
set t to position of selection
set m to item 1 of t
set name of selection to m
set selection to {}
delay 2
tell document 1
set selection to (every page item whose name is m)
end tell
end tell
I played around with this yesterday to see if I could find a solution. The problem with your set selection line is that position requires a list of two positions {3.0,4,0} and if you change it to that then it will select correctly, but I imagine that you want every text box with an x at 3.0 in the position with any y coordinate, and since there is not a wild card you can’t do it that way.
I tried reworking the wording as well to something like this:
set selection to every text frame whose item 1 of position is 3.0
But this didn’t work either.
You may be stuck with getting the position of the items and parsing the list in Applescript.
You’re right, Jerome- I want to use one coordinate as a wildcard. Basically we’re getting bar charts generated by MPI Stylus, exported as EMF files, which are then ‘restyled’ in Illustrator. I’m repositioning the X-axis labels, which naturally have the same Y-coordinate, but MPI does not label them. If I were able to select elements based on one of their coordinates I could eliminate a lot of looping through elements.