The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniOutliner 4 for Mac (http://forums.omnigroup.com/forumdisplay.php?f=72)
-   -   Any new applescript features? (http://forums.omnigroup.com/showthread.php?t=31158)

stephenll 2014-01-09 11:16 AM

Any new applescript features?
 
Hello,

I would love to be able to replace my latex workflow with omnioutliner. I have outlines in latex littered with equations.

While I could use latexit and link back to do this manually, I found that the zoom feature in 4.0 does not resize images that are in the outlines.

I would like the ability to loop over all cells in the outline and take the latex code out of the notes field and insert the image of the equation into the parent cell. This way I can run it and automatically change the font size of the equations when I want to zoom in.

I think the only piece that is missing is the ability to take image attachments on the hard drive into a outliner document via applescript.

Can applescript do this in omnioutliner 4.0?

Thanks.

Stephen

Carlos 2014-01-22 10:48 PM

Hi Stephen,
I would be also very interested in a nice way to bring back latex equations into OO4!
Previously this was possible with some script called oo3eq, which was broken at some point. There has been a thread with no real solution ([url]http://forums.omnigroup.com/showthread.php?t=29192&highlight=latex[/url]).

DerekM 2014-01-23 02:46 PM

Sorry, there is not yet support for attachments in OO4's AppleScript.

stephenll 2014-01-28 08:46 AM

Right now my current solution is using the outlines package in LaTeX with some fancy scripting in the sublime text editor to manipulate my outlines similar to the way you can promote demote and reorder the outlines in omnioutliner.

I really want a way to better use equations in omnioutliner. I find latexit very fragile. It hangs all too often to be reliable. I have to take notes on thousands of pages with math in them and my career depends on me studying/using these notes.

I think my ideal workflow would be to put the text representation of the equation in the notes section for a particular cell, then loop over all cells, see if there is an equation in the notes, render it as a picture, then place it in the cell. This way I can always be sure to have the equation as text if anything goes wrong.

I haven't given up yet and I will be sure to post anything I come up with.

Ken Case 2014-01-28 03:07 PM

[QUOTE=stephenll;128916]I think the only piece that is missing is the ability to take image attachments on the hard drive into a outliner document via applescript.

Can applescript do this in omnioutliner 4.0?[/QUOTE]

You bet! Try something like this:

[CODE]-- Set this path to whatever you like
set MyPath to "/Applications/OmniOutliner.app/Contents/Resources/HelpImages/oo4mac_aboutbox.png"

tell application id "com.omnigroup.OmniOutliner4"
set MyDoc to (make new document with properties {writes wrapper:false})
make new row at end of rows of MyDoc
set MyRow to row 1 of MyDoc
set MyCell to cell 2 of MyRow

tell text of MyCell
make new file attachment with properties {file name:POSIX file MyPath, embedded:true} at before character 1
end tell
end tell[/CODE]

We've posted a new support article describing the [URL="http://www.omnigroup.com/support/omnioutliner-4-applescript-changes"]AppleScript Changes in OmniOutliner 4[/URL].

Carlos 2014-02-02 12:01 PM

processing latex from content of note
 
Hi Ken,

thanks for sharing that code! It is wonderful for pasting the attachment!

I am trying follow the previous ideas and am parsing the content of a note and pass that content as command line argument to a python script (create_latex_pdf.py). This seems to work. The goal of the python script is to generate a pdf file which can then be used as an attachment in the cell of the selected row.

[B]Part 1[/B]: Applescript

[CODE]set lstNote to {}
tell application id "OOut" to set lstNote to note of selected rows of front document
set strNote to lstNote as text

tell application "Finder" to get folder of (path to me) as Unicode text
set presentDir to POSIX path of result

set py to "create_latex_pdf.py"
set calldir to "python " & quoted form of presentDir & py & " " & strNote
do shell script calldir[/CODE]

When I do this, I get no error, a temp.ps file is created, but it has 0 bytes.

[B]Part 2[/B]: Python script

See the python code below. When I run it from the terminal, it works and generates a pdf file as it should. [I]However, when called from applescript I can't see what it is doing or where / why it stops. I'd appreciate pointers.[/I]

[CODE]str_latex_note = sys.argv[1]
preamble = """\documentclass{article}
\usepackage{amsmath,amssymb}
\pagestyle{empty}
\\begin{document}
{\huge
\[
%s
\]
}
\end{document}"""% (str_latex_note)

cur_path = r'/Users/myfolder/Library/Scripts/OO_latex'
cur_file = "temp.tex"
fobj = open(os.path.join(cur_path, cur_file), 'w')
fobj.writelines(preamble)
os.chdir(cur_path)
cmd = 'latex temp.tex'
print cmd
os.system(cmd)

cmd2 = 'dvips -E -f -X 1200 -Y 1200 temp.dvi > temp.ps'
os.system(cmd2)

cmd3 = 'epstopdf temp.ps'
os.system(cmd3)[/CODE]

stephenll 2014-02-06 03:54 PM

I am learning applescript for the first time, so I am going slow.

I did pick up on what I think one problem:

I think you need to close the file after writing to it.

Carlos 2014-02-12 01:20 AM

latex equations in omni outliner
 
I hacked a version together, that works for me.

It involves an applescript and a python script.

Feel free to check it out [URL="https://github.com/clausTue/OO_latex"]here[/URL]

I'd be happy about feedback -- and thanks for the help on this forum!


One thing: is there a more omni-like-way of calling scripts in omnioutliner (and not via quicksilver)? -- I remember that there used to be a toolbar icon for applescripts, but I can't seem to find this option anymore.

Ken Case 2014-02-12 05:28 AM

[QUOTE=Carlos;129549]I hacked a version together, that works for me.[/QUOTE]

Wonderful! Congrats!

[QUOTE]One thing: is there a more omni-like-way of calling scripts in omnioutliner (and not via quicksilver)? -- I remember that there used to be a toolbar icon for applescripts, but I can't seem to find this option anymore.[/QUOTE]

We used to search several places, but sandboxing rules now limit us to a specific blessed folder which is based on our app id. (OmniOutliner isn't allowed to write from this folder, only to scan it and run scripts from it.)

If you're using a copy of OmniOutliner from our store, that blessed folder is:
[INDENT]~/Library/Application Scripts/com.omnigroup.OmniOutliner4[/INDENT]
For the Mac App Store editions, try one of these paths (based on whether you purchased Pro using the in-app purchase or as your initial purchase):
[INDENT]~/Library/Application Scripts/com.omnigroup.OmniOutliner.MacAppStore
~/Library/Application Scripts/com.omnigroup.OmniOutlinerPro.MacAppStore[/INDENT]
For a future update, I'd like to add a menu item somewhere that will automatically open this script folder in the Finder for you, so you don't have to find it yourself. (Sandboxing rules do allow apps to do that much.)

stephenll 2014-02-13 08:35 AM

This works really well. I need to figure out how to convert to a format where the attachment will be in a compatible format to the iPad app. I don't think omnioutliner for iPad will render pdfs that are attached in line.


All times are GMT -8. The time now is 07:07 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.