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 > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Today's Posts

 
focusing on all non-single-action projects Thread Tools Search this Thread Display Modes
For my weekly review, I like to take a look at a list of all my active projects. Within my planning hierarchy, I also have interspersed some single-action lists ("teaching singletons," "husband singletons," "colleague singletons"), which I don't want to review in this part of my weekly review.

So my present practice is to show all active projects, select all, collapse all, then go through and deselect (with Command held down) the single-actions lists, and then hit focus to drop them out.

I'm wondering if this would be easily scriptable. Ideas on how?
 
Something of this kind, perhaps.

Code:
tell application "OmniFocus"
	tell default document
		if number of document window is 0 then
			make new document window with properties {bounds:{0, 0, 1000, 500}}
		end if
	end tell
	
	tell window 1
		
		set selected view mode identifier to "project"
		set focus to {}
		
		tell sidebar
			select library
		end tell
		
		tell content
			
			set lstFocus to {}
			repeat with oTree in trees
				set expanded of oTree to false
				
				set oProject to value of oTree
				if not (singleton action holder of oProject) then
					set end of lstFocus to oProject
				end if
			end repeat
			
		end tell
		
		set focus to lstFocus
	end tell
end tell

Last edited by RobTrew; 2008-02-26 at 11:45 AM.. Reason: amend code
 
RobTrew for President!

Thanks, that works. At first it didn't - I got an error about not being able to make something type boolean. But I realized it was because the inbox was selected in the preexisting window, so when the script selected the library it was adding to, rather than replacing that selection, and then the script seems to have choked on doing its business on the inbox.

Changing
Code:
set selected of library to true
to
Code:
select library
fixed that.

Very helpful! Thanks again - I learn lots from your scripts.
 
Thanks for the edit. I will make it retrospectively.

Glad the snippet is useful.
 
From your snippet I inferred that a good way to expand all would be this:
Code:
tell content of window 1
	repeat with oTree in trees
		set expanded of oTree to true
	end repeat
end tell
but that leaves action groups collapsed. Is there a piece I'm missing?
 
There may be a syntactic route to something more elegant, but here is an approach to doing it recursively.


Code:
tell application "OmniFocus"
	tell content of window 1
		repeat with oTree in trees
			my Expand(oTree)
		end repeat
	end tell
end tell


on Expand(oTree)
	using terms from application "OmniFocus"
		set oSubTrees to trees of oTree
		if (count of oSubTrees) > 0 then
			set expanded of oTree to true
			repeat with oSubTree in oSubTrees
				Expand(oSubTree)
			end repeat
		end if
	end using terms from
end Expand

Last edited by RobTrew; 2008-02-26 at 01:15 PM..
 
 




Similar Threads
Thread Thread Starter Forum Replies Last Post
Single Action Lists VS. Projects Deinhart Applying OmniFocus 4 2012-06-14 01:49 AM
Single action, multiple projects? enmare OmniFocus 1 for Mac 3 2010-06-12 02:17 AM
Opening Projects for a Single Action in 1.7 gdevore OmniFocus 1 for Mac 8 2009-08-20 04:30 PM
Single action projects gmahoney OmniFocus 1 for Mac 2 2008-07-12 07:54 AM
Alphabetize Projects And Single Action Lists Dogsbreath OmniFocus 1 for Mac 3 2008-02-05 11:53 AM


All times are GMT -8. The time now is 10:45 AM.


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