ScoRm Posted August 6, 2018 Share Posted August 6, 2018 I have this Copy paste autolisp that i stitched up from various people(because IDK how to code) but i am stuck.. what i want to do is select all text and change them all my copy pasted code is for single text... (defun c:TcolAu (/ hcol clr pt1 ss) (While T (setq ss (ssget "_:S" '((0 . ",TEXT")))) (setq hcol (atof(cdr (assoc 1 (entget (ssname ss 0)))))) (cond ((<= hcol 0.09)(setq clr 252)) ((<= hcol 0.49)(setq clr 5)) ((<= hcol 0.99)(setq clr 3)) ((<= hcol 1.99)(setq clr 2)) ((<= hcol 2.99)(setq clr 30)) ((>= hcol 3)(setq clr 6)) ) (command "change" ss "" "_p" "Color" clr "") (princ))) Quote Link to comment Share on other sites More sharing options...
rlx Posted August 6, 2018 Share Posted August 6, 2018 quick google : ; [url]https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-text-and-change-color/td-p/1974137[/url] (defun c:cc (/ string color texts) ;Change Color (setq string (getstring "\n Text string to change: ")) (if (/= string "") (progn (setq texts (ssget "x" (list (cons 0 "TEXT") (cons 1 string)))) (if texts (progn (setq color (acad_colordlg 256 T 0)) (if (/= color nil) (progn (if (= color 256) (setq color "ByLayer")) (if (= color 0) (setq color "ByBlock")) (command "chprop" texts "" "c" color "") (princ (strcat "\n Changed " (rtos (sslength texts)) " text(s) with string >> " string " <<")) ) (princ "\n Color not selected!") ) ) (princ (strcat "\n Not find text(s) with string >> " string " <<")) ) ) (princ "\n Type string to search!") ) (princ) ) type * for all strings also the Qselect command could work... Quote Link to comment Share on other sites More sharing options...
ScoRm Posted August 6, 2018 Author Share Posted August 6, 2018 quick google : ; [url]https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-text-and-change-color/td-p/1974137[/url] (defun c:cc (/ string color texts) ;Change Color (setq string (getstring "\n Text string to change: ")) (if (/= string "") (progn (setq texts (ssget "x" (list (cons 0 "TEXT") (cons 1 string)))) (if texts (progn (setq color (acad_colordlg 256 T 0)) (if (/= color nil) (progn (if (= color 256) (setq color "ByLayer")) (if (= color 0) (setq color "ByBlock")) (command "chprop" texts "" "c" color "") (princ (strcat "\n Changed " (rtos (sslength texts)) " text(s) with string >> " string " <<")) ) (princ "\n Color not selected!") ) ) (princ (strcat "\n Not find text(s) with string >> " string " <<")) ) ) (princ "\n Type string to search!") ) (princ) ) type * for all strings also the Qselect command could work... no sir, i mean how can i change my code to select all text and change the color based on the value of the text... the one you gave will actually make the process longer if i use "search" Quote Link to comment Share on other sites More sharing options...
rlx Posted August 6, 2018 Share Posted August 6, 2018 haven't got a drawing to test it on so untested : (defun c:foo (/ ss hcol clr e) (if (setq ss (ssget "_X" (list '(0 . "TEXT")))) (foreach e (mapcar 'cadr (ssnamex ss)) (setq hcol (atof (cdr (assoc 1 (entget e))))) (cond ((<= hcol 0.09)(setq clr 252)) ((<= hcol 0.49)(setq clr 5)) ((<= hcol 0.99)(setq clr 3)) ((<= hcol 1.99)(setq clr 2)) ((<= hcol 2.99)(setq clr 30)) ((>= hcol 3)(setq clr 6))) (command "change" e "" "_p" "Color" clr "") ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 6, 2018 Share Posted August 6, 2018 Hi, My attempt. (defun c:foo (/ str int sel ent get lst) (and (setq str "" lst '(("0.09" 252) ("0.49" 5) ("0.99" 3)) ;; add your more desired of strings with colours here int -1 sel (ssget "_X" (list '(0 . "TEXT") (cons 1 (apply 'strcat (mapcar '(lambda (u) (setq str (strcat (car u) ","))) lst ) ) ) ) ) ) (while (setq ent (ssname sel (setq int (1+ int)))) (entmod (append (setq get (entget ent)) (list (cons 62 (cadr (assoc (cdr (assoc 1 get)) lst)))) ) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
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.