找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 604|回复: 3

[VBA程序]:请问在VB例如和设置VBA开发环境?

[复制链接]
发表于 2002-9-18 10:23:47 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
CAD里的VBA(IDE)不能用,请问在VB例如和设置?
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2002-9-18 10:38:58 | 显示全部楼层
不用设置,引用一下库后直接用即可。
you must first reference the AutoCAD type library. To do this in VB, select the References option from the Project menu to launch the Reference dialog box. From the References dialog box, choose AutoCAD Type Library, and then press OK.

例程:

  1. [FONT=courier new]
  2. Sub Ch2_ConnectToAcad()
  3.     Dim acadApp As AcadApplication
  4.     On Error Resume Next
  5.    
  6.     Set acadApp = GetObject(, "AutoCAD.Application")
  7.     If Err Then
  8.         Err.Clear
  9.         Set acadApp = CreateObject("AutoCAD.Application")
  10.         If Err Then
  11.             MsgBox Err.Description
  12.             Exit Sub
  13.         End If
  14.     End If
  15.     MsgBox "Now running " + acadApp.Name + _
  16.            " version " + acadApp.Version
  17. End Sub
  18. [/FONT]


VB与VBA程序比较

VBA:

  1. [FONT=courier new]
  2. Sub Ch2_AddLineVBA()
  3.     ' This example adds a line
  4.     ' in model space
  5.     Dim lineObj As AcadLine
  6.     Dim startPoint(0 To 2) As Double
  7.     Dim endPoint(0 To 2) As Double
  8.    
  9.     ' Define the start and end
  10.     ' points for the line
  11.     startPoint(0) = 1
  12.     startPoint(1) = 1
  13.     startPoint(2) = 0
  14.     endPoint(0) = 5
  15.     endPoint(1) = 5
  16.     endPoint(2) = 0
  17.    
  18.     ' Create the line in model space
  19.     Set lineObj = ThisDrawing. _
  20.         ModelSpace.AddLine _
  21.         (startPoint, endPoint)
  22.         
  23.     ' Zoom in on the newly created line
  24.     ZoomAll
  25. End Sub
  26. [/FONT]


VB:

  1. [FONT=courier new]
  2. Sub Ch2_AddLineVB()
  3.     On Error Resume Next
  4.    
  5.     ' Connect to the AutoCAD application
  6.     Dim acadApp As AcadApplication
  7.     Set acadApp = GetObject _
  8.                   (, "AutoCAD.Application")
  9.     If Err Then
  10.         Err.Clear
  11.         Set acadApp = CreateObject _
  12.                   ("AutoCAD.Application")
  13.         If Err Then
  14.             MsgBox Err.Description
  15.             Exit Sub
  16.         End If
  17.     End If
  18.    
  19.     ' Connect to the AutoCAD drawing
  20.     Dim acadDoc As AcadDocument
  21.     Set acadDoc = acadApp.ActiveDocument
  22.    
  23.     ' Establish the endpoints of the line
  24.     Dim lineObj As AcadLine
  25.     Dim startPoint(0 To 2) As Double
  26.     Dim endPoint(0 To 2) As Double
  27.     startPoint(0) = 1
  28.     startPoint(1) = 1
  29.     startPoint(2) = 0
  30.     endPoint(0) = 5
  31.     endPoint(1) = 5
  32.     endPoint(2) = 0
  33.     ' Create a Line object in model space
  34.     Set lineObj = acadDoc.ModelSpace.AddLine _
  35.                          (startPoint, endPoint)
  36.     ZoomAll
  37.     acadApp.visible = True
  38. End Sub
  39. [/FONT]
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2002-9-18 10:58:05 | 显示全部楼层
谢谢秋枫,
我是指在VB开发界面里如何设置AUTOTCAD 2000 VBA的开发环境?
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2002-9-18 10:59:02 | 显示全部楼层
看一下顶上那一段英文啊。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2025-9-6 16:25 , Processed in 0.372722 second(s), 36 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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