xys1995 发表于 2006-11-6 16:16:00

如何做一个程序同时支持两个版本的AutoCAD?

请问如何在VB6中做一个画园的程序,使得它可以同时支持AutoCAD2005和AutoCAD2007?

wyj7485 发表于 2006-11-7 08:17:00

打开或获取cad时不要指定版本就可以啊

tcsl9621 发表于 2006-11-7 11:41:00

<P>如下就好了。</P>
<P>Dim obj_Acad As Object<BR>Dim obj_Doc&nbsp; As Object</P>
<P>'''<BR>Sub Main()<BR>On Error Resume Next<BR>Set obj_Acad = GetObject(, "autocad.application")<BR>If Err Then<BR>&nbsp;&nbsp; Err.Clear<BR>&nbsp;&nbsp; On Error Resume Next<BR>&nbsp;&nbsp; Set obj_Acad = CreateObject("autocad.application")<BR>&nbsp;&nbsp; If Err Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Err.Clear<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox "不能运行AutoCAD,请检查是否安装!", vbOKOnly, "警告!"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit Sub<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>End If<BR>obj_Acad.Visible = True<BR>obj_Acad.WindowState = autocad.acwindowstate.acmax<BR>AppActivate (obj_Acad.Caption)<BR>Set obj_Doc = obj_Acad.ActiveDocument<BR>obj_Doc.SendCommand ("(setq p2c::filepath """ + Replace(App.Path, "\", "\\") + "\\"") ")<BR>obj_Doc.SendCommand ("(load (strcat p2c::filepath ""Part2CAM.fas"")) ")<BR>obj_Doc.SendCommand ("(princ) ")<BR>End Sub<BR></P>
页: [1]
查看完整版本: 如何做一个程序同时支持两个版本的AutoCAD?