View Single Post
Originally Posted by Carl Bourne View Post
Hi Guys,

I'm evaluating OP at the moment and need to automate pushing data in out. I need to use ruby for this since ultimately I want to hook it into a Rails app.

Could you provide some rb-appscript based examples as I'm struggling a bit at the moment. An example that first gets the % completed values then puts them back with a revised value would be wonderful. :) An example that adds new asks would also be useful.

Best Regards,

I can't give rb-appscript code, but I can share a simple AppleScript to do something similar:

tell application "OmniPlan"
	-- Note:  Inspector has "" as its name, and is often the front!
	set frontWindow to front window where name is not ""
	set selTasks to selected tasks of frontWindow
	repeat with curtask in selTasks
		set completed of curtask to 1.0
	end repeat
end tell
This iterates across each selected task in the front window (excluding the Inspector window), setting the "completed" value to "1.0". In other words, it lets me mark a bunch of tasks as "done" with a single click instead of going into the inspector to change the % Completed field to "100".

Similarly, you could do more complicated math on the current value of "completed of curtask" before setting it back again.