AeJay Posted March 27, 2023 Share Posted March 27, 2023 Basically I just wanted to have this code by Lee to essentially have the match prop as well. Someone replied to me in the original thread but I can't seem to get it to work. Lee's code: (defun c:mt (/ cEnt mEnt) (if (and (setq cEnt (car (nentsel "\nSelect Source Text: "))) (member (cdr (assoc 0 (entget cEnt))) '("TEXT" "MTEXT" "ATTRIB"))) (progn (redraw cEnt 3) (while (and (setq mEnt (car (nentsel "\nSelect Destination Text: "))) (member (cdr (assoc 0 (entget mEnt))) '("TEXT" "MTEXT" "ATTRIB"))) (entmod (subst (assoc 1 (entget cEnt)) (assoc 1 (entget mEnt)) (entget mEnt)))) (redraw cEnt 4)) (princ "\n<!> Incorrect Selection <!>")) (princ)) (defun c:mt2 (/ cEnt mEnt sLst) (if (and (setq cEnt (car (nentsel "\nSelect Source Text: "))) (member (cdr (assoc 0 (entget cEnt))) '("TEXT" "MTEXT" "ATTRIB"))) (progn (redraw cEnt 3) (if (setq ss (ssget "_X" '((-4 . "<NOT") (0 . "TEXT,MTEXT,INSERT") (-4 . "NOT>")))) (mapcar '(lambda (x) (redraw x 2)) (setq sLst (mapcar 'cadr (ssnamex ss))))) (while (and (setq mEnt (car (nentsel "\nSelect Destination Text: "))) (member (cdr (assoc 0 (entget mEnt))) '("TEXT" "MTEXT" "ATTRIB"))) (entmod (subst (assoc 1 (entget cEnt)) (assoc 1 (entget mEnt)) (entget mEnt))))) (princ "\n<!> Incorrect Selection <!>")) (command "_regenall") (princ)) (defun c:mt3 (/ cEnt ss) (vl-load-com) (if (and (setq cEnt (car (nentsel "\nSelect Source Text: "))) (member (cdr (assoc 0 (entget cEnt))) '("TEXT" "MTEXT" "ATTRIB"))) (progn (redraw cEnt 3) (if (setq ss (ssget '((0 . "TEXT,MTEXT")))) (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) (entmod (subst (assoc 1 (entget cEnt)) (assoc 1 (entget x)) (entget x)))))) (princ "\n<!> Incorrect Selection <!>")) (command "_regenall") (princ)) Quote Link to comment Share on other sites More sharing options...
AeJay Posted March 27, 2023 Author Share Posted March 27, 2023 I tried modifying it (code below) but then despite successfully loading the .lsp via appload and using the correct shortcut name of mt3. It says it is an unknown command. (defun c:mt3 (/ cEnt ss textColor) (vl-load-com) (if (and (setq cEnt (car (nentsel "\nSelect Source Text: "))) (member (cdr (assoc 0 (entget cEnt))) '("TEXT" "MTEXT" "ATTRIB"))) (progn (setq textColor (cdr (assoc 62 (entget cEnt)))) ;; get the text color (redraw cEnt 3) (if (setq ss (ssget '((0 . "TEXT,MTEXT")))) (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) (entmod (subst (assoc 1 (entget cEnt)) (assoc 1 (entget x)) (subst (cons 62 textColor) (assoc 62 (entget x)) (entget x)))))) ;; update the text color (princ "\n<!> Incorrect Selection <!>")) (command "_regenall") (princ))) Quote Link to comment Share on other sites More sharing options...
AeJay Posted March 27, 2023 Author Share Posted March 27, 2023 This code loads and functions correctly but it still just copies the text and not the text's color as well. Please help. (defun c:matchTextAndProp (/ cEnt ss textColor) (vl-load-com) (if (and (setq cEnt (car (nentsel "\nSelect Source Text: "))) (member (cdr (assoc 0 (entget cEnt))) '("TEXT" "MTEXT" "ATTRIB"))) (progn (setq textColor (cdr (assoc 62 (entget cEnt)))) ;; get the text color (redraw cEnt 3) (if (setq ss (ssget '((0 . "TEXT,MTEXT")))) (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) (entmod (subst (assoc 1 (entget cEnt)) (assoc 1 (entget x)) (subst (cons 62 textColor) (assoc 62 (entget x)) (entget x)))))) ;; update the text color (princ "\n<!> Incorrect Selection <!>"))) (command "_regenall") (princ)) Quote Link to comment Share on other sites More sharing options...
AeJay Posted March 27, 2023 Author Share Posted March 27, 2023 This too won't still work to copy the source's text color (defun c:matchTextAndProp (/ cEnt ss textColor) (vl-load-com) (if (and (setq cEnt (car (nentsel "\nSelect Source Text: "))) (member (cdr (assoc 0 (entget cEnt))) '("TEXT" "MTEXT" "ATTRIB"))) (progn (setq textColor (cdr (assoc 62 (entget cEnt)))) (redraw cEnt 3) (if (setq ss (ssget '((0 . "TEXT,MTEXT")))) (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) (entmod (subst (assoc 1 (entget cEnt)) (assoc 1 (entget x)) (entmod (subst (cons 62 textColor) (assoc 62 (entget x)) (entget x))))))) ) (command "_regenall") (princ)) Quote Link to comment Share on other sites More sharing options...
AeJay Posted March 27, 2023 Author Share Posted March 27, 2023 Below is a video of it working with one type of text but not all type of text. Please help. mp.mp4 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 27, 2023 Share Posted March 27, 2023 One of the things with color is if its bylayer then it does not have a color in the entget, no 62, so if its nil then you need to get the Layer color. Test (entget (car (entsel "\nPick text "))) Example (setq col (vla-get-color (vlax-ename->vla-object e))) (if (= col 256) (setq col (cdr (assoc 62 (tblsearch "LAYER" lay)))) ) 1 Quote Link to comment Share on other sites More sharing options...
AeJay Posted March 28, 2023 Author Share Posted March 28, 2023 Fixed it. Here is a code: cc: gileCAD (defun c:matchTextAndProp (/ cEnt elst text color ss i) (if (and (setq cEnt (car (nentsel "\nSelect Source Text: "))) (member (cdr (assoc 0 (entget cEnt))) '("TEXT" "MTEXT" "ATTRIB") ) ) (progn (setq elst (entget cEnt) text (assoc 1 elst) color (cond ((assoc 62 elst)) (T '(62 . 256)) ) ) (redraw cEnt 3) (if (setq ss (ssget '((0 . "TEXT,MTEXT")))) (repeat (setq i (sslength ss)) (setq elst (entget (ssname ss (setq i (1- i))))) (entmod (subst text (assoc 1 elst) (if (assoc 62 elst) (entmod (subst color (assoc 62 elst) elst)) (append elst (list color)) ) ) ) ) ) ) ) (command "_regenall") (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.