Skip to content

Instantly share code, notes, and snippets.

@ttscoff
Created September 28, 2012 20:10
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ttscoff/3801870 to your computer and use it in GitHub Desktop.
Save ttscoff/3801870 to your computer and use it in GitHub Desktop.
Creates nvALT notes from topics in a MindManager mind map, with links to open them from the map.
(*
mindjet2nvalt
Goes through selected nodes in MindJet Manager and creates
nvALT notes for them, adding a rocket icon to each node which
will locate the note when clicked. If the node has a note
attached, it is used as the content of the nvALT note.
Copyright 2012 Brett Terpstra
License is granted to use and modify for personal use
Do not distribute modified copies without permission
*)
----====User Config====----
-- by default, this property will avoid changing a
-- link on a node in case the title changes but you
-- want the link to remain connected
property overwriteLinks : true
-- centralTopicAsTags will convert the title of
-- map's main node into tags, allowing you to group
-- them together with nvALT or Spotlight searches
property centralTopicAsTags : true
-- centralTopicAsNotePrefix will prefix "[Central Topic title]: "
-- to the title of the note, if that's how you prefer to search
property centralTopicAsNotePrefix : false
---===End User Config===---
property _ucChars_ : "AÄÁÀÂÃÅĂĄÆBCÇĆČDĎĐEÉÈÊËĚĘFGHIÍÌÎÏJKLĹĽŁMNÑŃŇ" & ¬
"OÖÓÒÔÕŐØPQRŔŘSŞŠŚTŤŢUÜÚÙÛŮŰVWXYÝZŽŹŻÞ"
property _lcChars_ : "aäáàâãåăąæbcçćčdďđeéèêëěęfghiíìîïjklĺľłmnñńň" & ¬
"oöóòôõőøpqrŕřsşšśtťţuüúùûůűvwxyýzžźżþ"
tell application "Mindjet MindManager"
set theDocument to document 1
set theSelection to selection of theDocument
set _proj to central topic of theDocument
if theSelection is not equal to {} then
repeat with _t in theSelection
if hyperlink URL of _t is missing value or overwriteLinks is true then
set _map to POSIX path of (file of theDocument as alias)
if centralTopicAsNotePrefix is true then
set _name to (title of _proj) & ": " & title of _t
else
set _name to title of _t
end if
set _note to notes of _t as string
if centralTopicAsTags is true then
set _tags to "#" & my replace_string(" ", "-", my lowercase_string(title of _proj))
else
set _tags to ""
end if
set _link to my create_nv_note(_name, _note, _map, _tags)
set hyperlink URL of _t to _link
else if hyperlink URL of _t is not missing value then
set _url to hyperlink URL of _t
tell application "Finder" to open location _url
return
end if
end repeat
tell application "Mindjet MindManager" to activate
else
display dialog "You must have at least one node selected"
end if
end tell
-- creates a new note and returns a url for it
on create_nv_note(_title, _note, _map, _tags)
set newlink to ""
if _note is missing value or _note is equal to "" then
set newlink to "nvalt://make/?title=" & _title & "&tags=" & _tags & "&txt=" & "New note from Mind Map <file://" & my replace_string(" ", "%20", _map) & ">"
else
set newlink to "nvalt://make/?title=" & _title & "&tags=" & _tags & "&txt=" & _note
end if
tell application "Finder" to open location newlink
set _link to "nvalt://find/" & _title
return _link
end create_nv_note
on replace_string(thisStr, thatStr, origString) -- credit: Jon Pugh <http://www.seanet.com/~jonpugh/>
set {oldDelim, AppleScript's text item delimiters} to {AppleScript's text item delimiters, thisStr}
set theList to text items of origString
set AppleScript's text item delimiters to thatStr
set theString to theList as string
set AppleScript's text item delimiters to oldDelim
return theString
end replace_string
on lowercase_string(theText) -- credit: <http://applescript.bratis-lover.net/library/string/>
local upper, lower, theText
try
return my translateChars(theText, my _ucChars_, my _lcChars_)
on error eMsg number eNum
error "Can't lowerString: " & eMsg number eNum
end try
end lowercase_string
on translateChars(theText, fromChars, toChars)
local Newtext, fromChars, toChars, char, newChar, theText
try
set Newtext to ""
if (count fromChars) ≠ (count toChars) then
error "translateChars: From/To strings have different lenght"
end if
repeat with char in theText
set newChar to char
set x to offset of char in fromChars
if x is not 0 then set newChar to character x of toChars
set Newtext to Newtext & newChar
end repeat
return Newtext
on error eMsg number eNum
error "Can't translateChars: " & eMsg number eNum
end try
end translateChars
@rem90
Copy link

rem90 commented May 23, 2016

Hello, when I run this script, I get the following error: error "Can’t make missing value into type alias." number -1700 from missing value to alias

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment