The Blog

From the “Wish we'd thought of this” file…

by Brian on February 6, 2009

One of the best aspects of doing the work that we do is getting to see the really cool stuff that customers do with the tools we make. One such nugget of awesome came to us last Friday, when we got an email with this AppleScript as an attachment:

faces-v3

[Update: If you downloaded an earlier version of the script and it didn't work, try the updated one above. It handles the '~' in the iPhoto library preference now, and it avoids a problem that folks using a document style with no line head specified would encounter.]

The script makes use of the new Faces feature of iPhoto '09. It looks for named faces in your library, then creates an OmniGraffle document showing which ones appear in photos together. At that point, it fires off OmniGraffle's automatic layout feature. I'll let the script's author, Armin Briegel, describe the results:

“It probably depends on your picture taking habits, but in my graph you can pick out families and groups of people, such as my son's classmates. The big mess in the middle is obviously our closest friends and families. But even there the families are in close proximity to each other.”

In any case, this gets our robot-stamp of approval, so we thought other folks might want to check it out, as well. Enjoy!

 

Comments

Not working for me - “unable to open ~/Pictures/iPhoto Library/face.db”: unable to open database file.  File is definitely there, iPhoto not running. Shame - am interested in this.

Ian

02.13.09 6:35 AM

Since sending this script to Omni I found that it breaks on some installations. To fix this in the script replace the first two lines after the “on run” handler with this:


set iPhotoLibPath to do shell script “defaults read com.apple.iPhoto RootDirectory”

—expand the '~' if it's in there

set faceDBPath to do shell script “echo ” & iPhotoLibPath

set faceDBPath to quoted form of (faceDBPath & “/face.db”)


to make it work on all iPhoto installations.

Armin Briegel

02.13.09 7:41 AM

Unfortunately the script doesn't work for me—looks like there's a problem expanding '~' in my iPhoto Library path when it's contained in quotes (as the script does), and hence sqlite gives an error about not being able to open the database.


Changing the script so that it replaces the tilde in the path with the full path to my home directory (e.g. defaults read com.apple.iPhoto RootDirectory | sed -e 's:~:'$HOME':g') will do the trick.

David Shepherdson

02.13.09 10:44 AM

I've updated the script above; though I did it before I noticed Armin's shorter fix, sadly =)

Tim

02.13.09 5:20 PM

All working for me now - thanks for the fix, nice thing to have.

Ian

02.13.09 6:31 PM

When trying to run the script, OmniGraffle ends up shutting down (without a crash notice, just it's gone) and I get an AS error saying it lost connection to OmniGraffle.

Kevin Ballard

02.13.09 9:49 PM

I tried v1 and v2 but after graphing two of my contacts, the script serves the following error: “Can’t set head type of graphic id 6 of canvas id 1 of document “Untitled 3” to head type of graphic id 6 of canvas id 1 of document “Untitled 3”.”


Any ideas?

Arnþór Snær

02.13.09 11:57 PM

Fantastic. Thanks.

Seth

02.14.09 12:33 AM

OmniGraffle Professional 5 got an error: Can’t set head type of graphic id 5 of canvas id 1 of document “Untitled” to head type of graphic id 5 of canvas id 1 of document “Untitled”.

Ken

02.14.09 2:13 AM

Any messages in /Applications/Utilities/Console.app?

Tim

02.14.09 3:25 AM

V2 fails for me on line 72: “set tail type of theline to head type of theline”. It looks like head type and tail type aren't really there. Commenting out that line makes the script work. This is in OmniGraffle Pro 5.1.1.

Stonewall Ballard

02.14.09 4:11 AM

Hi,


I just tried to use the script but get this error:


“„OmniGraffle Professional 5“ hat einen Fehler erhalten: „head type of graphic id 24 of canvas id 1 of document “Ohne Titel”“ kann nicht als „head type of graphic id 24 of canvas id 1 of document “Ohne Titel”“ gesetzt werden.”


Hopefully this can easily be fixed.

Thanks in advance

 

Patrick

02.15.09 6:20 AM

No messages appear in console.app.

Arnþór Snær

02.15.09 6:28 PM

It looks like the script gets unhappy if you've chosen a line style that doesn't have a head shape attached. If folks open a new “basic” diagram using the Template Chooser, the script will run just fine, though.


I'll poke at the script a bit.

Brian

02.15.09 7:58 PM

New version of the script uploaded; it now explicitly sets the line head and tail to the “FilledArrow” type.

Brian

02.15.09 8:14 PM

In my case it runs for a while and then I get “AppleScript Error: OmniGraffle Professional 5 got an error: AppleEvent handler failed.”.


On the console there are several messages:


2/17/09 12:57:56 PM [0x0-0x63063].com.omnigroup.OmniGrafflePro[5551] forwarding exception, port = 0x0, behaviour = 0, flavor = 0

2/17/09 12:57:56 PM [0x0-0x63063].com.omnigroup.OmniGrafflePro[5551] forward_exception got unknown behavior

2/17/09 12:57:56 PM com.apple.launchd[75] ([0x0-0x63063].com.omnigroup.OmniGrafflePro[5551]) Exited with exit code: 1

2/17/09 12:57:57 PM OmniGraffle Professional[6554] OSULastRunStartInterval default is non-nil; unless you forcibly killed the app and restarted it it should be nil at launch time.

2/17/09 12:57:58 PM OmniGraffle Professional[6554] *** -[OZZuul page]: unrecognized selector sent to instance 0x1320f530

2/17/09 12:57:58 PM OmniGraffle Professional[6554] An exception was thrown during execution of an NSScriptCommand…

2/17/09 12:57:58 PM OmniGraffle Professional[6554] An exception was thrown during execution of an NSScriptCommand…

2/17/09 12:57:58 PM OmniGraffle Professional[6554] *** -[OZZuul page]: unrecognized selector sent to instance 0x1320f530


I hope this helps.

Jorge

02.16.09 9:56 PM

[...] it takes what it’s found and spits out an OmniGraffle document showing which people appear in photos together. The result is this weird spidery [...]

An Omni Script To Bring Friends Together | Cult of

02.19.09 7:16 PM

I've got the same problem as Jorge:


2/20/09 4:27:30 PM OmniGraffle Professional[12326] *** -[OZZuul page]: unrecognized selector sent to instance 0x8f3f90

Aaron

02.20.09 10:24 AM

[...] of iPhoto from iLife ‘09 and a version of the OmniGraffle diagramming software, you can now run a script (submitted by a customer) that takes iPhoto’s Faces database and creates an OmniGraffle [...]

Bites from the Apple: Cracks in the Mini Facade &#

02.20.09 11:19 AM

[...] of iPhoto from iLife ‘09 and a version of the OmniGraffle diagramming software, you can now run a script (submitted by a customer) that takes iPhoto’s Faces database and creates an OmniGraffle [...]

Bites from the Apple: Cracks in the Mini Facade |

02.20.09 11:23 PM
Commenting is not available in this channel entry.