.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Opening/Adding Acad document - 2005 vs 2006?

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
274 Views, 4 Replies

Opening/Adding Acad document - 2005 vs 2006?

Is there something I'm missing between 2005 and 2006? I've got a batch
processor that checks to see if an acad session is running and if so open a
document in that session and if its not running, open AutoCAD and then open
a document. The simple code works fine in AutoCAD 2005, but not with 2006.

This is my sub for detecting the acad session:

Imports Autodesk.AutoCAD.Interop.Common
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.AcadPlotClass

Sub DetectAcadSession()
blnAcadExist = False
' Check to see if Acad is open
On Error Resume Next
acad = GetObject(, "autocad.application") 'try to get the app object
If Err().Number <> 0 Then 'if not then create a new
one
blnAcadExist = False
acad = New AcadApplication
Else
blnAcadExist = True
End If
Err().Clear()
ACADVer = acad.Version.ToString() 'save acad version for later
End Sub


This is the code I use to Open a document:

dwg = acad.Documents.Open(strDwgs(i), False) 'strDwgs(i) is valid

If I step through the code using AutoCAD 2006, it works. If I just run it,
I get "Call Rejected by Callee".
Any help or tips would be greatly appreciated!
4 REPLIES 4
Message 2 of 5
temerson
in reply to: Anonymous

Did you ever get any response to the issue you are experiencing. I'm having the exact same issue. I have also tested it in debug mode and it works but compiled mode it does not. The same code has worked for AutoCAD 2004 & 2005 but is broken in 2006. Thanks for any help you can give me...
Message 3 of 5
temerson
in reply to: Anonymous

I was able to get my code running by looping until autocad is idle then open the file. The following example is for VB 6.0

' GET AUTOCAD STATE. NOTE: AutoCAD.AcadState OBJECT
Set oState = oApp.GetAcadState
If Not oState Is Nothing Then
Do While oState.IsQuiescent = False
DoEvents
Loop
End If
Message 4 of 5
Anonymous
in reply to: Anonymous

And here's what I used in .NET:

Dim AcState As AcadState
Dim blnAcState As Boolean = False

While blnAcState = False
AcState = acad.GetAcadState
If AcState.IsQuiescent Then
blnAcState = True
End If
End While

Same solution, basically...

wrote in message news:4882190@discussion.autodesk.com...
I was able to get my code running by looping until autocad is idle then open
the file. The following example is for VB 6.0

' GET AUTOCAD STATE. NOTE: AutoCAD.AcadState OBJECT
Set oState = oApp.GetAcadState
If Not oState Is Nothing Then
Do While oState.IsQuiescent = False
DoEvents
Loop
End If
Message 5 of 5
Anonymous
in reply to: Anonymous

Sometimes you just have to poke around a bit
to find the managed API equivalent:

Autodesk.AutoCAD.ApplicationServices.Application.IsQuiescent

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"pkirill" wrote in message news:4882466@discussion.autodesk.com...
And here's what I used in .NET:

Dim AcState As AcadState
Dim blnAcState As Boolean = False

While blnAcState = False
AcState = acad.GetAcadState
If AcState.IsQuiescent Then
blnAcState = True
End If
End While

Same solution, basically...

wrote in message news:4882190@discussion.autodesk.com...
I was able to get my code running by looping until autocad is idle then open
the file. The following example is for VB 6.0

' GET AUTOCAD STATE. NOTE: AutoCAD.AcadState OBJECT
Set oState = oApp.GetAcadState
If Not oState Is Nothing Then
Do While oState.IsQuiescent = False
DoEvents
Loop
End If

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost