问题
I am interested in developing an AutoCAD plugin and am trying to understand the relationships between several different types of AutoCAD plugin files:
- Managed DLLs that ship with AutoCAD plugins
- ARX files that ship with AutoCAD plugins
- CUIX files that ship with AutoCAD plugins
From what I can tell these three files are all inter-related and work together to initialize and load a plugin, I'm just not seeing the forest through the trees as to what information each file type contains, which files loads or depends on the others, etc.
It sounds like a plugin's core functionality is supposed to go inside the ARX file, and written in C++ and compiled for the native/target platform.
It also sounds like, at startup, AutoCAD loads its plugin DLLs, which are all managed .NET libraries (typically written in C#), and in turn they invoke their native/compiled respective ARX files. As to where the CUIX file comes into play, I still have no idea.
Can anyone help explain the relatioships & dependencies of these files, and what types of code/logic/data goes inside of them? Thanks in advance!
回答1:
AutoCAD core libraries are all written in unmanaged code (C++ I believe). Ultimately, whatever API you choose to develop your plugins, you will be manipulating the unmanaged AutoCAD objects from those core libraries via one of their APIs. Aside from the three types of files you mentioned, there is a number of other ways to create plugins for AutoCAD. Some examples include: Lisp Scripting, VBA Script, COM Clients (VB, Java, Delphi). Most of these are now outdated, and these days the .Net and C++(ObjectARX) APIs are most popular. However, the rest are still in use for legacy reasons. If you're starting a new module, you would use either .Net or ARX.
.NET API is a set of .NET wrapper libraries that wrap the ObjectARX API. Most common dlls you would reference are accoremgd.dll
, acdbmgd.dll
and acmgd.dll
, but there are others. These libraries allow you to manipulate native AutoCad objects though a .NET language. If you would like to create plug-ins for AutoCad in C#, then you only need to code in C#. It is great for development speed, but the performance of your code will be somewhat inferior to ARX plugins. That being said, I really want to emphasize that it is still damn fast. I have not found the need to code in C++ for AutoCAD due to performance issues. Overall it is very powerful and feature rich. You can do pretty well anything to a drawing using C# only.
Have a look at this answer I gave recently. It should answer most if not all your questions about getting started with AutoCAD plug-in development in .Net.
ObjectARX API is very similar to what I described for the .NET API, except you code in C++. Some of the libraries include rxapi.lib
, accore.lib
, acgiapi.lib
, acdrawbridge.lib
as well as some others. Development using C++ is considerably more cumbersome than when using C#, but C++ code runs faster, although not by a large margin.
CUIX files live in a whole different galaxy. They are used for customizing the UI among other related things. You can browse various uses of cuix files here.
Your choice will really come down to what you are doing. If you are writing code that will batch process hundreds of thousands of drawings as fast as possible, you will want to explore the C++ API. If you are processing just hundreds of drawings or just creating a bunch of commands for users, I would vehemently urge you to use the C# API. It is worth the small hit in performance that will almost never be perceptible to the user.
For more information, go to this AutoDesk link, and scroll down to the training labs. I would recommend that you at least read through both ObjectARX and .NET Training labs. Once you choose what you want to use, go through all the labs for the one of your choice. You will thank yourself later as you will save countless hours of headache and frustration!
Good Luck!
来源:https://stackoverflow.com/questions/47717868/autocad-plugin-development-by-example