Hello,
I found this code in this website and use this for
my batch plot routine. I would open a drawing run a
scr/lisp program to plot the drawing, then close it
without saving it.
The problem I'm having is that when somebody else in my
office has the same drawing open already. It does not close
the drawing I opened.
My guess is that the program sees the same drawing open twice
thats why it will not work.
Can somebody please modify this to close the drawing I opened
which will be in a read-only mode since somebody else has opened
already.
The Code:
(defun CloseAndSave ( dwgName bSave )
(vlax-for i (vla-get-Documents (vlax-get-Acad-Object))
(if (= (strcase dwgName) (strcase (vla-get-Name i)))
(if
(and
bSave
(equal (vla-get-ReadOnly i) :vlax-false)
)
(vla-Close i :vlax-true)
(vla-Close i :vlax-false)
)
)
)
)
(defun CloseDwg (filename save)
(setq acad (vlax-get-acad-object)
docs (vla-get-documents acad)
)
(vlax-for doc docs
(if (= filename (vlax-get-property doc 'fullname))
(vla-close doc save)
)
)
)
;;; close drawing don't save
(defun CloseDontSaveDwg (filename)
(CloseDwg filename :vlax-false)
)
;;; close drawing and save
(defun CloseAndSaveDwg (filename)
(CloseDwg filename :vlax-true)
)