Cannot link .NET code to Autocad 2014.

Cannot link .NET code to Autocad 2014.

Anonymous
Not applicable
1,664 Views
4 Replies
Message 1 of 5

Cannot link .NET code to Autocad 2014.

Anonymous
Not applicable

I had a Visual Basic .NET 2013 code, which connected to Autocad 2008 32 bit, and worked flawlessly.

 

But when I try to compile it in Visual Basic 2015, connecting to Autocad 2014 64 bit, it does not compile.

 

I removed COM references, and tried to add the references to "Autocad 2014 Type Library" and "Autocad/ObjectDBX Common 19 Type Library", I have many different choices, which seem to be related to different languages (Why different languages? I only use English).

 

Anyways, I choose the ones whose files end in *enu.tlb, because I guess those are for English.

 

When I choose one, two are selected.

 

referencias.jpg

 

But after that, I cannot compile. The line "Imports Autodesk.AutoCAD.Interop.Common" gives me this error:

 

namespace.jpg

 

If I try to add  Autocad Namespace

 

cosa.jpg

 

I still get the error 'Autodesk.AutoCAD.Interop.AcadApplication' is not defined.

 

But if I also add AXDBLib namespace, then I get errors like 'AcadLWPolyline' is ambiguous, imported from the namespaces or types 'AXDBLib, AutoCAD'

 

I'm desperate. I no more know how to link my code to Autocad. What should I do?

0 Likes
1,665 Views
4 Replies
Replies (4)
Message 2 of 5

Darin.Green
Mentor
Mentor

The issue is coming from 2008 to 2014... There was a number of changes to the API over those releases which you'll need to correct in the code before it will compile.



If this information was helpful, please consider using the Accept Solution


0 Likes
Message 3 of 5

Anonymous
Not applicable

What are those changes? there is a link?

0 Likes
Message 4 of 5

Darin.Green
Mentor
Mentor

I don't have links for each version, but again with each release the api changes... Below is a link to the changes from 2013 to 2014:

 

AutoCAD 2014 API Changes



If this information was helpful, please consider using the Accept Solution


0 Likes
Message 5 of 5

norman.yuan
Mentor
Mentor

Well, your issue (namespace "Autodesk.AutoCAD.Interop" is not defined) is not because of possible API changes, as suggested in the other reply.

 

There are 2 ways to add refernces to AutoCAD's COM interop:

 

1. Use AutoCAD COM API assemblies supplied by Autodesk, either downloaded from ObjectARX SDK, or the ones in AutoCAD installation folder (Audesk.AutoCAD.Interop.dll/Autodesk.AutoCAD.Interop.Common.dll). In this case, the referenced DLL's "Copy Local" property must be set to "False". The namespace "Autodesk.AutoCAD.Interop...." ONLY exists in Autodesk provided COM Interop assemblies.

 

2. Use VisualStudio's Add Refernces Dialog box->Com tab. This is what you did. In this case, Visual Studio generates the COM interop assembly from AutoCAD's COM type library, usually, the generated assemblies are "Interop.AXDBLib.dll" and "Interop.AutoCAD.dll, thus, the corresponding namespace is "AXDBLib" and "AutoCAD". Note, in this case, the "Copy Local" property of the 2 referenced DLL must be set to "True" (i.e. these 2 DLLs must go with your custom DLL).

 

While the 2 methods would result in the same effect to your project, I'd recommend you use AutoCAD interop assemblies supplied by Autodesk.

 

HTH

Norman Yuan

Drive CAD With Code

EESignature