AutoCAD 插件开发示例 [英] AutoCAD Plugin Development by Example

查看:64
本文介绍了AutoCAD 插件开发示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对开发 AutoCAD 插件感兴趣,并试图了解几种不同类型的 AutoCAD 插件文件之间的关系:

I am interested in developing an AutoCAD plugin and am trying to understand the relationships between several different types of AutoCAD plugin files:

  • 与 AutoCAD 插件一起提供的托管 DLL
  • ARX 文件,随 AutoCAD 插件一起提供
  • CUIX 文件,随 AutoCAD 插件一起提供
  • 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.

听起来就像插件的核心功能应该放在 ARX 文件中,用 C++ 编写并为本地/目标平台编译.

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.

它也听起来,在启动时,AutoCAD 加载其插件 DLL,这些 DLL 都是托管的 .NET 库(通常用 C# 编写),然后它们依次调用其本机/编译的相应 ARX 文件.至于CUIX文件在哪里发挥作用,我仍然不知道.

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.

任何人都可以帮忙解释一下这些关系吗?这些文件的依赖关系,以及其中包含哪些类型的代码/逻辑/数据?提前致谢!

推荐答案

AutoCAD 核心库都是用非托管代码(我相信是 C++)编写的.最终,无论您选择开发插件的 API 是什么,您都将通过它们的 API 之一操作来自这些核心库的非托管 AutoCAD 对象.除了您提到的三种类型的文件之外,还有许多其他方法可以为 AutoCAD 创建插件.一些示例包括:Lisp 脚本、VBA 脚本、COM 客户端(VB、Java、Delphi).其中大部分现在已经过时,而如今 .Net 和 C++(ObjectARX) API 最为流行.但是,由于遗留原因,其余部分仍在使用中.如果您要开始一个新模块,您可以使用 .Net 或 ARX.

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 是一组包装 ObjectARX API 的 .NET 包装库.您将引用的最常见的 dll 是 accoremgd.dllacdbmgd.dllacmgd.dll,但还有其他一些.这些库允许您通过 .NET 语言操作本机 AutoCad 对象.如果您想用 C# 为 AutoCad 创建插件,那么您只需要用 C# 编写代码.它对开发速度很有好处,但你的代码性能会比 ARX 插件差一些.话虽如此,我真的想强调它仍然非常快.由于性能问题,我还没有发现需要在 C++ 中为 AutoCAD 编码.总的来说,它非常强大且功能丰富.仅使用 C# 就可以很好地对绘图进行任何操作.

.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.

看看我最近给出的这个答案.它应该可以回答您在 .Net 中开始使用 AutoCAD 插件开发的大部分问题(如果不是全部的话).

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 与我为 .NET API 描述的非常相似,除了您使用 C++ 编写代码.一些库包括rxapi.libaccore.libacgiapi.libacdrawbridge.lib像其他一些人一样.与使用 C# 相比,使用 C++ 开发要麻烦得多,但 C++ 代码运行速度更快,尽管差距不大.

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 文件生活在一个完全不同的星系中.它们用于自定义 UI 以及其他相关内容.您可以在此处浏览cuix文件的各种用途.

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.

您的选择实际上取决于您正在做什么.如果您正在编写代码以尽可能快地批量处理数十万张图纸,您将需要探索 C++ API.如果您只处理数百幅绘图或只为用户创建一堆命令,我强烈建议您使用 C# API.对用户来说几乎永远不会察觉的性能上的小影响是值得的.

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.

有关更多信息,请转到此 AutoDesk 链接,以及向下滚动到培训实验室.我建议您至少通读 ObjectARX 和 .NET 培训实验室.一旦你选择了你想要使用的东西,就可以通过所有的实验来选择你所选择的一个.稍后您会感谢自己,因为您将省去无数小时的头痛和沮丧!

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!

祝你好运!

这篇关于AutoCAD 插件开发示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆