Howdy,
I’d just like to say to start that I’ve just purchased DEVONthink pro after playing with it for about two weeks. I think it’s a spectacular piece of software: you guys have really done a great job.
I hate to make my first post on these forums a scripting question, but I’ve been hammering at this script for a couple hours and I’m a little stuck. I have never done any applescripting before, so I apologize if these questions are a bit on the common-sense side. What I am attempting to write is a script to generate a LaTeX file from a group in DT. I have it working in a rough way I would like it to for rtf/txt and groups, but I’ve hit a few small snags and I’m curious if anyone might have some suggestions.
My first problem is that I’m having some troulbe reliably detecting the type of a record. The following code:
set recordType to the type of theRecord as string
display alert "DEVONthink Pro" message recordType
The above seems to produce different results when run from the Script Editor than it does when run from within the scripts menu in DT pro. If it run it from the editor, I get results like “group” or “txt”, if I run it from the scripts menu I get a crazy pointer type like “<<constant ****DTgr>>” or “<<constant ****pict>>”. I’m guessing this is a context problem, so I assume I’m just doing something stupid here… does anyone happen to have a suggestion on how to reliably check the type of a record object? Should a create a new record object, set its type and use that as a baseline?
My second problem is in dealing with records of picture type. All I need is to get the path to the image stored in DT, and then write a \includegraphics{…} to my LaTeX file. At first, I thought the path property of the record might work, but it seems to me that would only work if the file was still at the location it was at when imported into the system. I tried using export to send the file to a temporary location and then clean it up after the script finishes, but DT doesn’t seem to like exporting picture files (am I wrong here? Nothing was happening, but the same code works for txt and rtf.) Is there some way I can use the location property to get at the data inside the database? Or should I write an export routine that creates a new file with the finder, and sets its content to data?
Anyway, I’m going to mull over this for a while, any suggestions or tips would be greatly appreciated
Thanks,
Ben