本帖最后由 xiaxiang 于 2013-1-21 17:02 编辑
- (defun Get:OpenDrawings ( / *dwg* *acdocs*)
- (vlax-for <doc> (vla-get-documents (vlax-get-acad-object))
- (if (eq "" (setq *dwg* (vla-get-fullname <doc>)))
- (setq *dwg* (vla-get-name <doc>))
- )
- (setq *acdocs* (cons (cons (strcase *dwg*) <doc>) *acdocs*))
- )
- (reverse *acdocs*)
- )
- (Get:OpenDrawings)
- ;;dwgName ->file name "Drawing3.dwg"
- ;;bSave -> t save
- ;; ->nil not save
- (defun CloseAndSave ( dwgName bSave / myDocs myDoc)
- (setq myDocs (vla-Get-Documents (vlax-get-acad-object))
- myDoc (vla-Item myDocs dwgName))
- (vlax-for i myDocs
- (if (= (strcase dwgName) (strcase (vla-get-Name i)))
- (if
- (and
- bSave
- myDoc
- (equal (vla-get-ReadOnly i) :vlax-false)
- (equal (vla-get-Active i) :vlax-false)
- )
- (vla-Close i :vlax-true)
- (vla-Close i :vlax-false)
- )
- )
- )
- )
如果需要关闭当前文档,lisp似乎做不到,只有依赖VBA表达式
- (command "vbastmt" "activedocument.close false")
|