pmxcad Posted November 1, 2017 Posted November 1, 2017 I have a lisp routine from Tharwat. I customized something so I can use setq variables (through getstring). But the code does not work, nothing happens. The input can be numbers and letters. What am I doing wrong? Does anyone have an idea? (defun c:test (/ ss) ;; Tharwat 15.12.2015 ;; [color=red](setq str1 (getstring T "\nIDnr: ")) (setq str2 (getstring T "\nROOMnr: "))[/color] (setq lst '([color=red]("TEXT1" str1)[/color] [color=red] ("TEXT2" str2)[/color] ;; -> add more list of (tag . value) as you want ) ) (princ "\nSelect the Attributed block(s):") (if (setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1)))) ((lambda (i / obj e f) (while (setq obj (ssname ss (setq i (1+ i)))) (while (= "ATTRIB" (cdr (assoc 0 (setq e (entget (setq obj (entnext obj)))))) ) (if (setq f (assoc (cdr (assoc 2 e)) lst)) (entupd (cdr (assoc -1 (entmod (subst (cons 1 (cadr f)) (assoc 1 e) e))))) ) ) ) ) -1 ) ) (princ) ) Thanks in advance. ; error: bad DXF group: (1 . STR1) Quote
Grrr Posted November 1, 2017 Posted November 1, 2017 Hi, The getstring prompts are fine, you need to check this tutorial to work out the list problem. Quote
Tharwat Posted November 1, 2017 Posted November 1, 2017 Hi, Can you please try this untested modified codes and let me know? (defun c:test (/ str1 str2 lst ss) ;; Tharwat 01.11.2017 ;; (and (/= (setq str1 (getstring T "\nIDnr: ")) "") (/= (setq str2 (getstring T "\nROOMnr: ")) "") ;; -> add more list of (tag . value) as you want (setq lst (list (list "TEXT1" str1) (list "TEXT2" str2))) (princ "\nSelect the Attributed block(s):") (setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1)))) ((lambda (i / o e f) (while (setq o (ssname ss (setq i (1+ i)))) (while (= "ATTRIB" (cdr (assoc 0 (setq e (entget (setq o (entnext o))))))) (if (setq f (assoc (cdr (assoc 2 e)) lst)) (entupd (cdr (assoc -1 (entmod (subst (cons 1 (cadr f)) (assoc 1 e) e))))) ) ) ) ) -1 ) ) (princ) ) Quote
pmxcad Posted November 1, 2017 Author Posted November 1, 2017 Yes yes..... working. Thank you Tharwat and Grrr for your time. I am very pleased with the code Quote
Tharwat Posted November 1, 2017 Posted November 1, 2017 Yes yes..... working.Thank you Tharwat and Grrr for your time. I am very pleased with the code Good for you. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.