VB CAD插件二次开发

来源:互联网 发布:mac微信无法强制退出 编辑:程序博客网 时间:2024/05/05 14:20
<pre name="code" class="vb">Dim acadapp As AcadApplication   '在窗体代码声明段定义acadappPrivate Sub Command1_Click()acadapp.Documents.Add  '创建新的图形文件End SubPrivate Sub Command2_Click()Dim myfilename As StringMe.CommonDialog1.ShowOpenmyfilename = Me.CommonDialog1.FileNameIf myfilename <> "" Then    acadapp.Documents.Open myfilenameEnd IfEnd SubPrivate Sub Command3_Click()Dim savename As StringMe.CommonDialog1.ShowSavesavename = Me.CommonDialog1.FileNameIf savename <> "" Then    acadapp.ActiveDocument.SaveAs savenameEnd IfEnd SubPrivate Sub Command4_Click()If Not acadapp.ActiveDocument.Saved Then    If MsgBox("是否保存文件?", vbYesNo) = vbYes Then        acadapp.ActiveDocument.Save    End IfEnd IfEnd SubPrivate Sub Command5_Click()acadapp.ActiveDocument.Close (True)  '以当前文件名和路径保存修改后的图形文件,然后关闭文件,若为False则不修改即保存End SubPrivate Sub Form_Load()On Error Resume NextSet acadapp = GetObject(, "autocad.application")If Err Then    Err.Clear    Set acadapp = CreateObject("autocad.application")    If Err Then        MsgBox ("不能运行AutoCad,请检查是否安装了CAD")        Exit Sub    End IfEnd Ifacadapp.Visible = TrueEnd Sub


                                             
0 0
原创粉丝点击