我式新手,请看下面代码:
Public Sub Command1_Click() On Error Resume Next Set AcadApp = GetObject(, "AutoCAD.Application") If Err Then Err.Clear Set AcadApp = CreateObject("AutoCAD.Application") If Err Then MsgBox ("不能运行AutoCAD2000,请检查是否安装了AutoCAD2000") Exit Sub End If End If
Form1.Hide AcadApp.Visible = True Dim pt1(0 To 2) As Double pt1(0) = 100#: pt1(1) = 100#: pt1(2) = 0# Dim radius As Double radius = 60#
Dim cirobj1 As AcadCircle
Set cirobj1 = Addcir(pt1, radius)
ZoomAll
End Sub
Public Function Addcir(ByVal pt As Variant, ByVal radius As Double) As AcadCircle
Dim cirobj As AcadCircle Dim ptcen(0 To 2) As Double ptcen(0) = pt(0): ptcen(1) = pt(1): ptcen(2) = pt(2)
Set cirobj = AcadApp.ActiveDocument.ModelSpace.AddCircle(ptcen, radius) cirobj.Update Addcir = cirobj
End Function
我是想打开CAD后调用Addcir函数画一个圆,可是怎么不对啊?好像ptcen的值赋不进去,我从立即窗口赋值,还是画不出圆,Addcir是从工具里添加进去的,请高手指点一下嘛, |