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

查看:1112
本文介绍了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:

  • 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,它们都是托管的.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 ++ for 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天全站免登陆