Author Topic: close a drawing opened twice  (Read 1758 times)

0 Members and 1 Guest are viewing this topic.

Robert_s

  • Guest
close a drawing opened twice
« on: April 28, 2010, 01:28:23 PM »
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)
)

Andrea

  • Water Moccasin
  • Posts: 2372
Re: close a drawing opened twice
« Reply #1 on: April 28, 2010, 02:18:54 PM »
Hi,...I didn't check the code..
but I have made this program.
you can run any LSP VLX FAS file you need.
Keep smile...