recover drawing currently open

Discussion in 'AutoCAD' started by jclaidler, Sep 13, 2004.

  1. jclaidler

    jclaidler Guest

    Below is a program that will 'reopen' the current drawing. How can I change this to 'recover' the current drawing ??

    Thanks for any help.


    (DEFUN reopen ( / ADOC AccoSaveas)

    (SETQ ADOC (vla-get-ActiveDocument (vlax-get-acad-object)))
    (IF (> (GETVAR "SDI") 0)(progn
    (IF (= (vla-get-ReadOnly ADOC) :vlax-false) (COMMAND ".QSAVE"))
    (COMMAND ".OPEN" (STRCAT (GETVAR "DWGPREFIX")(GETVAR "DWGNAME"))))

    (progn
    (IF (= (vla-get-ReadOnly ADOC) :vlax-false) (COMMAND ".QSAVE"))
    (IF (SETQ AccoSaveas (OPEN "C:\\AccoSaveas.SCR" "w"))(progn
    (WRITE-LINE (STRCAT "CLOSE OPEN \"" (GETVAR "DWGPREFIX")(GETVAR "DWGNAME") "\"") AccoSaveas)
    (CLOSE AccoSaveas) ))
    ))

    (IF AccoSaveas (COMMAND ".SCRIPT" "C:\\AccoSaveas.SCR"))

    )
     
    jclaidler, Sep 13, 2004
    #1
  2. jclaidler

    Tom Smith Guest

    Below is a program that will 'reopen' the current drawing. How can I
    change this to 'recover' the current drawing ??

    (command "audit")?
     
    Tom Smith, Sep 13, 2004
    #2
  3. I don't understand how a drawing that needs recovery can possibly even BE
    the current drawing. Enlighten us....

    Kent Cooper, AIA


    ...
     
    Kent Cooper, AIA, Sep 13, 2004
    #3
  4. jclaidler

    jclaidler Guest

    I am creating a 'toolbar button' that will recover the current drawing, because the operators are not to know where the drawing is located. The drawings are opened via a drawing manager, and the manager doesn't have a recover option.

    So, I would like to know how to change the supplied code from 'open current drawing' to 'recover current drawing'.

    Ok ??
     
    jclaidler, Sep 13, 2004
    #4
  5. jclaidler

    Tom Smith Guest

    Thanks, but not the same as recover.

    Just for my information, what exactly is the difference? Recover prompts for
    an extarnal file, while audit runs on the current drawing. Only difference
    I've noticed is that audit will find errors that don't trigger an automatic
    recovery on opening a drawing -- leading me to believe that audit does a
    better job. But help in 2004 gives the opposite impression, by saying that
    you should run recover on a drawing that audit won't fix.
     
    Tom Smith, Sep 13, 2004
    #5
  6. I'm feeling like I must be really ignorant about something here, but bear
    with me....

    I'm still not catching on to what could be the purpose of recovering the
    current drawing, unless you mean something different from AutoCAD's Recover
    command. If the drawing requires recovery, something's gone really wrong,
    and you probably won't be able to use a toolbar button anyway. If it
    doesn't require recovery, what's the point -- why not just open it?

    (Come to think of it, I don't get why you'd want to "re-open" the current
    drawing, either. What does that do for you that's any better than simply
    saving it and continuing?)

    I admit I don't know VLA, so I don't get how you can do a toolbar button
    that closes a drawing and re-opens it, when there won't be Command prompt to
    accept the Open command when it comes along, because the drawing will be
    closed. With either ordinary Open or Recover, if I go for the current
    drawing, I get the already-open-how-about-read-only message, so I think you
    really do have to close it first. If you have (an)other drawing(s) open so
    there'll still be a Command prompt around, can a toolbar button invoked in
    one drawing feed stuff to another one?

    But granting that your re-open thing actually works, would logic dictate
    that you could just replace the word OPEN with RECOVER in appropriate
    places?

    Kent Cooper, AIA


    ...
     
    Kent Cooper, AIA, Sep 13, 2004
    #6
  7. jclaidler

    jclaidler Guest

    How about this... I need the supplied program to change from "opening" the current drawing, to "recovering" it.

    Thanks for any help.
     
    jclaidler, Sep 13, 2004
    #7
  8. jclaidler

    Jim Claypool Guest

    You can doitif you are in the single document mode (SDI=1) but I don't think
    you can otherwise.
    But, I'm with Kent on this one. If the drawing is opened, why would you want
    to recover it?
    And if it needs to be recovered, you probably can't open it to do what you
    are asking.
     
    Jim Claypool, Sep 13, 2004
    #8
  9. jclaidler

    jclaidler Guest

    Let me simplify why I need this.

    1.) drawings contain a OLE
    2.) drawings are imported into a drawing manager
    3.) drawing is OK, until OLE is 'clear'
    4.) upon saving, after clear, drawing is crashed.
    5.) if I recover the drawing, BEFORE saving, the crash does not occur.
    6.) I want to make a 'program' that when selected by our users, will recover the drawing that is currently open.
    7.) This is because the user does not know the location of the drawing file, therefore they can't 'recover' the normal way.
     
    jclaidler, Sep 13, 2004
    #9
  10. jclaidler

    jclaidler Guest

    Even simpler...

    the program will close the current drawing, then re-open it by using the 'recover' command.
     
    jclaidler, Sep 13, 2004
    #10
  11. jclaidler

    Jim Claypool Guest

    You can do it with SDI = 1
     
    Jim Claypool, Sep 13, 2004
    #11
  12. jclaidler

    jclaidler Guest

    I will post my original post again: (below)

    Below is a program that will 'reopen' the current drawing. How can I change this to 'recover' the current drawing ??

    Thanks for any help.


    (DEFUN reopen ( / ADOC AccoSaveas)

    (SETQ ADOC (vla-get-ActiveDocument (vlax-get-acad-object)))
    (IF (> (GETVAR "SDI") 0)(progn
    (IF (= (vla-get-ReadOnly ADOC) :vlax-false) (COMMAND ".QSAVE"))
    (COMMAND ".OPEN" (STRCAT (GETVAR "DWGPREFIX")(GETVAR "DWGNAME"))))

    (progn
    (IF (= (vla-get-ReadOnly ADOC) :vlax-false) (COMMAND ".QSAVE"))
    (IF (SETQ AccoSaveas (OPEN "C:\\AccoSaveas.SCR" "w"))(progn
    (WRITE-LINE (STRCAT "CLOSE OPEN \"" (GETVAR "DWGPREFIX")(GETVAR "DWGNAME") "\"") AccoSaveas)
    (CLOSE AccoSaveas) ))
    ))

    (IF AccoSaveas (COMMAND ".SCRIPT" "C:\\AccoSaveas.SCR"))

    )

    I would like this program to 'recover' the current drawing instead of opening it.
     
    jclaidler, Sep 14, 2004
    #12
  13. jclaidler

    Jim Claypool Guest

    This will do it with SDI = 1

    (DEFUN reopen ( / ADOC AccoSaveas)
    (SETQ ADOC (vla-get-ActiveDocument (vlax-get-acad-object)))
    (IF (> (GETVAR "SDI") 0)
    (progn
    (IF (= (vla-get-ReadOnly ADOC) :vlax-false)
    (COMMAND ".QSAVE")
    )
    (IF (SETQ AccoSaveas (OPEN "C:\\AccoSaveas.SCR" "w"))
    (progn
    (WRITE-LINE (STRCAT "QUIT Y RECOVER \"" (GETVAR "DWGPREFIX")(GETVAR
    "DWGNAME") "\"") AccoSaveas)
    (CLOSE AccoSaveas)
    (COMMAND ".SCRIPT" "C:\\AccoSaveas.SCR")
    )
    )
    )
    )
    )
     
    Jim Claypool, Sep 14, 2004
    #13
  14. jclaidler

    jclaidler Guest

    Thanks, works great.
    But, its not possible to do this with SDI = 0 ??
     
    jclaidler, Sep 14, 2004
    #14
  15. jclaidler

    Jim Claypool Guest

    The problem with the multiple document mode is that when you close the
    current drawing, the script that was running also closes, another opened
    drawing becomes the current one and the variables that were set to recover
    the previously current drawing are lost.
     
    Jim Claypool, Sep 14, 2004
    #15
  16. jclaidler

    jclaidler Guest

    ok.. I understand now why SDI has to be 1.

    How about this, if there is only 1 drawing open, have the program do the following.

    1.) temp set sdi to 1
    2.) recover drawing
    3.) set sdi back to 0
    4.) if more than 1 drawing is open, alert the user to close all other drawings.

    How can I detect multiple drawings open with lisp ??

    Thanks for your help.
     
    jclaidler, Sep 14, 2004
    #16
  17. jclaidler

    Jim Claypool Guest

    (DEFUN reopen () ;( / ADOC AccoSaveas documentcnt)
    (SETQ ADOC (vla-get-ActiveDocument (vlax-get-acad-object)))
    (setq documentcnt (vla-get-count (vla-get-documents
    (vlax-get-acad-object))))
    (if (> documentcnt 1)
    (alert
    (strcat
    "Please close all other drawings("
    (itoa (1- documentcnt))
    ") to run reopen"
    )
    )

    (progn
    (setvar "SDI" 1)
    (IF (= (vla-get-ReadOnly ADOC) :vlax-false)
    (COMMAND ".QSAVE")
    )
    (IF (SETQ AccoSaveas (OPEN "C:\\AccoSaveas.SCR" "w"))
    (progn
    (WRITE-LINE
    (STRCAT
    "QUIT Y RECOVER \""
    (GETVAR "DWGPREFIX")
    (GETVAR "DWGNAME") "\""
    )
    AccoSaveas
    )
    (CLOSE AccoSaveas)
    (COMMAND ".SCRIPT" "C:\\AccoSaveas.SCR")
    )
    )
    )
    )
    )
     
    Jim Claypool, Sep 14, 2004
    #17
  18. jclaidler

    jclaidler Guest

    works great, but where can I reset sdi back to 0 ??
     
    jclaidler, Sep 14, 2004
    #18
  19. jclaidler

    jclaidler Guest

    got it.... thanks for all your help !!!
     
    jclaidler, Sep 14, 2004
    #19
  20. jclaidler

    jclaidler Guest

    Thought it was working, but it isn't. I need to add (setvar "SDI" 0) when the script is down.

    But I can't find a place to put it.
     
    jclaidler, Sep 14, 2004
    #20
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.