vbyu1987 发表于 2013-5-3 09:41:00

设置当前文档

public sub activedocument()
      dim olddoc as acaddocument
      set olddoc=thisdrawing.application.activedocument
      if Len(Dir("c:\test.dwg"))0 then
                thisdrawing.application.documents.open "c:\test.dwg"
      else
                msgbox "指定的文件不存在"
      end if
      thisdrawing.application.activedocument=olddoc
end sub
请教一下,如果当时CAD打开一个文件A.dwg, 然后运行这个VBA程序,C盘下也有test.dwg
那运行之后的效果是什么,test.dwg 是当前文档还是A.dwg
一本教材上的,看不大懂

vbyu1987 发表于 2013-5-3 10:06:00

Public Sub openDialog()
    Dim strFileName As String
    '确保USERS1系统变量为空
    thisDrawing.SetVariable "USERS1", ""
    '显示"选择文件"对话框,并且获得用户选择的结果
    thisDrawing.sendcommand "(setvar "&" ""USERS1"""&"(getfield "&"""选择图形文件"""&"""d:/"""dwg"""&"8))"
    strFileName = thisDrawing.GetVariable("USERS1")
    '显示选择结果
    If Len(strFileName) = 0 Then
      MsgBox "为选择任何图形文件", vbInformation, "选择结果"
    Else
      MsgBox "选择的文件是:" & strFileName, vbInformation, "选择结果"
    End If
End Sub
红色的那句话是什么意思啊,那么多引号

vbyu1987 发表于 2013-5-3 14:52:00

没有人回答一下?
页: [1]
查看完整版本: 设置当前文档