关于VB.net使用ActiveX开发AutoCAD
我查了一些期刊文章,上面用VB.net二次开发的好几篇都是用ActiveX接口进行的。我要实现的功能很简单,就是画几个圆,连线,做标注。我想用ActiveX更方便吧?
我现在糊涂的是,由于VB.net和VBA语法结构不一样,那么我该看什么书,VBA的书,然后自己将VB代码转换为.net代码吗?
是想由程序调用AutoCAD,并不是在AutoCAD当中调出程序。
看得有点糊涂,你到底想用哪个开发,vba vb 还是 vb.net? vb.net还用什么ActiveX呀,直接用多方便
是这样的,我的目标客户大多安装的是AutoCAD2004版本,另外实现的功能也很简单,就是输出到CAD窗口几个图形,几个标注,无须交互。感觉VB开发的速度更快一些,能借到的书也比较多。.Net API开发,论坛的例子大多是C#的,我阅读起来有些困难。
不知我这样想是否正确?
经过2天的查找,问题已经得到解决,最终在Autodesk官方的.net开发文档中找到了答案。
这个是官方回答:
When you develop a new application, it can either run in or out-of-process. The AutoCAD .NET API is designed to run in-process only, which is different from the ActiveX Automation library which can be used in or -out-of-process.
......
If you need to create a stand-alone application to drive AutoCAD, it is best to create an application that uses the CreateObject and GetObject methods to create a new instance of an AutoCAD application or return one of the instances that is currently running. Once a reference to an AcadApplication is returned, you can then load your in-process .NET application into AutoCAD by using the SendCommand method that is a member of the ActiveDocument property of the AcadApplication.
简单的说.NET API 开发技术是专用于CAD进行“内部控制”的。而我需要实现的是一个通过外部程序控制CAD绘图的东西,目前仍然只有ActiveX Automation可以实现这一点,所以我这种开发要求,还是只能通过VBA来实现。
(可能理解的还有偏差,如果有错请大家指出)
(此回复中的VBA不准确,准确的是VB.net+Com类实现,因为程序内部的变量,与其说再找方法传递入Dll,还不如用VBA技术简单的解决掉,反正应用范围也不复杂)
你的理解没错,而且想用netapi都没法,2005以上的版本才支持
好像张晋西有本VB.net的二次开发书,是关于Com接口的,你可以找下
我用C#2005使用ActiveX开发AutoCAD只能对CAD控制,但想与CAD交互,怎么实现?必须用ObjectARX吗?
页:
[1]