Exporting from OmniFocus to OmniPlan
Here is an illustrative first draft of an applescript which exports whatever is selected in OmniFocus over into the current OmniPlan document (or a fresh OmniPlan document if none is selected).
This draft exports [COLOR="RoyalBlue"]name[/COLOR], [COLOR="RoyalBlue"]note[/COLOR], [COLOR="RoyalBlue"]start date[/COLOR], [COLOR="RoyalBlue"]due date[/COLOR], [COLOR="RoyalBlue"]estimated minutes[/COLOR], and [COLOR="RoyalBlue"]done[/COLOR], which is translated to Completed=1 in OP. Note that the whole sub-tree of the currently selected folder(s), projects(s) and/or task(s) is transferred, so only parent elements need to be selected in the OF interface. (Selecting both parents and their children will cause duplication). [CODE]-- Illustrative draft Ver 0.7 -- Copies anything selected in Omnifocus (Project or Context View) into Omniplan -- Note that the whole sub-tree is copied, so only 'parent' elements need to be selected. -- The destination is the currently open OmniPlan document. -- (A fresh OmniPlan document is created if none is open) property pPROJECT : "project" property pTASK : "task" property pITEM : "item" on run set {lstActivities, blnContext} to SelectedInOF() PlaceinOP(lstActivities) end run -- TRANSFERRING TO OMNIPLAN on PlaceinOP(lstTasks) if (length of lstTasks > 0) then tell application id "OPla" if (count of documents) < 1 then set oDoc to make new document else set oDoc to front document end if my PlaceTasks(lstTasks, oDoc) end tell end if end PlaceinOP on PlaceTasks(lstTasks, oParent) tell application id "OPla" tell oParent repeat with oTask in lstTasks set {strName, blnDone, lstSubTasks, strNote, strParent, dteStart, dteDue, dteDone, lngMins, blnFlagged} to oTask if length of strNote > 0 then set oOPTask to make new task with properties {name:strName, note:strNote} else set oOPTask to make new task with properties {name:strName} end if tell oOPTask if dteStart is not equal to missing value then set starting date to dteStart if dteDue is not equal to missing value then set ending date to dteDue if lngMins > 0 then set duration to lngMins * 60 end if if blnDone then set completed to 1 end tell if length of lstSubTasks > 0 then my PlaceTasks(lstSubTasks, oOPTask) end if end repeat end tell end tell end PlaceTasks -- READ SELECTED OmniFocus CONTENT TREE(S) TO NESTED APPLESCRIPT LISTS - Ver.02 on SelectedInOF() tell application id "OFOC" 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 {} tell application id "OFOC" 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 if cClass is task then set end of lstTasks to my ListTask(oNode, 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 tell lstTasks end Trees2List on ListProject(oNode, oValue, blnContext, blnAll) tell application id "OFOC" 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 tell end ListProject on ListContext(oNode, oValue, blnAll) tell application id "OFOC" 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 tell end ListContext on ListUnProcessed(oNode, oValue, blnContext, blnAll) tell application id "OFOC" 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 tell 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) tell application id "OFOC" 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 tell end ListTask [/CODE] |
Thanks so much Rob!
I just started a project estimation by entering data in OmniFocus, but then later realised that I couldn't copy/paste this into OmniPlan. You saved my day! |
Rob, you just saved me either a ton of work or a long wait until the new OmniFocus launches.
Thank you so much. |
Is there a way to edit this to open the beta of Omni Plan 2 ?
|
[QUOTE=ext555;96874]Is there a way to edit this to open the beta of Omni Plan 2 ?[/QUOTE]
Change the application id to "com.omnigroup.OmniPlan2" - I haven't done much OmniPlan scripting, but I know that much. :-) Hope this helps! |
thanks Brian ! that was exactly the error it was giving me that it couldn't find the application id omniplan .
|
I have modified the code in the first post (above) to ver 0.6, which should, I think work with both versions of OmniPlan, and with the App-Store variant of OmniFocus as well as the original.
(Uses the more generic [I]application id "OPla"[/I] and [I]application id "OFOC"[/I]) [COLOR="White"]--[/COLOR] |
Awesome , works great ! thanks so much .
|
Hey, this is great.
Is there anything special I need to do to get estimated duration working? Most of mine are blank, but some of them have things like '2h' - but they all show up as 1 day in omniplan. Thanks!!! |
I have made an edit to version 0.7 which may improve the mapping of [I]estimated minutes[/I] onto [I]duration[/I].
(Bear in mind that, depending on project settings, OP may recalculate parental durations in the light of the descendants or sub-components of a task.) |
All times are GMT -8. The time now is 06:33 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.