More new stuff for 2.1

During the weekend I finally got around to upgrading to Aperture 2.1 as well as playing around with new Applescript support. I'm very surprised Apple has released 2.0.1 and 2.1 with additions to Aperture's Applescript but hey I'm certainly not complaining. Thanks Apple! I hope there is even more to come.

Oddly, Apple only mentions one aspect of the new additions to Aperture's Applescript in the release notes for 2.1. I'm not entirely sure why that is. Here's what Apple says is new as it pertains to 2.1 and Applescript: "Extended AppleScript support. The "Reveal" verb in the AppleScript dictionary has been extended to include containers such as projects and albums.". Well I see one more addition to the dictionary: Import/Export of projects.

Here's a few simple scripts to help get you started with the new features found in 2.1:

I noticed right away the reveal verb has been updated more than just revealing containers (projects, folders, and albums) after looking at the 2.1 dictionary. The 2.0.1 reveal entry is very basic and you could only reveal a single image version at a time. The 2.1 dictionary states you need to place whatever you want to reveal in a list which got me thinking....does that mean I can reveal more than one object at once? Well as it applies to images, the answer is YES! For some reason the same isn't true for the containers (I realize you can't select more than one container in the GUI, but then why make it a list?).

tell application "Aperture"
tell library 1
tell project 1
reveal {image version 1, image version 10, image version 2}
--reveal {project 1, project 2}
--doesn't work although the dictionary gives an impression of a multiple container selection

end tell
end tell
end tell

Revealing a container is similar to revealing an image version: reveal {project 1}.

Exporting a project:

tell application "Finder"
set export_dir to (choose folder with prompt "Choose a folder to export into") as alias
end tell


tell application "Aperture"

set x to name of every project
choose from list x with prompt "Select a project"
set ap_proj to item 1 of result
set ap_proj to project ap_proj

export {ap_proj} to export_dir with consolidating images

end tell

I got caught by a stupid syntax mistake when exploring exporting projects. If you accidently leave off "images" from that last line, the script will run and the editor will ignore "consolidating" which will be treated as a variable. There are times when the editor will catch cases where a variable is used but no value is assigned to it and produces the appropriate error message. For whatever reason, the editor doesn't catch this particular case and I was trying and trying to figure out why my referenced images where not being consolidated on export. BEWARE!

And importing a project:

tell application "Finder"
set import_dir to (choose file with prompt "Choose a project to import") as alias
end tell


tell application "Aperture"

set x to name of every project
choose from list x with prompt "Select a project"
set ap_proj to item 1 of result
set ap_proj to project ap_proj

import {import_dir} into folder "blue folder1"

end tell

What's really nice with the way they implemented the ability to import projects is you can import a project into a particular location within the hierarchy within Aperture. For example, I have a blue folder named "blue folder1". I want to import a project so that it resides within that folder without any manual assistance. With 2.1, that can now be accomplished.