The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniOutliner 3 for Mac (http://forums.omnigroup.com/forumdisplay.php?f=9)
-   -   Merge Children to notes field (http://forums.omnigroup.com/showthread.php?t=26709)

viellieb 2012-10-31 06:55 AM

Merge Children to notes field
 
Hy Friends,

I'm struggling with AppleScript and OmniOutliner.
I'd like to export my Outline as .opml for Scrivener ([url]http://www.literatureandlatte.com/scrivener.php[/url]).

Unfortunately in Scrivener only the Text in notes-field comes in as Text, all the children are imported as sub-topics.

Long story short:
I need an applescript that moves all of the children of the selected row into it's notes field.

So that:
- Topic
- 1
- 2
- 3

becomes

- Topic
1
2
3
with the lines 1,2 and the 3 in the notes field. Preferably without the dashes :-)

This applescript here ([url]http://muninn.net/blog/2010/03/omnioutliner-applescript-to-append-a-note-to-selected-rows.html[/url]) can copy the clipboard to the notes.

I also found a Applescript for merging children:
[url]http://forums.omnigroup.com/showthread.php?t=6750&highlight=merge[/url]

Can anyone pleas help me with this applescript idea? :-)

whpalmer4 2012-10-31 07:23 AM

What happens if the children have notes, or children of their own?

RobTrew 2012-10-31 09:02 AM

OO3 → Markdown → Scrivener > File > Import MultiMarkdown

may prove to be a shorter route than:

OO3 → Applescript → OPML → Scrivener > File > Open OPML

One route to the Markdown would be the MMD exporter for OO3

([url]http://forums.omnigroup.com/showthread.php?t=7625[/url])

[url]http://fletcherpenney.net/2011/10/omnioutliner_plugin[/url]

([URL="http://forums.omnigroup.com/showthread.php?t=26704"]FoldingText outlines[/URL] will also import directly through the MMD importer, but you may not want the tab indentations).

[COLOR="White"]--[/COLOR]

viellieb 2012-11-02 04:25 AM

[QUOTE=whpalmer4;116825]What happens if the children have notes, or children of their own?[/QUOTE]

Excellent question.
Now that I thought about it: merging everything to normal paragraphs - without indent - would be perfect for my needs.

viellieb 2012-11-02 04:29 AM

[QUOTE=RobTrew;116829]OO3 → Markdown → Scrivener > File > Import MultiMarkdown
[COLOR="White"]--[/COLOR][/QUOTE]

Thanks. Got the Markdown export working.
Unfortunately I get the same result as with OPML.

Which seems logical, because Scrivener can't know at which hierachy I want the outline to stop and the "normal Text" to start.
Hope this makes sense to you too :D

RobTrew 2012-11-02 02:52 PM

1 Attachment(s)
I wonder if this script helps.

(Saves the front OO3 document as flattened text).

You can adjust the value of the first few properties at the top of the script to tune things a little:

[CODE]-- UNIT OF INDENT -- empty string in lieu of tab
property pstrIndentUnit : ""
property pstrDefaultPrefix : "- "

-- EXPORT ONLY THE SELECTED OMNIOUTLINER 3 NODE AND ITS SUBTREE ?
property pblnSeln : false
[/CODE]

This is currently prefixing each OO3 topic with a hyphen and space, and exporting the whole document rather than the selection and its subtree, but you could set the value of [I]pstrDefaultPrefix [/I] to an empty string, and edit the value of [I]pblnSeln[/I] to true, for example.

[COLOR="White"]--[/COLOR]

RobTrew 2012-11-02 03:01 PM

PS the posted version of the script is exporting levels 1 and 2 of the OO3 outline as Markdown (hash-prefixed headers # and ##) but if you wanted to go down to using levels 3 or 4 (### and ####) of the OO3 hierarchy as headers you could adjust the value of:

[CODE]property plngMaxHash : 2 -- Deepest level of OO3 nesting to flag as headers rather than bullets etc[/CODE]

RobTrew 2012-11-02 03:11 PM

Ver 3 (above) allows you to control the paragraph separator though the value of [I]pstrEOL[/I] (end of line), now defaulting to two linefeeds. Also removes the hyphen prefix.

viellieb 2012-11-07 01:55 AM

Hy Rob,

Thanks again for investing so much time in my issue.

Your script is really awesome. It's not what I need for my current issue, but I'm sure it will do me good at other projects - when I'm starting off with a neatly organized outline :-)

Unfortuantely my current outline isn't all that tidy :D
Being able to copy all of it's children without intend into the note field of the current selection would be perfect.
This way I can decide in OmniOutliner what will be the "last" folder in Scrivener and what will be normal Text.

RobTrew 2012-11-08 02:24 AM

[QUOTE=viellieb;117054]Being able to copy all of it's children without intend into the note field of the current selection would be perfect.[/QUOTE]

Well you could experiment with this ...

(as drafted it doesn't delete the child nodes, but the comments contain instructions for changing the value of a property to do that, if it's really what you want, and if you are really working with a disposable copy of well backed up work). Personally I think that scripts are best used for gathering and integration, and deletion is always best done manually …

[CODE]-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-- OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

-- IF YOU *REALLY* WANT TO DELETE THE CHILD NOTES AFTER CAPTURING THEIR TEXT
-- CHANGE THE VALUE OF THIS PROPERTY TO TRUE …
-- BUT *ONLY* EXPERIMENT WITH DISPOSABLE COPIES OF MULTIPLY BACKED UP WORK ...
property pblnReallyDeleteDescendants : false

tell application id "OOut"
set lstDocs to documents
if length of lstDocs < 1 then return

tell first item of lstDocs
set lstSeln to selected rows
if length of lstSeln < 1 then return
tell first item of lstSeln
if has subtopics then ¬
set its note to its note & return & return & my GetSubText(its children)
set its note expanded to true
end tell
end tell
end tell

on GetSubText(lstChiln)
tell application id "OOut"
set str to ""
-- CAPTURE THE TEXT
repeat with oChild in lstChiln
tell oChild
set str to str & its topic & return & return & its note & return & return
if has subtopics of it then set str to str & my GetSubText(its children)
end tell
end repeat

-- AND THEN DELETE THE CHILDREN ?
if pblnReallyDeleteDescendants then
repeat with i from length of lstChiln to 1 by -1
delete item i of lstChiln
end repeat
end if
return str
end tell
end GetSubText
[/CODE]


All times are GMT -8. The time now is 01:17 PM.

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