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 > Developer > AppleScripting Omni Apps
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Fetching all OmniPlan tasks Thread Tools Search this Thread Display Modes
I'm trying to extract all the tasks from an OmniPlan document and I'm adapting one of Rob Trew's scripts to send OP tasks to OF so that it creates a TaskPaper document instead. It's working, but currently the script is only sending the selected tasks:

tell window 1
    set lstOPTasks to selected tasks of it
end tell
And I want to send the whole document without having to select, using something like:

tell document 1 of it
    set lstOPTasks to task of it
end tell
Unfortunately the second form seems seems to have done a recursive descent of all tasks to populate the list, while leaving the descendants of each task intact. Consequently I see every task twice.

It there a way to get hold of some phantom root task or just the top level tasks?


(have pity: I only opened "Learn AppleScript" on Friday)
Answered my own question just filtered the list:
		tell document 1 of it
			set allTasks to task of it
			set lstOPTasks to {}
			repeat with aTask in allTasks
				if (outline depth of aTask) is 1 then
					set end of lstOPTasks to aTask
				end if
			end repeat
		end tell
If you're munging the script I think you are, replacing OPSelected() with the following code should change its behavior to send all tasks if none are selected, otherwise only the selected ones:

on OPSelected()
	tell application "OmniPlan"
		tell front window
			if (count of selected tasks) > 0 then
				set lstOPTasks to selected tasks
				set lstOPTasks to (every child task)
			end if
			if (count of lstOPTasks) > 0 then
				return my Tasks2NameList(lstOPTasks)
				return {}
			end if
		end tell
	end tell
end OPSelected
That is indeed a much better idea. Thanks.
A more idiomatic (and efficient) way of doing your filtering might be:

tell document 1 of it
      set lstOPTasks to (every task whose outline depth is 1)
end tell
Originally Posted by whpalmer4 View Post
A more idiomatic (and efficient) way of doing your filtering might be:
You should see the rest of my script, you would probably weep.
Very few arrive like Athena, springing forth fully armed from the head of Zeus :-)
Many are called but few are chosen.

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
OmniPlan Help - Prioritising Tasks Tan OmniPlan General 0 2012-08-09 02:54 AM
Custom Filter (Sync Tasks to/from iCal) doesn't work in Omniplan 2.0 GM (w officerfishdumplings OmniPlan General 7 2011-09-01 07:43 AM
Omniplan fixed end dates and flexible tasks psilas OmniPlan General 4 2010-10-28 04:08 AM
Omniplan does not appear to contain valid Omniplan data fposada OmniPlan General 2 2009-11-30 11:58 PM
"Fetching remote database" takes forever? Quorcork OmniFocus Syncing 10 2009-06-29 09:06 AM

All times are GMT -8. The time now is 02:46 PM.

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