LSP to SCR problems

Discussion in 'AutoCAD' started by MJB, Feb 4, 2005.

  1. MJB

    MJB Guest

    Howdy All,

    KDispoto was nice enough to post this lsp (from Hot Tip Harry I
    believe) and wroks great until the choice of directory has a space in
    the name. I have tinkered with it a bit to no avail. (I am an ameteur
    lvl programmer at best)
    So any help in determining how to allow directories with spaces to work
    would be great.

    When I run the LSP it allows me to browse to the desired DIR, then it
    cereats a TEMP.SCR in that DIR then when it tries to access the DIR
    again it stops.
    "The system can not find the file specified".

    TIA,
    MJB

    ;Tip1512: BP.LSP Batch Processor (c)1999, Yuqun Lian

    (setq *process "AUDIT Y" ) ;;to audit drawings
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;(setq *process "dxfout ") ;;to DXFout drawings
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    (defun C:BAudit(/ afile)
    (setq afile (getfiled (strcat "Select a file in a
    desired "
    "directory for batch processing") "" "DWG"
    0))
    (if afile
    (bprocess (strp_path afile))
    (alert "You need to pick a file in the directory!")
    )
    )

    (defun bprocess(listpath / tempfile filelist scrfile fp
    file)
    (setq tempfile (strcat listpath "temp.dwg"))
    (if (findfile tempfile)
    (command "_SAVE" tempfile "y")
    (command "_SAVE" tempfile)
    )
    (setq filelist (get_file_list listpath "DWG"))
    (setq scrfile (strcat listpath "temp.scr"))
    (setq fp (open scrfile "w"))
    (foreach file filelist
    (write-line (strcat "_OPEN " "\"" listpath file "\"")
    fp)
    (write-line (strcat *process " _QSAVE") fp)
    )
    (close fp)
    (command "_SCRIPT" scrfile)
    (princ)
    )

    ;; Return file list in listpath directory with extention
    ext
    (defun get_file_list (listpath ext / listfile fp fileline
    linelen
    startnum filelist scr file extention
    filename c)
    (setq listfile "temp.txt")
    (setq listfile (strcat listpath listfile))
    (setq fp (open listfile "w"))
    (write-line "File list for this directory:" fp)
    (close fp)
    (setq filelist '())
    (setq scr (strcat "dir " listpath " > " listfile))
    (command "_shell" scr)
    (command "_delay" 2000)
    (setq fp (open listfile "r"))
    (while (setq fileline (read-line fp))
    (setq linelen (strlen fileline))
    (setq startnum 40)
    (if (= (substr fileline startnum 1) ":")
    (setq startnum 45)
    )
    (if (> linelen (+ startnum 3))
    (progn
    (setq file (substr fileline startnum (1+ (-
    linelen
    startnum))))
    (setq extention (substr file (- (strlen file)
    2) 3))
    (if (= (strcase extention) (strcase ext))
    (setq filelist (append filelist (list
    file)))
    )
    )
    )
    )
    (close fp)
    (setq filelist filelist)
    )

    (defun strp_name (full_str / count full_count not_found)
    (if full_str (progn
    (setq count (strlen full_str))
    (setq full_count count)
    (setq not_found T)
    (while not_found
    (if (or(= (substr full_str count 1) "\\")
    (= (substr full_str count 1) "/"))
    (setq not_found nil)
    (setq count (- count 1)))
    )
    (substr full_str (1+ count) (- full_count 1) )
    )(eval "")) ;progn if
    )

    (defun strp_path(fullname / path name)
    (setq name (strp_name fullname))
    (setq path (substr fullname 1 (- (strlen fullname)
    (strlen
    name))))
    )

    (princ "\nType BAudit to run batch processing.")(princ)
     
    MJB, Feb 4, 2005
    #1
  2. MJB

    MJB Guest

    oops sorry..

    Vanilla ACAD2004

    Thanks,

    MJB
     
    MJB, Feb 4, 2005
    #2
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.