I have code to create an object within a Try block. Specifically an AutoCAD object. What is strange is that sometimes it works and others it throws a Cannot create ActiveX object. What is really peculiar is that it indeed opens AutoCAD (I see in the task manager). It's like there is some kind of delay when establishing the connection and VB can't really cope with this Frankly I am at a total loss.
You may need to wait until it's ready to accept the command.
Imports System.Threading Public Class isQuiescent Public Function isQuiescent(ByRef AcadApp As Autodesk.AutoCAD.Interop.AcadApplication) As Boolean Try While Not AcadApp.GetAcadState.IsQuiescent Thread.Sleep(100) End While Catch ex As Exception End Try Return True End Function End Class
Try AcadApp = GetObject(, "AutoCAD.Application.18") Catch ex As Exception AcadApp = CreateObject("AutoCAD.Application.18") End Try
Where would you call that function? After the CreateObject.
Check out this MS article. I had the same problem until I implemented this...
Thanks for the info. However, I have no idea how to implement this in the context of my standalone app using VB2010.
Would you be so kind as to provide am details of how you did this.
Scroll down to the bottom of the MS Page and grab the VB code. Paste it into a class module.
Before your code to get or start AutoCAD use this command: "MessageFilter.Register"
Add the end of you start AutoCAD code use this command: "MessageFilter.Revoke"