明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 4326|回复: 2

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

[复制链接]
发表于 2006-4-14 08:41 | 显示全部楼层 |阅读模式

我现在用AutoCAD2004+vb.net(2003),没有用objectarx,这样如何在通过vb.net编程在CAD中画直线啊??? 

其实不光是直线,因为我是刚接触了,所以很多都不懂啊,如果您有画其他图形的代码,能否让我参考一下 ,万分感谢啊!!!!

发表于 2006-5-12 09:11 | 显示全部楼层

推荐一本书: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()

发表于 2006-12-30 14:59 | 显示全部楼层
这和VB创建一条直线不是一样吗?为什么不用objcet arx库          我QQ420021327  一同计论vb.net进行CAD二次开发
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-2 23:51 , Processed in 0.766946 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表