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 > OmniPlan > OmniPlan Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Need help with applescript terminology please Thread Tools Search this Thread Display Modes
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
 
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
 
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
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
 
thanks for the examples !!

what about oTask that's mentioned elsewhere in the plan forums ?
 
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'
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Applescript help Shek OmniGraffle General 3 2012-09-04 04:02 AM
$$ for Applescript Help Hewdini OmniFocus Extras 1 2009-08-14 11:34 AM
Applescript Help ryan_marsh OmniFocus 1 for Mac 3 2008-11-24 08:51 AM
Help with applescript mrpuggles AppleScripting Omni Apps 1 2008-09-16 04:40 PM
Task vs Action terminology ptone OmniFocus Extras 2 2007-12-17 08:09 PM


All times are GMT -8. The time now is 04:33 PM.


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