关闭指定的图形或所有打开的图形。 支持的平台:仅窗口 签名工 务 局: object.Close [SaveChanges] [, FileName]
返回值(RetVal)无返回值。 言论如果图形没有更改,则忽略。如果对图形进行了更改,则指定是否应保存更改。参数的默认值为。SaveChangesFileNameSaveChangesSaveChangesTrue
在 MDI 模式下从文档集合调用此方法将关闭所有打开的图形。若要关闭单个图形,请从要关闭的图形调用此方法。 不能从该图形的事件处理程序内部关闭图形。 注意:关闭图形会破坏对象。切勿在对象被销毁或在这种情况下关闭后尝试引用对象。进程内客户端(VBA 宏)可能会注意到,在退出子例程之前,不会销毁对象。但是,根本不建议引用已销毁的对象,即使在进程内代码中也是如此。Document
例子工 务 局: Sub Example_Close()
' This example cycles through the documents collection
' and closes all open drawings using the Close method.
Dim DOC As AcadDocument
' If there are no open documents, then exit
If Documents.count = 0 Then
MsgBox "There are no open documents!"
Exit Sub
End If
' Close all open documents
For Each DOC In Documents
If MsgBox("Do you wish to close the document: " & DOC.WindowTitle, vbYesNo & vbQuestion) = vbYes Then
If DOC.FullName <> "" Then
DOC.Close
Else
MsgBox DOC.name & " has not been saved yet, so it will not be closed."
End If
End If
Next
End Sub
Visual LISP: (vl-load-com)
(defun c:Example_Close()
;; This example cycles through the documents collection
;; and closes all open drawings using the Close method
;; except the current drawing.
(setq acadObj (vlax-get-acad-object))
(setq curDoc (vla-get-ActiveDocument acadObj))
(setq docs (vla-get-Documents acadObj))
;; Close all open documents and discard changes, except for the current drawing
(vlax-for doc docs
(if (/= (vla-get-Name doc) (vla-get-Name curDoc))
(progn
(alert (strcat "Closing " (vla-get-Name doc) " file."))
(vla-Close doc :vlax-false)
)
)
)
)
|
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-29 06:02
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.