how to change iphoto selection

I wanted to iterate through selection in iPhoto and do some changes to them. But I wanted to see which photo i’m currently applying the changes to so I wanted to change current selection to current photo i’m working on and then switch view to edit so that it will be shown in the screen.

I wrote following script:
tell application “iPhoto”
set myPhotos to selection
repeat with p from 1 to count of myPhotos
set currPhoto to item p of myPhotos
set selection to {currPhoto}
set view to edit
doSomething()
end repeat
end tell

the line “set selection to {currPhoto}” fails. I get following error “iPhoto got an error: AppleEvent handler failed.”
I also tried doing “set selection to myPhotos” and i got same error message
why isn’t this working?

Hi,

iPhoto is one of the few Apple applications (or is it even the only one?), whose selection can be set with a specified select command


tell application "iPhoto"
	set myPhotos to selection
	repeat with currPhoto in myPhotos
		select currPhoto
		set view to edit
		doSomething()
	end repeat
end tell

Thanks! that worked