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 Search Today's Posts Mark Forums Read

 
Send from OmniPlan to OmniFocus Thread Tools Search this Thread Display Modes
Here is an illustrative first draft, which transfers any activities selected in OmniPlan (with their sub-activities) to a new date-stamped folder in OF.

--

Code:
-- ver 0.2 (Exports to an OF Folder, rather than making all tasks children of the same project)

-- All activities selected in OmniPlan GUI transferred (with their descendants) to 
-- a new date-stamped *folder* in OmniFocus, and each parent element selected in OP becomes a project in the OF folder,
-- with the descendent OP sub-tasks exported as a hierarchy of OF tasks
--
-- An alternative line shown in the FillofProj() function would exclude transfer of estimated minutes

property pstrOFProjectName : "OmniPlan import"

on run
	set lstTasks to OPSelected()
	
	if length of lstTasks > 0 then
		PlaceInOF(lstTasks)
	else
		display dialog "Select parent task(s) in OmniPlan, and try again"
	end if
end run

-- Get a nested list of the selected OmniPlan activities
on OPSelected()
	tell application "OmniPlan"
		tell front window
			set lstOPTasks to selected tasks
			if (count of lstOPTasks) > 0 then
				return my Tasks2NameList(lstOPTasks)
			else
				return {}
			end if
		end tell
	end tell
end OPSelected

-- -- Translate OmniPlan activities to a nested list of activity names
on Tasks2NameList(lstOPTasks)
	using terms from application "OmniPlan"
		set lstTasks to {}
		repeat with oTask in lstOPTasks
			tell oTask
				set lstChiln to child tasks
				if (lstChiln is not missing value) and (length of lstChiln) > 0 then
					set end of lstTasks to {name, my Tasks2NameList(lstChiln), starting date, ending date, note, duration / 60}
				else
					set end of lstTasks to {name, {}, starting date, ending date, note, duration / 60}
				end if
			end tell
		end repeat
		return lstTasks
	end using terms from
end Tasks2NameList

-- Place nested list of activity names in a new OF project
on PlaceInOF(lstActivities)
	if length of lstActivities > 0 then
		tell application "OmniFocus"
			tell front document
				set oFolder to make new folder with properties {name:pstrOFProjectName & " " & my SysDate()}
				my FillOFFolder(oFolder, lstActivities)
			end tell
		end tell
	end if
end PlaceInOF

on SysDate()
	current date
end SysDate

-- Transfer activities to the specified project (or parent task)
on FillOFFolder(oFolder, lstActivities)
	using terms from application "OmniFocus"
		tell oFolder
			repeat with oAct in lstActivities
				set {strName, lstChiln, dteStart, dteDue, strNote, lngMins} to oAct
				if strNote is missing value then
					set oProj to make new project with properties {name:strName, start date:dteStart, due date:dteDue, estimated minutes:lngMins}
					-- set oProj to make new project with properties {name:strName, start date:dteStart, due date:dteDue}
				else
					set oProj to make new project with properties {name:strName, start date:dteStart, due date:dteDue, note:strNote, estimated minutes:lngMins}
					-- set oProj to make new project with properties {name:strName, start date:dteStart, due date:dteDue, note:strNote}
				end if
				if length of lstChiln > 0 then
					my FillOFProj(oProj, lstChiln)
				end if
			end repeat
		end tell
	end using terms from
end FillOFFolder


-- Transfer activities to the specified project (or parent task)
on FillOFProj(oProj, lstActivities)
	using terms from application "OmniFocus"
		tell oProj
			repeat with oAct in lstActivities
				set {strName, lstChiln, dteStart, dteDue, strNote, lngMins} to oAct
				if strNote is missing value then
					-- set oTask to make new task with properties {name:strName, start date:dteStart, due date:dteDue, estimated minutes:lngMins}
					set oTask to make new task with properties {name:strName, start date:dteStart, due date:dteDue}
				else
					-- set oTask to make new task with properties {name:strName, start date:dteStart, due date:dteDue, note:strNote, estimated minutes:lngMins}
					set oTask to make new task with properties {name:strName, start date:dteStart, due date:dteDue, note:strNote}
				end if
				if length of lstChiln > 0 then
					my FillOFProj(oTask, lstChiln)
				end if
			end repeat
		end tell
	end using terms from
end FillOFProj

Last edited by RobTrew; 2011-09-10 at 01:10 AM.. Reason: Workaround for a new bug in the Applescript library
 
works just fine! i needed this feature so much! thanx!
 
I want to try this in OF but keep getting a syntax error in Applescript editor.
 
Quote:
Originally Posted by sflore8 View Post
I want to try this in OF but keep getting a syntax error in Applescript editor.
What does the error say ?

(I wonder if your use of the phrase "in OF" is a clue, as this is an applescript to be used in Omniplan for sending selected actions, and their children, to OmniFocus)

--

Last edited by RobTrew; 2010-05-22 at 08:01 AM..
 
Hi,

I'm looking for the opposite capability. To be able to export directly to Omniplan format from Omni Focus. It seems such an obvious ommission

Hugh
 
Quote:
Originally Posted by hughf View Post
I'm looking for the opposite capability. To be able to export directly to Omniplan format from Omni Focus
There is a OmniFocus --> OmniPlan script at

http://forums.omnigroup.com/showthread.php?t=15447
 
You rule! Thank you very much.
 
I just bought OmniPlan and needed to change the scripts to exchange data between OF and OP.

The Application ID changed to:-
com.omnigroup.OmniPlan.MacAppStore

After that "fix", both scripts are doing well.

Regards,
Stefan
 
Quote:
Originally Posted by sschultestrathaus View Post
I just bought OmniPlan and needed to change the scripts to exchange data between OF and OP.

The Application ID changed to:-
com.omnigroup.OmniPlan.MacAppStore

After that "fix", both scripts are doing well.
Thanks for letting me know, I hadn't heard that Apple have different bundle identifiers for AppStore versions, and I've amended the script above to use:

Code:
application "OmniPlan"
which should, I think, work with both versions.


(Pre-app store, Apple's own advice was to use the id + bundlename identification of applications, on the grounds that these were less likely to change, between versions, than the name property. Sounds like quite a lot of scripts may now have to be edited if others are to use them with AppStore-purchased versions :-)

As it happens, I notice that the execution speed seems to be marginally faster using the application name idiom ...

--

Last edited by RobTrew; 2011-06-28 at 01:44 PM.. Reason: The .MacAppStore affix is an Omni choice, not an Apple requirement
 
hello

Im a newbie of omnigroup product.

I was looking for the way to sending tasks in omniplan to omnifocus today, and i found this thread.

Id really love to use this script, but I couldnt figure out how to install this script and use it , although i googled the way to use applescript in omniplan.

Please anyone help me out !


Thanks,
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with send-to-omnifocus hh15302 OmniFocus for iPad 1 2011-12-10 08:49 AM
Send to Omnifocus mcortina OmniFocus Extras 0 2011-07-11 11:04 AM
New to Omnifocus: How to send an email from omnifocus iain.c.devine Applying OmniFocus 2 2011-01-31 11:30 PM
Send to Omnifocus? bcalloway OmniFocus for iPhone 2 2010-01-23 08:24 PM
Send Firefox URL to Omnifocus spnyc OmniFocus Extras 14 2009-02-12 01:44 PM


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


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