VB6 / Autocad 2021

VB6 / Autocad 2021

informatica_riphorsa_com
Explorer Explorer
995 Views
11 Replies
Message 1 of 12

VB6 / Autocad 2021

informatica_riphorsa_com
Explorer
Explorer

I have a program in VB6 working in Autocad 2019, and I want to migrate to Autocad 2021.

If I change the code in CreateObject and GetObject from AutoCAD.Application.23 to AutoCAD.Application.24, and I change references from 2019 to 2021 in the project, the program stops trying to connect to Autocad 2021 but doesnt work.

Any idea about the problem?

 

0 Likes
996 Views
11 Replies
Replies (11)
Message 2 of 12

Ed__Jobe
Mentor
Mentor

The class id for 2021 is 24.0. To see the class id for versions you have installed, open Regedit and go to HkeyClassesRoot and scroll down to AutotoCAD.Application.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 3 of 12

informatica_riphorsa_com
Explorer
Explorer

I tried with AutoCAD.Application.24.0  as your suggestion, and didnt work.

 

Also If I see in my computer, the class id is 23 for Autocad 2019 and 24 for Autocad 2021, so I think I need to put 

AutoCAD.Application.24, but doesn work.

 

informatica_riphorsa_com_0-1700672353743.png

 

0 Likes
Message 4 of 12

Ed__Jobe
Mentor
Mentor

Have you tried setting a breakpoint in your code and examining variables while stepping through your code? Do you get any errors? Can you post your code?

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 5 of 12

informatica_riphorsa_com
Explorer
Explorer

I post the code in 2021:

 

Dim ObjACAD As AutoCAD.AcadApplication

On Error GoTo newACAD
Set ObjACAD = GetObject(, "AutoCAD.Application.24")

newACAD:
If ObjACAD Is Nothing Then
Set ObjACAD = CreateObject("AutoCAD.Application.24")
ObjACAD.Visible = True
ObjACAD.WindowState = 2
End If

 

And references:

 

informatica_riphorsa_com_0-1700763475929.png

 

If I debug in 2019 (same code changing to .23 and Autocad 2019 references), I have:

 

informatica_riphorsa_com_1-1700763562434.png

But if I try in 2021, the program freeze and finally I have this error in CreateObject:

informatica_riphorsa_com_2-1700763767097.png

Any idea?

 

 

 

0 Likes
Message 6 of 12

Ed__Jobe
Mentor
Mentor

Have you installed VBA for 2021? Open 2021 and enter VBAMAN and see if you get an error. Also, I don't know what AxDbLib is. It should look like the image below.

acad references.png

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 7 of 12

informatica_riphorsa_com
Explorer
Explorer

If I execute the same 2021 code from Excel VBA instead Visual Basic 6.0, its works.

If I execute the same 2019 code works in both, Excel VBA and Visual Basic 6.0.

Do you know if is any problem to work in Visual Basic 6.0 with Autocad 2021?

0 Likes
Message 8 of 12

Ed__Jobe
Mentor
Mentor

You didn't answer my previous questions.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 9 of 12

informatica_riphorsa_com
Explorer
Explorer

VBA is installed (the code is working in Excel VBA), only not works with VB6.

 

AxDbLib is ObjectDBX

 

Reference=*\G{AA9A2205-75AA-43AD-9138-1767F1BB5E0C}#1.0#0#..\..\..\..\..\Program Files\Common Files\Autodesk Shared\acax24enu.tlb#AutoCAD 2021 Type Library
Reference=*\G{39FFAA00-8623-488F-8C53-DD3B0B7A464F}#1.0#0#..\..\..\..\..\Program Files\Common Files\Autodesk Shared\axdb24enu.tlb#AXDBLib

 

informatica_riphorsa_com_1-1701705831077.png

 

 

0 Likes
Message 10 of 12

Ed__Jobe
Mentor
Mentor

@informatica_riphorsa_com wrote:

VBA is installed (the code is working in Excel VBA), only not works with VB6.


 

Just because you have Excel vba working doesn't mean that you've installed vba for acad. You can test it by entering the VBAMAN command in acad. You will get an error message if it's not installed. It has to be installed for each version of acad that you have. The version of vba for 2019 is different than the version for 2021.

 

 

@informatica_riphorsa_com wrote:

AxDbLib is ObjectDBX


I was expecting to see it named different, as shown in my last picture. Possibly that is just the difference in the Spanish version. They both seem to be pointing to the same tlb file.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 11 of 12

informatica_riphorsa_com
Explorer
Explorer

informatica_riphorsa_com_0-1701708727208.png

0 Likes
Message 12 of 12

Ed__Jobe
Mentor
Mentor

It looks good so far. What program are you using to compile vb6? I know that VBA is at version 7.1. Maybe there is an incompatibility with your vb6 code and vba 7.1 running in acad 2021? Can you use an updated current IDE to compile an exe? Perhaps move to Visual Studio Community edition to create an exe instead of vb6. I haven't used vb6 in probably 20-25 years.

 

You aren't using the same exe to connect to both 2019 and 2021 are you?

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes