The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Exporting to Merlin 2 FROM Omnifocus Thread Tools Search this Thread Display Modes
An illustrative draft of an applescript which exports the projects selected in Omnifocus to Merlin 2, with their tasks and subtasks.

(Note that any visible children of selected parents are exported, so there is no need to select children as well as parents).

This draft exports only activity names and notes (as Merlin 2 activity descriptions). It can easily be adapted to make use of OF start dates etc.

Code:
-- Illustrative draft Ver 0.0

-- Copies anything selected in Omnifocus (Project or Context View) into MERLIN 2
-- Note that the whole sub-tree is copied, so only 'parent' elements need to be selected.
-- The destination is a new Merlin 2 document.

property pPROJECT : "project"
property pTASK : "task"
property pITEM : "item"

on run
	set {lstActivities, blnContext} to SelectedInOF()
	
	PlaceinMerlin(lstActivities)
end run

-- TRANSFERRING TO MERLIN

on PlaceinMerlin(lstTasks)
	if (length of lstTasks > 0) then
		tell application id "net.projectwizards.Merlin2"
			
			set oDoc to make new document
			set oRoot to root project of oDoc
			set title of oRoot to "OmniFocus import" & " " & (current date) as string
			
			my PlaceTasks(lstTasks, oRoot)
		end tell
	end if
end PlaceinMerlin

on PlaceTasks(lstTasks, oParent)
	using terms from application "Merlin"
		tell oParent
			repeat with oTask in lstTasks
				set {strName, blnDone, lstSubTasks, strNote, strParent, dteStart, dteDue, dteDone, lngMins, blnFlagged} to oTask
				
				set oMlnTask to make new activity at end of activities of oParent
				tell oMlnTask
					set title to strName
					if length of strNote > 0 then set description to strNote
					
					-- Assign any other properties here, e.g. ...
					------ if dteStart is not missing value then set given planned start date min to dteStart
					------ if dteDue is not missing value then set given planned end date max to dteDue
				end tell
				
				if length of lstSubTasks > 0 then
					my PlaceTasks(lstSubTasks, oMlnTask)
				end if
			end repeat
		end tell
	end using terms from
end PlaceTasks


-- READ SELECTED OmniFocus CONTENT TREE(S) TO NESTED APPLESCRIPT LISTS - Ver.02

on SelectedInOF()
	tell application "OmniFocus"
		set oWin to front window
		set blnContext to ((selected view mode identifier) of oWin is not equal to pPROJECT)
		tell content of oWin
			set lstContentSeln to selected trees
			if (count of lstContentSeln) > 0 then -- Whatever is SELECTED in content panel
				set lstTrees to lstContentSeln
				set blnAll to false
			else -- EVERYTHING in the content panel
				set lstTrees to trees
				set blnAll to true
			end if
		end tell
		{my Trees2List(oWin, lstTrees, blnContext, blnAll), blnContext}
	end tell
end SelectedInOF

on Trees2List(oWin, lstTrees, blnContext, blnAll)
	set lstTasks to {}
	
	using terms from application "OmniFocus"
		repeat with oNode in lstTrees
			set oValue to value of oNode
			set cClass to class of oValue
			
			if cClass is not item then
				if cClass is project then
					set end of lstTasks to my ListProject(oNode, oValue, blnContext, blnAll)
				else
					set end of lstTasks to my ListContext(oNode, oValue, blnAll)
				end if
			else
				set end of lstTasks to my ListUnProcessed(oNode, oValue, blnContext, blnAll)
			end if
		end repeat
	end using terms from
	lstTasks
end Trees2List

on ListProject(oNode, oValue, blnContext, blnAll)
	using terms from application "OmniFocus"
		tell oNode
			set lstChildren to trees of oNode
			tell oValue
				if (count of lstChildren) > 0 then
					{name, completed, my ListSubTrees(lstChildren, blnContext, blnAll), note, "", start date, due date, completion date, estimated minutes, flagged}
				else
					{name, completed, {}, note, "", start date, due date, completion date, estimated minutes, flagged}
				end if
			end tell
		end tell
	end using terms from
end ListProject

on ListContext(oNode, oValue, blnAll)
	using terms from application "OmniFocus"
		tell oNode
			set lstChildren to trees
			set oValue to value of oNode
			tell oValue
				if (count of lstChildren) > 0 then
					{name, false, my ListSubTrees(lstChildren, true, blnAll), note, "", missing value, missing value, missing value, 0, false}
				else
					{name, false, {}, note, "", missing value, missing value, missing value, 0, false}
				end if
			end tell
		end tell
	end using terms from
end ListContext


on ListUnProcessed(oNode, oValue, blnContext, blnAll)
	using terms from application "OmniFocus"
		tell oNode
			set lstChildren to trees
			
			if blnContext then
				set strName to "No Context"
			else
				set strName to "Inbox"
			end if
			
			tell oValue
				if (count of lstChildren) > 0 then
					{strName, false, my ListSubTrees(lstChildren, blnContext, blnAll), "", "", missing value, missing value, missing value, 0, false}
				else
					{strName, false, {}, "", "", missing value, missing value, missing value, 0, false}
				end if
			end tell
		end tell
	end using terms from
end ListUnProcessed

on ListSubTrees(lstTrees, blnContext, blnAll)
	set lstTasks to {}
	repeat with oNode in lstTrees
		set end of lstTasks to my ListTask(oNode, blnContext, blnAll)
	end repeat
	return lstTasks
end ListSubTrees

on ListTask(oNode, blnContext, blnAll)
	using terms from application "OmniFocus"
		tell oNode
			set oTask to value of oNode
			set lstSubTrees to trees of oNode
			
		end tell
		if blnContext then
			set oParent to containing project of oTask
		else
			set oParent to context of oTask
		end if
		if oParent is not missing value then
			set strParent to name of oParent
		else
			set strParent to ""
		end if
		tell oTask
			if (count of lstSubTrees) > 0 then
				{name, completed, my ListSubTrees(lstSubTrees, blnContext, blnAll), note, strParent, start date, due date, completion date, estimated minutes, flagged}
			else
				{name, completed, {}, note, strParent, start date, due date, completion date, estimated minutes, flagged}
			end if
		end tell
	end using terms from
end ListTask

Last edited by RobTrew; 2010-03-02 at 03:46 PM.. Reason: Illustrate assignment of additional properties from OF data
 
Hello RobTrew,
Thank you for your great script to export to Omnifocus from Merlin Works great!.

im actually havin problem using the actulal one from Omnifocus to Merlin, i've added the scritp to the omnifocus folder and doesn't work and don't appear in the toolbar customisation menu.
Any cue to help me catch what i'm missing?

Best
 
The first port of call is this:

http://forums.omnigroup.com/showthread.php?t=7453

also worth checking whether you can run if from Applescript Editor.
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Send to Omnifocus from Merlin Arild OmniFocus Extras 21 2012-06-20 07:30 AM
Exporting from OmniFocus to OmniPlan RobTrew OmniFocus Extras 11 2011-12-29 10:18 AM
Update Merlin 2 tasks using OmniFocus JamieStarr OmniFocus Extras 4 2011-12-14 12:41 AM
Exporting Dates to OmniPlan (or Merlin) Nedzb OmniOutliner 3 for Mac 2 2010-12-13 01:06 PM
Exporting to Omnifocus document mpw OmniFocus 1 for Mac 2 2008-03-07 04:29 AM


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


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