I have an attribute editor LISP that changes the value of an attribute within a block.
Recently, the LISP needed a face lift due to changes in standards, sp this is what i am working on...
(defun c:`` ( / _AttFunc b tbl dname attval a b) (vl-load-com) (defun _AttFunc (en lst / vals v) (mapcar (function (lambda (at) (setq vals (list (vla-get-tagstring at) (vla-get-textstring at))) (if (and lst (setq v (assoc (car vals) lst))) (vla-put-textstring at (cadr v)) ) vals ) ) (vlax-invoke (if (eq (type en) 'VLA-OBJECT) en (vlax-ename->vla-object en) ) 'Getattributes ) ) ) (setq Y (getstring "Enter building number: ")) (setq Z (getstring "Enter project number: ")) (setq Y (strcat Y "-")) (setq Z (strcat Y Z)) (if (and (= (getvar 'Dwgtitled) 1) (setq b nil tbl (ssget "_X" '((0 . "INSERT")(66 . 1)(2 . "TB_PARAMOUNT_ELC")))) (setq p (vl-string-position 95 (setq dname (vl-filename-base (getvar 'dwgname))) nil T)) (setq dname (substr dname (+ 2 p))) (setq attval (_AttFunc (setq tbl (ssname tbl 0)) nil)) (vl-every '(lambda (x) (if (setq a (assoc x attval)) (setq b (cons a b)))) '("DWG")) ) (_AttFunc tbl (list (list "DWG" (strcat (cadr (assoc Z attval)) "-" dname)))) (princ "\Incomplete data to process") ) (princ) )
So now whenever I run this code, i get an "; error: bad argument type: stringp nil" error.
I am wanting to update the attribute value with the Building number "-" Project number "-" the last 3 digits of the DWG file name.
So something to the effect of "13-21-100", whatever the user inputs are.
I'm missing something simple here, i know it, but i can't seem to figure it out.
So i am turning to the awesome community that is here in the VLISP forums!
Thanks as always!
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
Change
(_AttFunc tbl (list (list "DWG" (strcat (cadr (assoc Z attval)) "-" dname))))
to
(_AttFunc tbl (list (list "DWG" (strcat Z "-" dname))))
Henrique
@Anonymous wrote:
I have an attribute editor LISP that changes the value of an attribute within a block.
Recently, the LISP needed a face lift due to changes in standards, sp this is what i am working on...
Thanks as always!
---> Source? <----
I think i can FIX that code for you TomTom111
1. You dont need vl-every if theres only one condition . ["DWG"]
2. It will crash if value for variable Z is not found in variable attval hence the error
At any rate, i'm not sure of your intention for the final string result as you area targeting a specifc TAG from attval.
@hmsilva wrote:Change
(_AttFunc tbl (list (list "DWG" (strcat (cadr (assoc Z attval)) "-" dname))))
to
(_AttFunc tbl (list (list "DWG" (strcat Z "-" dname))))
Henrique
Works like a charm.
Not sure what I was trying to do yesterday. LISP fatigue perhaps.
Thanks very much for the reply!
Can't find what you're looking for? Ask the community or share your knowledge.