VB CAD插件二次开发
发布时间:2020-12-17 07:43:28 所属栏目:百科 来源:网络整理
导读: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.ShowOpenmyf
<pre name="code" class="vb">Dim acadapp As AcadApplication '在窗体代码声明段定义acadapp Private Sub Command1_Click() acadapp.Documents.Add '创建新的图形文件 End Sub Private Sub Command2_Click() Dim myfilename As String Me.CommonDialog1.ShowOpen myfilename = Me.CommonDialog1.FileName If myfilename <> "" Then acadapp.Documents.Open myfilename End If End Sub Private Sub Command3_Click() Dim savename As String Me.CommonDialog1.ShowSave savename = Me.CommonDialog1.FileName If savename <> "" Then acadapp.ActiveDocument.SaveAs savename End If End Sub Private Sub Command4_Click() If Not acadapp.ActiveDocument.Saved Then If MsgBox("是否保存文件?",vbYesNo) = vbYes Then acadapp.ActiveDocument.Save End If End If End Sub Private Sub Command5_Click() acadapp.ActiveDocument.Close (True) '以当前文件名和路径保存修改后的图形文件,然后关闭文件,若为False则不修改即保存 End Sub Private Sub Form_Load() On Error Resume Next Set acadapp = GetObject(,"autocad.application") If Err Then Err.Clear Set acadapp = CreateObject("autocad.application") If Err Then MsgBox ("不能运行AutoCad,请检查是否安装了CAD") Exit Sub End If End If acadapp.Visible = True End Sub (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |