Well, I surprised myself. This works, but I'm sure there are bugs and limitations. One known one is that it doesn't handle recurring events. iCal just gives you a recurrence rule and lets you figure out when the event will recur (see RFC 2445 and, well, don't look at me...). It will also not remove exceptions should an event be removed from your calendar.
So... regard this as a crude starting point?
Code:
tell application "iCal"
set startDates to start date of every event of calendar named "Work"
set endDates to end date of every event of calendar named "Work"
end tell
tell application "OmniPlan"
tell front document
tell schedule of resource named "Resource 1"
repeat with eIndex from 1 to count of startDates
set startDate to time string of (item eIndex of startDates)
set endDate to time string of (item eIndex of endDates)
subtract work time from my shortDate(startDate) to my shortDate(endDate) on item eIndex of startDates
end repeat
end tell
end tell
end tell
-- unfortunately the time parsing barfs if seconds are included
on shortDate(MyDate)
set Pos to offset of ":" in MyDate
set hour to characters 1 thru (Pos - 1) of MyDate as string
set MyDate to characters (Pos + 1) through end of MyDate as string
-- Get the "minute"
set Pos to offset of ":" in MyDate
set minute to characters 1 thru (Pos - 1) of MyDate as string
set MyDate to characters (Pos + 1) through end of MyDate as string
--Get "AM or PM"
set Pos to offset of " " in MyDate
set suffix to characters (Pos + 1) through end of MyDate as string
return (hour & ":" & minute & " " & suffix) as string
end shortDate