.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Interop Activex or .NET API? Which one is recommended?

17 REPLIES 17
SOLVED
Reply
Message 1 of 18
apoorva_jukanti
955 Views, 17 Replies

Interop Activex or .NET API? Which one is recommended?

Hi,

 

My requirement is migrating a desktop application from .vbp to .net. 

Present code in vb is using ActiveX object to launch the autocad application and insert blocks and deal with the block attributes. The major existing project is to use the existing drawing blocks in specific path and modify and replace them.

 

Now while migrating it to .net which is the optimized way(recommended waY) to implement the above mentioned functionality, ActiveX or Autocad .Net API?

Please suggest a viable solution.

17 REPLIES 17
Message 2 of 18
_gile
in reply to: apoorva_jukanti

Hi,

The .NET API is more powerfull but it cannot be directly used as stand-alone executable (exe). See this topic.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 18
apoorva_jukanti
in reply to: _gile

Can you please provide examples of using ActiveX Interop  in C# other than launching autocad application ?  For Example: InsertBlock Method(ActiveX) 

Message 4 of 18
apoorva_jukanti
in reply to: _gile

Is there any possibility of Deprecating ActiveX in future?

As Microsoft might stop supporting VB in future?

 

Message 5 of 18
_gile
in reply to: apoorva_jukanti


@apoorva_jukanti  a écrit :

Can you please provide examples of using ActiveX Interop  in C# other than launching autocad application ?  For Example: InsertBlock Method(ActiveX) 


If you absolutely want to use ActiveX Interop in a .NET plugin (which most AutoCAD .NET developers deprecate), you can simply get the the AcadApplication object from the Application.AcadApplication property.

var acadApp = (AcadApplication)Application.AcadApplication;
var thisDrawing = acadApp.ActiveDocument;
var blockRef = thisDrawing.ModelSpace.InsertBlock(Point3d.Origin.ToArray(), blockName, 1.0, 1.0, 1.0, 0.0);


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 6 of 18
apoorva_jukanti
in reply to: _gile

No, I would like to use .Net API.

But, My requirement is launching autocad from .net (which can be done only using ActiveX) and then use the existing .dwg from a folder and modify them.

 

Can I use ActiveX object for launching Autocad and then use .Net api for modifying the drawing ?

Message 7 of 18
_gile
in reply to: apoorva_jukanti


@apoorva_jukanti  a écrit :

No, I would like to use .Net API.

But, My requirement is launching autocad from .net (which can be done only using ActiveX) and then use the existing .dwg from a folder and modify them.

 

Can I use ActiveX object for launching Autocad and then use .Net api for modifying the drawing ?


You can use the same "ConnectToAcad" method of the example in this topic from a stand-alone executable (without the CommandMethodAttribute).



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 8 of 18
apoorva_jukanti
in reply to: _gile

Can you please tell the valid nuget for using Interop.AutoCAD.dll

Message 9 of 18
_gile
in reply to: apoorva_jukanti

https://www.nuget.org/packages/AutoCAD.NET.Interop



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 10 of 18
apoorva_jukanti
in reply to: _gile

if I install the latest autocad 2025 nuget, i will be able to use lower versions of autocad also right?

Message 11 of 18
apoorva_jukanti
in reply to: _gile

apoorva_jukanti_0-1725620298498.png

it shows it does not support 

Message 12 of 18
_gile
in reply to: apoorva_jukanti


@apoorva_jukanti  a écrit :

if I install the latest autocad 2025 nuget, i will be able to use lower versions of autocad also right?


No. You have to install the package corresponding to the targeted AutoCAD version.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 13 of 18
kdub_nz
in reply to: apoorva_jukanti


@apoorva_jukanti wrote:

apoorva_jukanti_0-1725620298498.png

it shows it does not support 


//

the wording is "provide support"

That means that nuget won't answer questions about the files provided . . . which I think is typical, they just push the files provided by their clients.
sort of like : don't complain to the postman about the bills you get in the mail.


// Called Kerry in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect.
Sometimes the question is more important than the answer.

class keyThumper<T> : Lazy<T>;      another  Swamper

Message 14 of 18
apoorva_jukanti
in reply to: _gile

Is there a way, I can support all versions of autocad? using the AutoCAD.NET.Interop NuGet in my c# code

 

Message 15 of 18
apoorva_jukanti
in reply to: _gile

Can you please provide nuget that supports .net framework4.8 and autocad 2025

Message 16 of 18
_gile
in reply to: apoorva_jukanti

As said upper the COM API is not version compatible.

You have to build separated assembies for each targeted AutoCAD version (at least major version) referencing the corresponding libraries.

.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 17 of 18

@apoorva_jukanti 

Judging by the questions you asked here and in the other forum (ObjectARX), it seems to me that you are probably not very familiar with AutoCAD programming and the various types of AutoCAD APIs that could be used in different scenarios/application types.

 

You might as well provide some detailed description of what type of application you want to develop, some business requirements/workflows...because these things decide if your goal is doable, and if yes, what AutoCAD API should be used. At least people do not have to keep guessing an answer you really want to hear.

 

Norman Yuan

Drive CAD With Code

EESignature

Message 18 of 18

Yes, you can use late binding and dynamic coding styles, this will eliminate the need for hard references.

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report