0

I want to create a LISP program to change the complete template with new template for batch of files. I created a script but it's showing an error:

(setq ss (ssget "_X" '((0 . "INSERT") ( 2 . "old_block_name"))))
(if ss (command "_.ERASE" ss ""))
_PURGE
_B
"old_block_name"
_N
_QSAVE
(command "_insert" "C:\\Users\\1011848\\Desktop\\new block.dwg" "0,0" "1" "1" "0")
_QSAVE

and

(defun c:make_script ( / prefix file_scr)
    (setq
        prefix (strcat (vl-filename-directory (getfiled "Select a file drawing for batch your directory" "" "dwg" 16)) "\\")
        file_scr (open (strcat prefix "batch_dir.scr") "w")
    )
    (foreach dwg (vl-directory-files prefix "*.dwg" 1)
        (write-line "_.open" file_scr)
        (write-line (strcat "\"" prefix dwg "\"") file_scr)
;;Begin of your commands
        (write-line "(load \"br.lsp\")" file_scr)
;;End of your commands
        (write-line "_.qsave" file_scr)
        (write-line "_.close" file_scr)
    )
    (close file_scr)
    (princ (strcat "\nYou can use the SCRIPT :" prefix "hope.scr"))

(prin1)
)
Lee Mac
  • 15,615
  • 6
  • 32
  • 80
Arjun
  • 1
  • 1
  • 3
    First of all: please format the code to a more friendly form. This is hard to read. Then: what error You get ? – CAD Developer Nov 14 '19 at 07:03
  • Hi Lee , this is the first time i am doing the lisp code , and the code which mentioned i copied from other forum , error its showing is after loading the lisp the block will delete and will show "invalid comment" . can you help me to write code to change the template of batch of drawings together . – Arjun Nov 15 '19 at 09:27

0 Answers0