.NET

.NET

Reply
Contributor
phives
Posts: 22
Registered: ‎08-25-2012
Message 1 of 6 (298 Views)

Issue when creating an AutoCAD object and ActiveX.

298 Views, 5 Replies
09-04-2012 10:36 AM

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.

*Expert Elite*
arcticad
Posts: 1,286
Registered: ‎06-21-2004
Message 2 of 6 (294 Views)

Re: Issue when creating an AutoCAD object and ActiveX.

09-04-2012 10:56 AM in reply to: phives

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

 

---------------------------



(defun botsbuildbots() (botsbuildbots))
Contributor
phives
Posts: 22
Registered: ‎08-25-2012
Message 3 of 6 (285 Views)

Re: Issue when creating an AutoCAD object and ActiveX.

09-04-2012 11:25 AM in reply to: phives
        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.

New Member
pbhonl
Posts: 2
Registered: ‎01-25-2012
Message 4 of 6 (244 Views)

Re: Issue when creating an AutoCAD object and ActiveX.

09-06-2012 04:57 AM in reply to: phives

Check out this MS article.  I had the same problem until I implemented this...

 

http://msdn.microsoft.com/en-us/library/ms228772(VS.80).aspx

 

 

Contributor
phives
Posts: 22
Registered: ‎08-25-2012
Message 5 of 6 (229 Views)

Re: Issue when creating an AutoCAD object and ActiveX.

09-07-2012 06:27 AM in reply to: phives

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.

New Member
pbhonl
Posts: 2
Registered: ‎01-25-2012
Message 6 of 6 (200 Views)

Re: Issue when creating an AutoCAD object and ActiveX.

09-10-2012 05:30 AM in reply to: phives

Scroll down to the bottom of the MS Page and grab the VB code.  Paste it into a class module.

 

http://msdn.microsoft.com/en-us/library/ms228772(v=vs.80).aspx

 

 

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"

 

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.