VB与CAD的连接
我在利用VB开发CAD时,只有一个窗体需要创建CAD对象,我先引用CAD,然后添加了一个窗体,在该窗体的代码窗体输入以下代码,VB中也是通过的,但并没有显示连接到了CAD界面,还是一个空白窗体!请各位帮忙指教一下!!(这段代码是来自一本参考书,但并没有达到效果,很是郁闷!!)dim acadapp as acadapplication
private sub form_load
on error sub resume next
set acadapp=getobject(,"autocad.application")
if err then
err.clear
set acadapp=createobject("autocad.application")
if err then
msgbox("error!")
exit sub
end if
end if
acadapp.visible=ture
end sub
Dim AcadApp As AcadApplication<BR>Dim AcadDoc As AcadDocument<BR>Dim ThisDrawing As AcadDocument<BR>'由工程直接调用启动程序<BR> On Error Resume Next<BR> Set AcadApp = GetObject(, "AutoCAD.Application")<BR> If err > 0 Then<BR> err.Clear<BR> Set AcadApp = CreateObject("AutoCAD.Application")<BR> If err Then<BR> MsgBox err.Description<BR> End<BR> End If<BR> End If<BR> Set AcadDoc = AcadApp.ActiveDocument<BR> Set ThisDrawing = AcadApp.ActiveDocument<BR> AcadApp.Visible = True<BR> On Error Resume Next<BR> ' 交由AutoCAD控制<BR> Me.Hide <BR> ThisDrawing.Application.ZoomAll 呵呵,我想你大概是想把CAD的图形显示窗口当做ACTIVATEX控件来用吧,可惜CAD并不支持。它只能做到库的挂接,具体的显示界面还是CAD本身的。VB所做的只是幕后操控罢了!
页:
[1]