The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniPlan Extras (http://forums.omnigroup.com/forumdisplay.php?f=45)
-   -   Need help with applescript terminology please (http://forums.omnigroup.com/showthread.php?t=4807)

ext555 2007-09-08 10:45 AM

Need help with applescript terminology please
 
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 2007-09-10 03: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.

[CODE]
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
[/CODE]

Lizard 2007-09-10 03:29 PM

This blob of code might also be helpful:
[CODE]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
[/CODE]

and
[CODE]
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
[/CODE]

ext555 2007-09-10 06:53 PM

thanks for the examples !!

what about oTask that's mentioned elsewhere in the plan forums ?

Lizard 2007-09-12 10:48 AM

If you're talking about threads like this one
[url]http://forums.omnigroup.com/showthread.php?t=4526[/url]
that's just a variable name, like 'newTask' or 'oldTask' or 'sourceProject'


All times are GMT -8. The time now is 09:28 PM.

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