View Single Post
Ok, it bothered me that I couldn't figure out the "find or create resource" code so I got Lizard to help me out.

Code:
tell application "OmniPlan"
	
	-- This probably doesn't work in 1.1 beta 1 and earlier releases
	set myDoc to open "Users:tom:Desktop:PlanTest:foo.omniplan"
	-- The following, commented out code is the workaround
	-- open "Volumes:Extra:Users:tom:Desktop:PlanTest:foo.omniplan"
	-- set myDoc to document "foo.omniplan"
	
	tell myDoc
		set myToms to resources whose name is "Tom"
		if (count of myToms) > 0 then
			set Myself to first item of myToms
		else
			set Myself to make new resource with properties {kind:person, efficiency:2, name:"Tom", cost per hour:200.0}
		end if
		
		set MyTask to make new task with properties {name:"Cure Cancer", duration:8.0}
		assign MyTask to Myself
	end tell
	
end tell