'整个程序中用到的全局变量
Public acadAPP As AcadApplication
Public ThisDrawing As AcadDocument
Public moSpace As AcadModelSpace
Public viewPort As AcadViewport
Public Pi As Double
Public originPoint(0 To 2) As Double
Sub Main()
'一些用到的常量
 i = 3.1415926
'进入主程序
frmMain.Show
End Sub
Public Sub Link_AutoCad()
'本模块与CAD连接,初始化cad>文件>图纸/模型空间变量
On Error Resume Next
Set acadAPP = GetObject(, "AutoCAD.Application")
If Err Then
Err.Clear
Set acadAPP = CreateObject("AutoCAD.Application")
If Err Then
MsgBox Err.Description
Exit Sub
End If
End If
acadAPP.Visible = True
Set ThisDrawing = acadAPP.ActiveDocument
Set moSpace = ThisDrawing.ModelSpace