export variable system in a txt

Discussion in 'AutoCAD' started by caca, Sep 17, 2004.

  1. caca

    caca Guest

    Hi,

    Does anyone know how can I export the variable system TDINDWG into a txt file together with the command quit, when the projectist closes the drawing?

    Thank you,
    Carol
     
    caca, Sep 17, 2004
    #1
  2. caca

    randy benson Guest

    ; Write-TDindwg to "\CurrentDwgFolder\CurrentDwgname.txt"

    (defun c:WTD ()
    (setq len (strlen (getvar "dwgname"))
    f (open
    (strcat
    (getvar "DWGPREFIX")
    (substr (getvar "DWGNAME") 1 (- len 4))
    ".txt"
    )
    "w"
    )
    )
    (write-line (strcat (rtos (getvar "TDINDWG")) " " "QUIT") f)
    (close f)
    (princ)
    )
     
    randy benson, Sep 18, 2004
    #2
  3. caca

    randy benson Guest

    Sorry -- 1st line should've been:

    (defun c:WTD ( / len f) ; local variables
     
    randy benson, Sep 18, 2004
    #3
  4. caca

    C Witt Guest

    i don't think he wanted the "text" quit in the file.. he wanted that
    sysvar exported when he uses the COMMAND quit.
     
    C Witt, Sep 18, 2004
    #4
  5. caca

    randy benson Guest

    You're probably right -- I wrote before thinking. If so, redefining the
    'quit' command would be more straightforward than writing a reactor - but I'd
    tend towards a 'Quit' routine that would be invoked by a name other than 'quit',
    say, 'fin.lsp'. It would write the sysvar state to a file before invoking the
    'quit' command:

    ; Fin - Writes TDindwg to "\\CurrentDwgFolder\CurrentDwgname.txt"
    ; then quits, saving changes to dwg

    (defun c:fin ( / len f)
    (command "_.expert" (getvar "expert")) ; suppresses 2nd 'command: ' prompt
    when lsp runs
    (setq len (strlen (getvar "dwgname"))
    f (open
    (strcat
    (getvar "DWGPREFIX")
    (substr (getvar "DWGNAME") 1 (- len 4))
    ".txt"
    )
    "w"
    )
    )
    (write-line (rtos (getvar "TDINDWG")) f)
    (close f)
    (command "._QUIT" "Y")
    (princ)
    )
     
    randy benson, Sep 18, 2004
    #5
  6. caca

    caca Guest

    Hi Randy,

    Do you mean with this lisp is that I can save TDINDWG into a txt file?
    But is it possible to save the TDINDWG from all drawings that I have opened during the period of one day and save all listed in one sigle txt with DWGPREFIX, DWGNAME and TDINDWG, right before command "Close", I was confusing with "Quit", sorry...?
     
    caca, Sep 20, 2004
    #6
  7. caca

    randy benson Guest

    Not tested -- and I use LDD which is non-MDI, so I don't know about the "close"...

    Make sure you change the "//Zarkon/_Data" to your 'Projects' folder path.

    I put the 'TDINDWG' data first on the line to ease column justification.


    ; Fin - Writes TDindwg, Path and Filename to "Today's Date.txt", e.g.,
    ; "20040921.TXT", in the folder you specify < SEE BELOW >
    ; then quits, saving changes to dwg
    ; by Randy Benson 9/21/2004

    (defun c:fin ( / fln f)
    (setq TDFilePath "//Zarkon/_Data")
    ; NOTE: set TDFilePath = Your 'All Projects' Container Path
    ; e.g., "d:/MyProjects"
    ;
    (command "_.expert" (getvar "expert"))
    (if
    (null
    (findfile
    (setq fln
    (strcat
    TDFilePath
    "/"
    (itoa (fix (getvar "CDATE")))
    ".TXT"
    )
    )
    )
    )
    (progn
    (setq f (open fln "w"))
    (close f)
    )
    )
    (setq f (open fln "a"))
    (setq strng
    (strcat
    (rtos (getvar "TDINDWG") 2 12)
    " "
    (getvar "DWGPREFIX")
    (getvar "DWGNAME")
    )
    )
    (write-line strng f)
    (close f)
    (command "._QUIT" "Y")
    (princ)
    )
     
    randy benson, Sep 21, 2004
    #7
  8. caca

    randy benson Guest

    Oops --

    I think you can safely replace the
    (command "._QUIT" "Y")

    with

    (command "._CLOSE" "Y")
     
    randy benson, Sep 21, 2004
    #8
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.