Re: Scripting Bridge usage, iPhoto example
Re: Scripting Bridge usage, iPhoto example
- Subject: Re: Scripting Bridge usage, iPhoto example
- From: "Jeffrey J. Early" <email@hidden>
- Date: Thu, 13 May 2010 15:39:54 -0400
On May 13, 2010, at 2:45 PM, has wrote:
> Jeffrey J. Early wrote:
>
>> I'm having some difficulties mapping commands from from an AppleScript script to ScriptingBridge and was hoping someone might be able to point me in the right direction.
>>
>> As a reduced example/test case, I have the following script to set the rating and assign a keyword to the selected photo in iPhoto,
>>
>> tell application "iPhoto"
>> set selectedPhotos to the selection
>> repeat with thisPhoto in selectedPhotos
>> set rating of thisPhoto to 2
>> assign keyword string "Vacation"
>> end repeat
>> end tell
>>
>> As long as "Vacation" is an existing keyword, this script works just fine. Trying (what I think should be) the equivalent ScriptingBridge,
>>
>> iPhotoApplication *iPhoto = [SBApplication applicationWithBundleIdentifier:@"com.apple.iPhoto"];
>> for (iPhotoPhoto *photo in [iPhoto selection]) {
>> [photo setRating: 3];
>> [photo assignKeywordString: @"Vacation"];
>> }
>
> These are not equivalent. To match your AppleScript, your last line should read [1]:
>
> [iPhoto assignKeywordString: @"Vacation"];
[snip]
>
> [1] Also, since 'assign keyword' acts on the current selection, there's no need for it to be inside the loop (which is a bit misleading to the casual reader).
That's very helpful, thank you. I'm puzzled now why this fails,
tell application "iPhoto"
set myPhoto to the last item of (every photo whose name is "__iPhotoTest")
tell myPhoto
assign keyword string "Vacation"
end tell
end tell
but this does not,
tell application "iPhoto"
set myPhoto to the last item of (every photo whose name is "__iPhotoTest")
tell myPhoto
reverse geocode
end tell
end tell
??? I don't see any distinction in the iPhoto dictionary that would suggest one would work and other wouldn't. I guess the whole thing is a little bizarre to me -- I can't really determine which objects respond to which actions just by looking at the Applescript dictionary.
I'm wanting to use the action "assign keyword" on a photo, but maybe that's just not possible? I'm forced to actually select a photo first, then tell the *application* to "assign keyword"?
I appreciate the help,
Jeffrey
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden