Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

script calling LISP problem

2 REPLIES 2
Reply
Message 1 of 3
rbevansii
789 Views, 2 Replies

script calling LISP problem

I created a LISP routine that will redefine all my dynamic blocks and regular blocks within a drawing.  I set up a SCRIPT to do a batch run of this routine across several drawings.  The LISP routine I created works great by itself, but when I run it within a SCRIPT AutoCAD's Help get's pulled up and the script does not complete.  I'm baffled by this....

 

A portion of the Script I'm using:

sdi 1

 

OPEN "C:\SYMLIB\US\Alpharetta\US-47S-71F-0L1-SO-R-00.dwg" (c:redef) qsave
OPEN "C:\SYMLIB\US\Alpharetta\US-47S-71F-0LL-SO-R-00.dwg" (c:redef) qsave
OPEN "C:\SYMLIB\US\Alpharetta\US-ALG-72C-001-SO-R-00.dwg" (c:redef) qsave
.......
sdi 0
The LISP routine:
(defun C:redef(/ started b b1)
  (command "-purge" "a" "*" "N");;purges the drawing
  (command "-purge" "a" "*" "N");;purges the drawing
  (layerstate-save "DCSSpace" 239 nil)
  (command "-layer" "off" "*" "YES" "")
  (command "-layer" "on" "*eqpm*, *hvac*, *powr*" "")
  (c:blklist);;lisp routine
  (tblnext "block" T)
  (blkct);;lisp routine
  (tblnext "block" T)
  (command "-purge" "a" "*" "N");;purges the drawing
  (setq replacect 0) ;;sets replaced counter
  (while (setq b (tblnext "block" (if (not started) T)))
    (setq started T)
    (if (/= (substr (cdadr b) 1 1) "*")
      (progn
        (setq b1 (cdadr b))
        (if (findfile (strcat "C:/SYMLIB/WBLOCKS/" b1 ".dwg")) ;;if file is in library replaces
          (progn
		  	(setq dwgname1 (getvar "dwgname"))
			(setq csv1(strcat dwgname1 "," b1))
			(setq f (open "C:/SYMLIB/BlocksReplaced.txt" "A"))
			(write-line csv1 f)
			  (close f)
            (command "insert" (strcat b1 "=C:/SYMLIB/WBLOCKS/" b1))
            (command); cancel insertion after new definition imported
            (setq replacect (1+ replacect));;counter for defined blocks replaced
          ); end progn
        ); end if
      ); end progn
    ); end if
  ); end while
  (setq oldsrvc (ssget "X" '((8 . "*SRVC*"))))
  (setq oldcstr (ssget "X" '((8 . "*CSTR*"))))
  (command "erase" oldsrvc oldcstr "")
  (command "-purge" "a" "*" "N");;purges the drawing
  (command "-purge" "a" "*" "N");;purges the drawing
  (prompt (strcat "\nTotal defined blocks: " (itoa origblkct)));;total defined blocks
  (prompt (strcat "\nDefined blocks replaced: " (itoa replacect)));;blocks replaced final count
  (layerstate-restore "DCSSpace")
  (princ)
); end defun

 

2 REPLIES 2
Message 2 of 3
francishc
in reply to: rbevansii

Have you tried typing 'resume at the command line when that happens?  If you can Isolate where it happens, you may be able to put the resume command in your script.  Maybe turn on logs, read the files to see where it breaks.

Message 3 of 3
Moshe-A
in reply to: rbevansii

Hi

 

1. each time you open a drawing you need to verify that your lisp loaded

    otherwise you can not call it 

 

2. there is no need to call your lisp function (c:redef)

    REDEF is enough (like any other regular autocad command)

 

Moshe

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost