独孤雪 发表于 2006-4-14 08:41:00

急!!!如何用vb.net在autocad中画直线啊??

我现在用2004+vb.net(2003),没有用objectarx,这样如何在通过vb.net编程在CAD中画直线啊???
其实不光是直线,因为我是刚接触了,所以很多都不懂啊,如果您有画其他图形的代码,能否让我参考一下 ,万分感谢啊!!!!

quren 发表于 2006-5-12 09:11:00

推荐一本书:visual basic .net二次开发 AutoCAD,清华大学出版社
画图之前,先添加引用autocad 2004 type library 及
然后连接autocad
Imports Autodesk
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common
      Dim cadApp As AcadApplication
      '获得应用程序进程
      cadApp = GetObject(, "AutoCAD.AcadApplication")
      If Err.Number Then
            Err.Clear()
            Try
                '定义一个进程
                Dim cadprocess As New Process
                '进程启动可执行文件
                'cadprocess.Start("D:\Program Files\AutoCAD 2006\acad.exe")
                '创建应用程序进程
                cadApp = CreateObject("AutoCAD.AcadApplication")
            Catch ex As Exception
                If Err.Number Then
                  MsgBox("不能启动AutoCAD,请检查是否安装!或文件路径是否正确!")
                End If
            End Try
            '软件可见
            'cadApp.Visible = True
            '软件成最大化状态
            'cadApp.WindowState = Common.AcWindowState.acMax
            '显示软件界面
            'AppActivate(cadApp.Caption)
      End If
   cadApp.Documents.Add()
      Dim newline As AcadLine
      Dim spoints(2), epoints(2) As Double
      spoints(0) = 0 : spoints(1) = 100
      epoints(0) = 0 : epoints(1) = 100
      newline = cadApp.ActiveDocument.ModelSpace.AddLine(spoints, epoints)
      cadApp.ZoomAll()

houlinbo 发表于 2006-12-30 14:59:00

这和VB创建一条直线不是一样吗?为什么不用objcet arx库          我QQ420021327一同计论vb.net进行CAD二次开发
页: [1]
查看完整版本: 急!!!如何用vb.net在autocad中画直线啊??