bihumanbu 发表于 2006-4-27 17:59:00

帮我看一段程序吧

<P>这段程序为绘制一个圆让后生成面域,但是我调试的时候只能绘出圆&nbsp; ,到生成面域时出错:"时实错误426".请高人指点,谢谢!</P>
<P>Const pi = 3.1415926<BR>Dim r As Double<BR>Dim Acadapp As AutoCAD.AcadApplication<BR></P>
<P>Private Sub Command4_Click()<BR>Call drwPicture<BR>End Sub<BR>&nbsp;'绘制面域<BR>&nbsp;Sub drwPicture()<BR>&nbsp;Call linkCad<BR>&nbsp;Dim curves(0) As AutoCAD.AcadEntity<BR>&nbsp;Dim centerpoint(2) As Double<BR>&nbsp;r = 600<BR>&nbsp;centerpoint(0) = 0: centerpoint(1) = 0: centerpoint(2) = 0<BR>&nbsp; Set curves(0) = Acadapp.ActiveDocument.ModelSpace.AddCircle(centerpoint, r)<BR>&nbsp; Dim obj As Object<BR>&nbsp;obj = Acadapp.ActiveDocument.ModelSpace.AddRegion(curves)<BR>&nbsp;<BR>&nbsp;End Sub</P>
<P>'建立与cad连接<BR>Sub linkCad()<BR>On Error Resume Next<BR>&nbsp; Set Acadapp = GetObject(, " AutoCAD.Application")<BR>&nbsp; If Err Then<BR>&nbsp;&nbsp;&nbsp; Err.Clear<BR>&nbsp;&nbsp;&nbsp; Set Acadapp = CreateObject("AutoCAD.Application")<BR>&nbsp;&nbsp;&nbsp; If Err Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox Err.Description<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit Sub<BR>&nbsp;&nbsp;&nbsp; End If<BR>&nbsp; End If<BR>&nbsp; Acadapp.Visible = True<BR>&nbsp;&nbsp; Acadapp.WindowState = AutoCAD.AcWindowState.acMax<BR>End Sub<BR></P>

雪山飞狐_lzh 发表于 2006-4-27 18:34:00

AddRegion函数的返回值是实体数组,而不是Object

bihumanbu 发表于 2006-4-27 22:03:00

<P>要怎么呢?我是新手,谢谢</P>
页: [1]
查看完整版本: 帮我看一段程序吧