View Full Version : Need help with applescript terminology please
ext555
09-08-2007, 11:45 AM
trying to write a quick script to export omni focus top level items to Omni Plan
What I need to know is : what items do I tell Omni Plan to " make" to correspond with " trees " it doesn't seem to like 'tasks " or "task" ..
do I need to call it " group task " or " parent task" maybe ?
thanks for any help you can offer . :)
Paul
Lizard
09-10-2007, 04:25 PM
You're going to want to "make new task". (OmniPlan doesn't have any sort of tree stuff, tasks just have more tasks as children.) The code snippet below is copying tasks from one OmniPlan file to another, but if you replace all the stuff referring to "oldTask" with code that talks to OmniFocus, you'll be getting fairly close to what you want. This code was pulled out of the "Join Projects" script on our extras page, so you might look there for more example code.
Since OmniFocus and OmniPlan both use the term 'task' but don't mean exactly the same thing, make extra sure that you're "using terms from" the correct application.
on copyTask(oldTask, newParent, destProject)
using terms from application "OmniPlan"
set n to name of oldTask
set c to completed of oldTask
set recalcDur to recalculates duration of oldTask
set e to effort of oldTask
set nt to note of oldTask
-- do not set start date or duration yet
tell newParent
set newTask to make new task with properties {name:n, completed:c, note:nt}
set recalculates duration of newTask to recalcDur
end tell
-- assign resources
repeat with a in assignments of oldTask
set oldResID to id of resource of a
set newResID to findNewID(oldResID, my resourceIDMap)
set newTaskID to id of newTask
set oldTaskID to id of oldTask
set u to units of a
tell destProject
assign task id newTaskID to resource id newResID units u
end tell
end repeat
--have to set effort/duration after assignments to make calc work out right
tell destProject
set effort of newTask to e
end tell
return newTask
end using terms from
end copyTask
Lizard
09-10-2007, 04:29 PM
This blob of code might also be helpful:
on copyChildTasks(sourceTree, destTree, destProject)
using terms from application "OmniPlan"
repeat with c in child tasks of sourceTree
set newTask to my copyTask(c, destTree, destProject)
my copyChildTasks(c, newTask, destProject)
end repeat
end using terms from
end copyChildTasks
and
set frontWindow to front window
set destDoc to document of frontWindow
set destProject to project of my destDoc
tell destProject
set newProjectRoot to make new task with properties {name:sourceName, note:projnote}
end tell
ext555
09-10-2007, 07:53 PM
thanks for the examples !!
what about oTask that's mentioned elsewhere in the plan forums ?
Lizard
09-12-2007, 11:48 AM
If you're talking about threads like this one
http://forums.omnigroup.com/showthread.php?t=4526
that's just a variable name, like 'newTask' or 'oldTask' or 'sourceProject'
vBulletin® v3.7.0, Copyright ©2000-2008, Jelsoft Enterprises Ltd.