This Week's Sponsor:

Listen Later

Listen to Articles as Podcasts


Visualize OmniFocus As iThoughts Map, OPML, Or Plain Text

iThoughts for OmniFocus

iThoughts for OmniFocus

A few weeks ago, Michael Schechter found a way to export an OmniFocus for Mac database to OPML to visualize it in mind-mapping apps like iThoughts and MindNode. In the post, he wrote that, however, he was reaching to the Mac community to see if anyone would be able to build a more powerful and reliable solution with filters, color options, and more control on the exported data. RobTrew picked up the task and, on the OmniGroup Forums, released an initial script to export from OmniFocus to OPML.

Then, yesterday, Rob released a new version of the script which adds native iThoughts support and plain text exporting options, as well as settings for colors, templates, and filters.

I tested Rob’s script with my OmniFocus database, and after several improvements he made to the script, I feel comfortable enough with linking to it here. Unlike other solutions, Rob’s script looks directly into the SQL OmniFocus database cache to get its data – quite a feat on its own. But there’s so much more the script can do if you start customizing it.

General instructions are available in the official thread at the OmniGroup forums. To sum up, the script is available in two versions: an AppleScript and a Python script. The Python version can be used to run the script from the shell or automatically using, say, Hazel; the AppleScript requires manual interaction as it’ll ask you to specify a filetype for exported documents and a location in the Finder. The AppleScript is useful if you want to run the script every once in a while; the shell version is recommended if you want to run everything without having to click on dialog boxes.

In his script, Rob focused on native iThoughts export. iThoughtsHD is, in my opinion, the best mind-mapping app available on the iPad, which, by fiddling around with the settings, can also become a powerful text-based outliner. And this is exactly why I wanted to try Rob’s script: I was looking for a way to visualize my entire OmniFocus database as a horizontal outline. Something like Tree, but on the iPad. And as I discovered, iThoughtsHD had the settings to do just that.

iThoughts has options to apply default colors and shapes to new documents, but these won’t carry over to documents you’re opening from somewhere else, like your Dropbox account. Rob found a way to import color and shape settings from an .itm or .itmz file previously created in iThoughts. In this way, you can just create a template of what your OmniFocus map should look like, set colors and styles for shapes and canvas, and use the file as a template. The OmniFocus map will pick up the style every time, so you won’t have to manually adjust anything else. As a tip, I suggest you create a small template file with just a few top-level branches, otherwise the exporting process will slow down.

Once you download the script, you’ll find four templates and a .scptd file in the compressed archive. If you want to run the “normal” AppleScript, just open the .scptd file with AppleScript Editor, and hit Run. Follow the on-screen dialog boxes to filter data, choose a format, a location, and export. You’ll end up with an .itmz, .itm, OPML, or plain text file with the contents of your current OmniFocus database.

If you want to run the AppleScript with a template for your iThoughts map, place both the script and the template in the same location, and put the filename of the template between quotes in property pstrTemplate. Rob’s script inherits colors and shapes of root and level 1 branches of any .itm or .itmz template; if your template also sets the inherited shapes option, level 2 (and onwards) branches will inherit level 1 settings. This is useful to make sure your entire map looks the same.

As you can imagine, however, I prefer the Python version of the script, as I can run it in the background, automatically, every time my OmniFocus database changes. I can always have the latest “map version” of my OmniFocus database, and I can even keep it in sync with iThoughtsHD so I don’t have to manually download or upload anything.

To do so, I built a Hazel rule that watches the OmniFocus database for changes. The database should be located in Users/username/Library/Caches/com.omnigroup.OmniFocus/OmniFocusDatabase2, and to pick up any change via Hazel you can use the trusted “Date Last Modified is after Date Last Matched” method. Every time you make a change to OmniFocus and sync, the database will be updated.

On my Mac mini, I set Hazel to run three scripts whenever my database changes; these scripts create three different versions of my OmniFocus database – iThoughts, OPML, and plain text. The scripts are all based on the shell command posted by Rob, which includes “switches” for setting options manually. Everything is well documented on the forums, or by typing --help when viewing the Python script in Terminal.

So here’s what I did. I got the Python script from the Resources inside the .scptd bundle. I moved the .py file to my Home directory alongside the map.itm template I’m using. In Hazel, I set up a “Run shell script” action that does the following:

python $HOME/ofoc_to_mindmap_018.py --format=itmz --output=$HOME/Dropbox/Maps/ActiveTasks -m map.itm -c '0'

Pretty straightforward: --format sets the format of the exported file (more on this in a bit), --output sets the location of the file, -m calls the template, and -c controls the branches that will be collapsed by default in iThoughts. By setting it to 0, I get my OmniFocus map fully laid out as soon as I open it.

To export to OPML or plain text, simply remove the template (since you won’t need it), change the format, and choose a different filename if you wish. The same Python script will handle exporting in multiple formats.

iOS 6 share menu

iOS 6 share menu

By exporting OmniFocus’ database to plain text, other iOS apps can open the file.

OmniOutliner

OmniOutliner

OmniOutliner for iPad correctly opens both OPML and tab-delimited plain text.

In iThoughtsHD, you can download & sync maps using the “Copy From Cloud” menu. In here – assuming you’re saving your map to Dropbox – you’ll be able to find a map and choose the “Download and Sync” option. I found out that, because .itmz is the native format of iThoughts, you’ll be able to get download & sync working only if your map is already in .itmz format. If it is, changes to the map will be seen by iThoughts, which will notify you of new versions available in Dropbox.

As usual with scripts by RobTrew, you can customize a lot of parameters and fine-tune several aspects of the script to your tastes and needs. Personally, I have found this to be a great addition to my workflow as it allows me to lean back and have a different overview of everything that’s going on in OmniFocus. I can enjoy a bird’s eye view of projects and tasks (as well as due dates) at a single glance – a feature that the OmniFocus apps don’t have.

Obviously, you should consider the script a “beta” that you’re running at your own risk; a backup of your OmniFocus database is recommended, but judging from my tests, I can say it has been bug-free and stable.

You can download the script here.

Unlock More with Club MacStories

Founded in 2015, Club MacStories has delivered exclusive content every week for over six years.

In that time, members have enjoyed nearly 400 weekly and monthly newsletters packed with more of your favorite MacStories writing as well as Club-only podcasts, eBooks, discounts on apps, icons, and services. Join today, and you’ll get everything new that we publish every week, plus access to our entire archive of back issues and downloadable perks.

The Club expanded in 2021 with Club MacStories+ and Club Premier. Club MacStories+ members enjoy even more exclusive stories, a vibrant Discord community, a rotating roster of app discounts, and more. And, with Club Premier, you get everything we offer at every Club level plus an extended, ad-free version of our podcast AppStories that is delivered early each week in high-bitrate audio.

Choose the Club plan that’s right for you:

  • Club MacStories: Weekly and monthly newsletters via email and the web that are brimming with app collections, tips, automation workflows, longform writing, a Club-only podcast, periodic giveaways, and more;
  • Club MacStories+: Everything that Club MacStories offers, plus exclusive content like Federico’s Automation Academy and John’s Macintosh Desktop Experience, a powerful web app for searching and exploring over 6 years of content and creating custom RSS feeds of Club content, an active Discord community, and a rotating collection of discounts, and more;
  • Club Premier: Everything in from our other plans and AppStories+, an extended version of our flagship podcast that’s delivered early, ad-free, and in high-bitrate audio.