ImaJayhawk
12th Nov 2003, 09:34 pm
I wrote a quick autolisp routine to replace one block with another. It works fine except I tried to add a not statement after the while statement so that if I miss clicking on a block it won't stop the command. Now it won't loop or even work one time through. Does anyone see what I did wrong? Thanks.
--ImaJayhawk
----------------------Code Before Change-----------------------------
(defun C:blocky()
;turn the system echo off
(setvar "cmdecho" 0)
(setq blocker (getstring "\nEnter Block Name: "))
(While
(setq enty (entsel "\nSelect Block: "))
(progn
(setq e (entget (car enty)))
(setq xcorr (cadr (assoc 10 e)))
(setq ycorr (caddr (assoc 10 e)))
(setq zcorr (cadddr (assoc 10 e)))
(setq n (list xcorr ycorr zcorr))
(setq angler (cdr (assoc 50 e)))
(command "erase" enty "")
(command "-insert" blocker n "" "" (strcat (rtos angler 2 6) "r"))
) ;progn
) ;while
(setvar "cmdecho" 1)
(princ)
)
----------------------Code After Change--------------------------
(defun C:blocky()
;turn the system echo off
(setvar "cmdecho" 0)
(setq blocker (getstring "\nEnter Block Name: "))
(While (not (setq enty (entsel "\nSelect Block: ")))
(progn
(setq e (entget (car enty)))
(setq xcorr (cadr (assoc 10 e)))
(setq ycorr (caddr (assoc 10 e)))
(setq zcorr (cadddr (assoc 10 e)))
(setq n (list xcorr ycorr zcorr))
(setq angler (cdr (assoc 50 e)))
(command "erase" enty "")
(command "-insert" blocker n "" "" (strcat (rtos angler 2 6) "r"))
) ;progn
) ;while
(setvar "cmdecho" 1)
(princ)
)
--ImaJayhawk
----------------------Code Before Change-----------------------------
(defun C:blocky()
;turn the system echo off
(setvar "cmdecho" 0)
(setq blocker (getstring "\nEnter Block Name: "))
(While
(setq enty (entsel "\nSelect Block: "))
(progn
(setq e (entget (car enty)))
(setq xcorr (cadr (assoc 10 e)))
(setq ycorr (caddr (assoc 10 e)))
(setq zcorr (cadddr (assoc 10 e)))
(setq n (list xcorr ycorr zcorr))
(setq angler (cdr (assoc 50 e)))
(command "erase" enty "")
(command "-insert" blocker n "" "" (strcat (rtos angler 2 6) "r"))
) ;progn
) ;while
(setvar "cmdecho" 1)
(princ)
)
----------------------Code After Change--------------------------
(defun C:blocky()
;turn the system echo off
(setvar "cmdecho" 0)
(setq blocker (getstring "\nEnter Block Name: "))
(While (not (setq enty (entsel "\nSelect Block: ")))
(progn
(setq e (entget (car enty)))
(setq xcorr (cadr (assoc 10 e)))
(setq ycorr (caddr (assoc 10 e)))
(setq zcorr (cadddr (assoc 10 e)))
(setq n (list xcorr ycorr zcorr))
(setq angler (cdr (assoc 50 e)))
(command "erase" enty "")
(command "-insert" blocker n "" "" (strcat (rtos angler 2 6) "r"))
) ;progn
) ;while
(setvar "cmdecho" 1)
(princ)
)