''' Dim obj_Acad As Object Dim obj_Doc As Object
''' Sub Main() On Error Resume Next Set obj_Acad = GetObject(, "autocad.application.16") If Err Then Err.Clear On Error Resume Next Set obj_Acad = CreateObject("autocad.application.16") If Err Then Err.Clear MsgBox "不能运行AutoCAD,请检查是否安装!", vbOKOnly, "警告!" Exit Sub End If End If obj_Acad.Visible = True obj_Acad.WindowState = autocad.acwindowstate.acmax AppActivate (obj_Acad.Caption) Set obj_Doc = obj_Acad.ActiveDocument obj_Doc.SendCommand ("(setq p2c::filepath """ + Replace(App.Path, "\", "\\") + "\\"") ") obj_Doc.SendCommand ("(load (strcat p2c::filepath ""Part2CAM.fas"")) ") obj_Doc.SendCommand ("(princ) ") End Sub 帖回代码,VB可以和各种二次开发工具一同使用。用VB编程打开CAD调用二次开发程序。可以使我们的程序看上去更专业。 |