D
dhorton
Hello,
With much help from Jimmy D and Bob (ECCAD) recently, I have a LISP that creates a selection of a particular block and alters two vairables within it (adding leading zeros).
Basically, I have used the LISP Jimmy D has supplied me and repeated part of it. Is there a more efficient way of altering multiple attributes within a block?
Heres my lisp:
comments very much appreciated......
(defun c:test (/ blk att att1 str1 slen1)
(setq blk (ssget "x"(list (cons 0 "INSERT") (cons 2 "blockname"))))
(while (/= (sslength blk) 0)
(setq att (ssname blk 0))
(setq att1 (entget att))
(while (setq att1 (entnext (cdr (assoc -1 att1))))
(setq att1 (entget att1))
(if (= (cdr (assoc 2 att1)) "tagname1")
(progn
(setq str1 (cdr (assoc 1 att1))
slen1 (strlen str1)
); end setq
(if (= slen1 1)
(entmod (subst (cons 1 (strcat "0" str1)) (assoc 1 att1) att1))
);end if
); end progn
); end if
); end while
;;
;;
(setq att (ssname blk 0))
(setq att1 (entget att))
(while (setq att1 (entnext (cdr (assoc -1 att1))))
(setq att1 (entget att1))
(if (= (cdr (assoc 2 att1)) "tagname2")
(progn
(setq str1 (cdr (assoc 1 att1))
slen1 (strlen str1)
); end setq
(if (= slen1 1)
(entmod (subst (cons 1 (strcat "0" str1)) (assoc 1 att1) att1))
);end if
); end progn
); end if
); end while
;;
(ssdel att blk)
); end while
)
thanks,
dom
With much help from Jimmy D and Bob (ECCAD) recently, I have a LISP that creates a selection of a particular block and alters two vairables within it (adding leading zeros).
Basically, I have used the LISP Jimmy D has supplied me and repeated part of it. Is there a more efficient way of altering multiple attributes within a block?
Heres my lisp:
comments very much appreciated......
(defun c:test (/ blk att att1 str1 slen1)
(setq blk (ssget "x"(list (cons 0 "INSERT") (cons 2 "blockname"))))
(while (/= (sslength blk) 0)
(setq att (ssname blk 0))
(setq att1 (entget att))
(while (setq att1 (entnext (cdr (assoc -1 att1))))
(setq att1 (entget att1))
(if (= (cdr (assoc 2 att1)) "tagname1")
(progn
(setq str1 (cdr (assoc 1 att1))
slen1 (strlen str1)
); end setq
(if (= slen1 1)
(entmod (subst (cons 1 (strcat "0" str1)) (assoc 1 att1) att1))
);end if
); end progn
); end if
); end while
;;
;;
(setq att (ssname blk 0))
(setq att1 (entget att))
(while (setq att1 (entnext (cdr (assoc -1 att1))))
(setq att1 (entget att1))
(if (= (cdr (assoc 2 att1)) "tagname2")
(progn
(setq str1 (cdr (assoc 1 att1))
slen1 (strlen str1)
); end setq
(if (= slen1 1)
(entmod (subst (cons 1 (strcat "0" str1)) (assoc 1 att1) att1))
);end if
); end progn
); end if
); end while
;;
(ssdel att blk)
); end while
)
thanks,
dom