Aperture 3 - path to referenced master image file

Hello,

I have written a couple of scripts that need a path to an image file in Aperture. They work fine with managed images, but not with referenced images.

Can anyone supply a code sample to get the path to a referenced master image file in Aperture 3?

I have seen some code samples that use a SQL database query, but I think Apple changed the database schema in Aperture 3. If someone can share the data model, I might be able to write a query to get the path

I am using the file information to call EXIFtool in a shell script. The code below works for managed images, but not for referenced images. I put in the choose file dialog as a workaround.


on getPath(aItem)
tell application "Aperture"
tell library 1
tell aItem
set MasterFile to (get value of other tag "FileName")
set isReferenced to get referenced
if isReferenced then
set FinderPath to choose file MasterFile with prompt "Please locate referenced file"
set thePath to POSIX path of FinderPath
else
set ImpGroup to (get value of other tag "ImportGroup")
set MasterPath to my GetMasterPath(ImpGroup)
set MasterPath to my getLibPath() & MasterPath
set thePath to quoted form of (MasterPath & MasterFile)
end if
end tell
end tell
end tell
return thePath
end getPath

The full scripts are located here:
http://bergersoft.com/personal/AppleScript/

Thanks in advance.