The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Send from OmniPlan to OmniFocus (http://forums.omnigroup.com/showthread.php?t=15448)

RobTrew 2010-02-27 11:06 AM

Send from OmniPlan TO OmniFocus
 
Here is an illustrative first draft, which transfers any activities selected in [B]OmniPlan[/B] (with their sub-activities) to a new date-stamped folder in OF.

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

[CODE]-- ver 0.2 (Exports to an OF Folder, rather than making all tasks children of the same project)

-- All activities selected in OmniPlan GUI transferred (with their descendants) to
-- a new date-stamped *folder* in OmniFocus, and each parent element selected in OP becomes a project in the OF folder,
-- with the descendent OP sub-tasks exported as a hierarchy of OF tasks
--
-- An alternative line shown in the FillofProj() function would exclude transfer of estimated minutes

property pstrOFProjectName : "OmniPlan import"

on run
set lstTasks to OPSelected()

if length of lstTasks > 0 then
PlaceInOF(lstTasks)
else
display dialog "Select parent task(s) in OmniPlan, and try again"
end if
end run

-- Get a nested list of the selected OmniPlan activities
on OPSelected()
tell application "OmniPlan"
tell front window
set lstOPTasks to selected tasks
if (count of lstOPTasks) > 0 then
return my Tasks2NameList(lstOPTasks)
else
return {}
end if
end tell
end tell
end OPSelected

-- -- Translate OmniPlan activities to a nested list of activity names
on Tasks2NameList(lstOPTasks)
using terms from application "OmniPlan"
set lstTasks to {}
repeat with oTask in lstOPTasks
tell oTask
set lstChiln to child tasks
if (lstChiln is not missing value) and (length of lstChiln) > 0 then
set end of lstTasks to {name, my Tasks2NameList(lstChiln), starting date, ending date, note, duration / 60}
else
set end of lstTasks to {name, {}, starting date, ending date, note, duration / 60}
end if
end tell
end repeat
return lstTasks
end using terms from
end Tasks2NameList

-- Place nested list of activity names in a new OF project
on PlaceInOF(lstActivities)
if length of lstActivities > 0 then
tell application "OmniFocus"
tell front document
set oFolder to make new folder with properties {name:pstrOFProjectName & " " & my SysDate()}
my FillOFFolder(oFolder, lstActivities)
end tell
end tell
end if
end PlaceInOF

on SysDate()
current date
end SysDate

-- Transfer activities to the specified project (or parent task)
on FillOFFolder(oFolder, lstActivities)
using terms from application "OmniFocus"
tell oFolder
repeat with oAct in lstActivities
set {strName, lstChiln, dteStart, dteDue, strNote, lngMins} to oAct
if strNote is missing value then
set oProj to make new project with properties {name:strName, start date:dteStart, due date:dteDue, estimated minutes:lngMins}
-- set oProj to make new project with properties {name:strName, start date:dteStart, due date:dteDue}
else
set oProj to make new project with properties {name:strName, start date:dteStart, due date:dteDue, note:strNote, estimated minutes:lngMins}
-- set oProj to make new project with properties {name:strName, start date:dteStart, due date:dteDue, note:strNote}
end if
if length of lstChiln > 0 then
my FillOFProj(oProj, lstChiln)
end if
end repeat
end tell
end using terms from
end FillOFFolder


-- Transfer activities to the specified project (or parent task)
on FillOFProj(oProj, lstActivities)
using terms from application "OmniFocus"
tell oProj
repeat with oAct in lstActivities
set {strName, lstChiln, dteStart, dteDue, strNote, lngMins} to oAct
if strNote is missing value then
-- set oTask to make new task with properties {name:strName, start date:dteStart, due date:dteDue, estimated minutes:lngMins}
set oTask to make new task with properties {name:strName, start date:dteStart, due date:dteDue}
else
-- set oTask to make new task with properties {name:strName, start date:dteStart, due date:dteDue, note:strNote, estimated minutes:lngMins}
set oTask to make new task with properties {name:strName, start date:dteStart, due date:dteDue, note:strNote}
end if
if length of lstChiln > 0 then
my FillOFProj(oTask, lstChiln)
end if
end repeat
end tell
end using terms from
end FillOFProj[/CODE]

livesey 2010-03-06 05:42 AM

works just fine! i needed this feature so much! thanx!

sflore8 2010-05-22 01:31 AM

I want to try this in OF but keep getting a syntax error in Applescript editor.

RobTrew 2010-05-22 03:56 AM

[QUOTE=sflore8;77538]I want to try this [B]in OF[/B] but keep getting a syntax error in Applescript editor.[/QUOTE]

What does the error say ?

(I wonder if your use of the phrase "[B]in OF[/B]" is a clue, as this is an applescript to be used in [B]Omniplan[/B] for sending selected actions, and their children, [B]to[/B] OmniFocus)

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

hughf 2010-05-23 09:47 AM

Hi,

I'm looking for the opposite capability. To be able to export directly to Omniplan format from Omni Focus. It seems such an obvious ommission

Hugh

RobTrew 2010-05-23 02:31 PM

[QUOTE=hughf;77562]I'm looking for the opposite capability. To be able to export directly to Omniplan format from Omni Focus[/QUOTE]

There is a OmniFocus --> OmniPlan script at

[URL="http://forums.omnigroup.com/showthread.php?t=15447"]http://forums.omnigroup.com/showthread.php?t=15447[/URL]

platonium 2010-09-17 10:11 AM

You rule! Thank you very much.

sschultestrathaus 2011-03-08 12:06 PM

Script tweak needed if OmniPlan bought via AppStore
 
I just bought OmniPlan and needed to change the scripts to exchange data between OF and OP.

The Application ID changed to:-
com.omnigroup.OmniPlan.MacAppStore

After that "fix", both scripts are doing well.

Regards,
Stefan

RobTrew 2011-03-08 01:55 PM

[QUOTE=sschultestrathaus;94516]I just bought OmniPlan and needed to change the scripts to exchange data between OF and OP.

The Application ID changed to:-
com.omnigroup.OmniPlan.MacAppStore

After that "fix", both scripts are doing well.[/QUOTE]

Thanks for letting me know, I hadn't heard that Apple have different bundle identifiers for AppStore versions, and I've amended the script above to use:

[CODE]application "OmniPlan"[/CODE]

which should, I think, work with both versions.


(Pre-app store, Apple's own advice was to use the [B]id + bundlename[/B] identification of applications, on the grounds that these were less likely to change, between versions, than the [B]name[/B] property. Sounds like quite a lot of scripts may now have to be edited if others are to use them with AppStore-purchased versions :-)

As it happens, I notice that the execution speed seems to be marginally faster using the application [I]name[/I] idiom ...

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

001shu 2011-09-09 07:24 PM

how can i use this script?
 
hello

Im a newbie of omnigroup product.

I was looking for the way to sending tasks in omniplan to omnifocus today, and i found this thread.

Id really love to use this script, but I couldnt figure out how to install this script and use it , although i googled the way to use applescript in omniplan.

Please anyone help me out !


Thanks,

whpalmer4 2011-09-09 11:05 PM

The process is described in this thread: [url]http://forums.omnigroup.com/showthread.php?t=7453[/url]

You need to follow the directions quite carefully or you'll end up needing to create some things by hand.

The script itself you copy from the web post and paste into a blank window in the Applescript Editor application, then save in the OmniFocus script directory with a suitable name.


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

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