Jump to content

how to check if CAD is OPEN AND READY


Recommended Posts

Posted

i am trying to check to see is the instance of AutoCad is ready . i know i can check the processes to see what is running but i dont hink that gives me a check of if it is ready or not. since autocad takes forever to load i need to see if there is a state that i cn check that will inform that the instance is fully loaded

Posted

When you open the program, there will be a load screen. The load screen will run for a while, and then your actual ACad window will open. If you look at the command line, you can see it loading all the files it has to load on startup. As soon as you see the word COMMAND: in the command line, you're ready to go. As long as your able to actually do something in the program, it's ready.

 

Perhaps I'm misunderstanding your question?

Posted

yes i think there is a misunderstanding. i know when the autocad application is ready to use from a user stand point. yes i know that a command prompt will come up..and no i am not refering to any of that. i am looking at this as strictly a process level state. the application i am running is automatically opening the cad sopftware then opening drawings according to the input given. this is NOT a plug in. it is an exe that accesses autocad. but when you open autocad it gets only 70% ready before the code moves on to the next routine... so what i need is to basically put a wait or mutex and waitone in there so i can wait till autocad is fully loaded. the thing is.. how to see if it is fully loaded from the code point of view

Posted

Ah... I see. Well, with mine, as soon as it's completely loaded, the CPU usage in my task manager drops to 0...

Posted

i thought as much but its tough to trouble shoot a process check through the debug lol.. the cad load wont pause for me... but i am currently trying to check for a named process that is from the created app object from with in the code..

Posted

This thread sounds vaguely familiar. I'm sure someone has inquired about this in the past but for the moment I cannot recall the exact thread.

 

Have you posted the question in the AutoDesk Discussion forums by any chance? There is a subforum for programming and customization.

Posted

i am looking online for any reference to this. but to clarify. i am trying to ope a file (dwg) after i open autocad. but if cad is not fully loaded i get an error.. call rejected by callee....but i put in a message box after the call to open autocad and wait till autocad is load before i click ok on it.. and everything is fine.. so basically i am jsut trying to cade a wait till autocad is fully loaded.. when i try to check for processes the app crashes... so i am thinking i have to start a parallel thread to check for processes and then end the thread when cad is checked.. ok.. just a thought

Posted

Yes, I realize that you are 1) waiting for AutoCAD to fully load and 2) then opening a file.

 

You're basically familiar with what is being loaded at AutoCAD startup then I assume.

Posted

i guess i dont know fully what processes are going on when cad loads.. it does take forver though lol.. so i guess i just need to know that.. or a metod to check for completion

Posted

thanks for the tip. i checked that out and it basically checks if the object has been created. i am trying to basically see if CAD is at the command prompt state within the program ..i.e. ready to take command.. if there is no way to check then i guess i have to put thread sleep in there.. and that is not my first choice by far

Posted

very helpful.. thanks.. i guess to get very direct i just need to check when S::STARTUP has been called within cad..according to the call order at startup that is the last thing that is called so if i check for that then i know i should be good.... lol so how do i check for it?

Posted

soooooo. i guess it pays to ask the right question.. the state that i am looking for is a return from IsQuiescent()

so now i just need to know how to call this at the right time so it wont error out from the new object creation.. but the key is that function

Posted

ok... finally for anyone who is in need of this little tip.. i am very very very close...i just need to catch the exception and keep looping till i get true from Isquiecent() here is a what i got so far..i just need to just catch the exception now

[font=Consolas][size=2][font=Consolas][size=2]
 State = MyAcad.GetAcadState

           
[/size][/font]
[/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Do[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] [/size][/font][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Until[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] cadquiet = [/size][/font][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]True[/color][/size][/font][/color][/size][/font][/color][/size][/font]
[font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2]
               
[/size][/font]
[/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Try[/color][/size][/font][/color][/size][/font][/color][/size][/font]
[font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2]
                   
[/size][/font]
[/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]If[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] State.IsQuiescent [/size][/font][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Then[/color][/size][/font][/color][/size][/font][/color][/size][/font]
[font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2]
                       cadquiet = 
[/size][/font]
[/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]True[/color][/size][/font][/color][/size][/font][/color][/size][/font]
[font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2]
                   
[/size][/font]
[/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]End[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] [/size][/font][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]If[/color][/size][/font][/color][/size][/font][/color][/size][/font]
[font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2]
               
[/size][/font]
[/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Catch[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] ex [/size][/font][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]As[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] [/size][/font][/size][/font][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af]Exception[/color][/size][/font][/color][/size][/font][/color][/size][/font]
[font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2]
                   cadquiet = 
[/size][/font]
[/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]False[/color][/size][/font][/color][/size][/font][/color][/size][/font]
[font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2]
               
[/size][/font]
[/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]End[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] [/size][/font][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Try[/color][/size][/font][/color][/size][/font][/color][/size][/font]
[font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2]
           
[/size][/font]
[/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Loop[/color][/size][/font][/color][/size][/font][/color][/size][/font]
[font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][/color][/size][/font][/color][/size][/font][/color][/size][/font]

Posted

ok.. so i got it to work with the following code.. if someone can do better please let me know.. the main thing is to catch the exception and just keep waiting till its ready

[font=Consolas][size=2][font=Consolas][size=2]
 State = MyAcad.GetAcadState

           
[/size][/font]
[/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Do[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] [/size][/font][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Until[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] cadquiet = [/size][/font][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]True[/color][/size][/font][/color][/size][/font][/color][/size][/font]
[font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2]
               
[/size][/font]
[/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Try[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2]

[/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]If[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] State.IsQuiescent [/size][/font][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Then[/color][/size][/font][/color][/size][/font][/color][/size][/font]
[font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2]
                       cadquiet =[/size][/font]
[/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]True[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2]

[/size][/font][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af]Thread[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2].Sleep(1500)[/size][/font][/size][/font][font=Consolas][size=2][font=Consolas][size=2]
[/size][/font]
[/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]End[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] [/size][/font][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]If[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2]

[/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Catch[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] ex [/size][/font][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]As[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] System.IO.[/size][/font][/size][/font][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af]IOException[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2]
                   cadquiet =[/size][/font][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]False[/color][/size][/font][/color][/size][/font][/color][/size][/font]
[font=Consolas][size=2] 
[/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]End[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] [/size][/font][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Try[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2]
[/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Loop[/color][/size][/font][/color][/size][/font][/color][/size][/font]
[font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][/color][/size][/font][/color][/size][/font][/color][/size][/font]

Posted

I knew you were a persistent person. Nice job! :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...