The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniPlan General (http://forums.omnigroup.com/forumdisplay.php?f=37)
-   -   Applescript problems (http://forums.omnigroup.com/showthread.php?t=1223)

mattao 2006-07-28 03:06 PM

Applescript problems
 
Hi guys,

As an architect I got a lot of projects for omniplan :)

It includes of course classic project planning.

But I plan to implement some right click linking of 3D model parts directly from maya.

AND

I want to create a little script to RECORD the task I am doing on my computer.

Example: Foundation works: start at 8.00 today ended at 11.30

I am planning to do that through applescripts.

Actually I succeed in creating a task from a script, change it's name or duration.

But I failed in effectively changing it's "starting date"

The actual start seems to be modified in the task information panel but it do not update the calendar view.
And the modification is buggy, as soon as I want to go to the ressource panel i got the following alert:[I]*** -[NSCFDate dayOfCommonEra]: selector not recognized [self = 0x52539c0][/I] wich appear and appear again in such a way i got to force quit.

here the applescript I wrote:
[I][COLOR="RoyalBlue"]
property ATime : date
property BTime : date
property CDuration : 4
property ADur : 4
property BDur : 4

tell application "OmniPlan"
activate
set CTime to (current date)
set myDoc to front document
tell front document
-- set Myself to make new resource with properties {kind:person, efficiency:2, name:"Tom", cost per hour:200.0}
--set MyTask to make new task with properties {name:"Cure Cancer", starting date:CTime, duration:CDuration}
--assign MyTask to Myself
set ADur to duration of task "Cure Mat"
set duration of task "Cure Mat" to 12
set BDur to duration of task "Cure Mat"
set ATime to starting date of task "Cure Mat"
set BTime to current date
set starting date of task "Cure Mat" to BTime
set BTime to starting date of task "Cure Mat"
display dialog ADur & " " & BDur & return & ATime & return & BTime as string
end tell
end tell
[/COLOR][/I]

Any clue?

PS: please ask if you want some more details on my goal. I am trying to do something like "timelog" do.

mattao 2006-07-28 03:09 PM

An clue from Len
 
I got this part of answer on an other thread:

[QUOTE=Len Case]Well, I don't know how to solve it, but the problem is that "current date" returns the wrong kind of date. (NSDate vs. NSCalendarDate)[/QUOTE]

I am actually working on it

mattao 2006-07-28 03:52 PM

It appears that OS X doesn't map NSDate objects to AppleScript dates.

As far as I can see I will need to use some Cocoa Method

mattao 2006-07-28 04:24 PM

Actually I switched to Xcode to get some cocoa code easily

Tom Bunch 2006-07-28 04:35 PM

[QUOTE=mattao]It appears that OS X doesn't map NSDate objects to AppleScript dates.[/QUOTE]

Yes, or, rather the default coercions don't map back and forth from AppleScript dates, which come to the app as NSDate, and NSCalendarDate, which we use in our object model. We have to add, oh, two lines of code, if we can only figure out which two.

-Tom

mattao 2006-07-31 11:48 AM

[QUOTE=Tom Bunch]Yes, or, rather the default coercions don't map back and forth from AppleScript dates, which come to the app as NSDate, and NSCalendarDate, which we use in our object model. We have to add, oh, two lines of code, if we can only figure out which two.

-Tom[/QUOTE]

Thank for your answer.

Do you think I should wait for you to fix this "two lines of code" or should I write in cocoa?

Greg Titus 2006-07-31 05:59 PM

We'll write it. Your script should work as is, we just need to fix the bug on our end.

mattao 2006-08-02 10:52 AM

thanks.

please warn me as soon as the update is done in order to give me the ability to go on my development...

:D

mattao 2006-08-18 04:36 PM

no news
 
Hi,

Should I expect something new in the next update?

Lizard 2006-08-20 08:05 PM

Not beta 6, maybe in beta 7 (but no guarantees). We've been a little side-tracked by WWDC.

mattao 2006-09-08 12:11 PM

Beta 7.
 
Could you confimr me if beta 7 will contain this problem?

Thanks

Greg Titus 2006-09-10 08:39 AM

[QUOTE=mattao]Could you confimr me if beta 7 will contain this problem?
[/QUOTE]

This bug is now fixed, and so with beta 7 you should no longer have any problems with AppleScripting dates.

mattao 2006-09-19 03:45 PM

[QUOTE=Greg Titus]This bug is now fixed, and so with beta 7 you should no longer have any problems with AppleScripting dates.[/QUOTE]
Cool thanks

I am impatient!

mattao 2006-09-28 06:23 PM

Great improve
 
OK guys

My scripts actually work.
I will add some functionality soon I try to build up an aplication.

Thanks a lot for your help.

I will give news soon.

Lizard 2006-09-28 08:27 PM

Thanks for the good news mattao, and let us know if you hit any more roadblocks.

mattao 2006-11-27 12:49 PM

New problem with group
 
Hi guys and gals,

And a BIG HI to Lizard,

My script is evoluting I need to create group and affects task to it.

I can't succeed! Could you please help?

my script is:

property ATime : date
property BTime : date
property CDuration : 4
property ADur : 4
property BDur : 4


set CTime to (current date)

tell application "OmniPlan"
activate
tell document "planning"
set MyTask to make new task with properties {name:"Cure Mat"}
set MyTask to make new task with properties {name:"Bisoux", starting date:CTime, duration:CDuration}
set duration of task "Bisoux" to 1
set ATime to current date
set starting date of task "Bisoux" to ATime

set task type of task "Cure Mat" to group task
set parent task of task "Bisoux" to "Cure Mat"


end tell
end tell

:mad:

As you can probably see if you try it, it fail on the last instruction line. I got an error message:"OmniPlan got an error: Can't make "Cure Mat" into type task."

What to do?

mattao 2006-11-27 03:07 PM

And in the dictionnary I read: "parent task (task, r/o) : the group that this task is in"

What the hell r,o mean?

Thanks

mattao 2006-11-27 03:15 PM

OK r/o means read only!

Who said it's obvious?

:rolleyes:


All times are GMT -8. The time now is 09:22 AM.

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