Unable to get AutoCAD object using 'GetObject' method using VB6

Unable to get AutoCAD object using 'GetObject' method using VB6

cadsindiaadn
Enthusiast Enthusiast
2,580 Views
2 Replies
Message 1 of 3

Unable to get AutoCAD object using 'GetObject' method using VB6

cadsindiaadn
Enthusiast
Enthusiast

Hi,

 We have a few legacy VB6 projects, in which we try to get the AutoCAD object from the below sample code:

 

On Error Resume Next

Public AcadApp As Object

Set objApp = GetObject(, "AutoCAD.Application")

If Err Then

Err.Clear

Set objApp = GetObject(, "AutoCAD.Application.20")

End If

If Err Then

Err.Clear

Set objApp = GetObject(, "AutoCAD.Application.21")

End If

 

This code was working perfect, right from AutoCAD 2005 till AutoCAD 2017, when the code was finally compiled in Win 7.

 

Now when we compiled the same source, the 'GetObject' method fails to create an instance of the AutoCAD object.

The error code is 429 "ActiveX component can't create object".

We are using x64 version AutoCAD 2015, 2016 and 2017 and the OS is Windows 10.

 

 

Whereas the 'CreateObject' method creates the AutoCAD objects perfectly.

Set AcadApp = CreateObject("AutoCAD.Application.20")

 

It would be helpful if you could resolve this ASAP.

 

regards,

CADSINDIAADN

0 Likes
2,581 Views
2 Replies
Replies (2)
Message 2 of 3

norman.yuan
Mentor
Mentor

You probably know this. but since you did not mention, I ask anyway:

 

For all the ... GetObject(, "AutoCAD.Application...") method calls, when the exception 429 is raised, you are sure there is an AutoCAD instance running, aren't you?

 

Usually, the Program ID "AutoCAD.Application" in the GetObject()/CreateObject() does not need to have version suffix, unless the running computer has multiple AutoCAD installed and you need/prefer a certain version (but in this case, you'd test specific version first, then next preferred version, and then eventually the generic "AutoCAD.Application", meaning "whatever AutoCAD version, give me or create me an instance").

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 3

cadsindiaadn
Enthusiast
Enthusiast

Yes. I always tried keeping AutoCAD running. We do use multiple AutoCAD versions. I tried getting the specific version first and then the generic version later. But couldn't get a positive result.

0 Likes