Juergen Posted April 19, 2021 Posted April 19, 2021 Hi, I use the search function from Acad to find all the same text contant and write per hand then the pos at the end of the text. Is there a way to write it automatic? Thx. for your help. Drawing.dwg Quote
Kajanthan Posted April 19, 2021 Posted April 19, 2021 Try this, But This possible only MTEXT (defun c:pos ( / tl snum svnames svvals ss sta_full num sta) (setq svnames '(osmode cmdecho blipmode plinewid vtenable) svvals (mapcar 'getvar svnames)) (mapcar 'setvar svnames '(0 0 0 0 0)) (setq num (getdist "\n Enter Starting Number")) (while (if (setq ss (ssget ":S" '((0 . "MTEXT") ))) (progn (setq tl (strlen (strcat (rtos num 2 0)))) (if (< tl 2) (setq snum (strcat "0" (rtos num 2 0))) (setq snum (strcat (rtos num 2 0))) ) (setq sta_full (cdr (assoc 1 (entget (ssname ss 0))))) (setq sta (strcat sta_full "\\C1" "xPos." snum)) (mapcar '(lambda (z) (vla-put-textstring z sta)) (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))) (setq num (1+ num)) ) ) ) (mapcar 'setvar svnames svvals) ) (princ "\n| Type \"POS\" to Awake |") (princ) file here Increment Text.lsp Quote
BIGAL Posted April 20, 2021 Posted April 20, 2021 (setq num (getdist "\n Enter Starting Number")) Doubtful that the number is 123.456 (getint would be better. I think the answer required is more select a single text, using that as a pattern find all the matching texts and add the pos.x, then pick next text and add the pos.x+1 Quote
Juergen Posted April 20, 2021 Author Posted April 20, 2021 Hi Kajanthan, i tried to run your file, but i get the info "; Error: Bad string for ssget mode" . The starting number should be 01. Quote
Kajanthan Posted April 20, 2021 Posted April 20, 2021 2 hours ago, Juergen said: Hi Kajanthan, i tried to run your file, but i get the info "; Error: Bad string for ssget mode" . The starting number should be 01. First you Convert TEXT To MTEXT using command "TXT2MTXT". Without Starting Number. Corrected lisp Increment Text.lsp Quote
Juergen Posted April 20, 2021 Author Posted April 20, 2021 Hi Kajanthan, i change the text into mtext but i have the same report: bad string ... ssget I use a german version. Any Idea? Quote
Tharwat Posted April 20, 2021 Posted April 20, 2021 Give this dynamic increment a go. (defun c:Test (/ sel lst yup) ;; Tharwat - Date: 20.Apr.2021 ;; (and (or *inc_* (setq *inc_* 1)) (setq *inc_* (cond ((getint (strcat "\nSpecify increment number < " (itoa *inc_*) " > : " ) ) ) (*inc_*) ) ) (while (and (setq sel (car (entsel "\nSelect Mtext to add increment suffix : "))) (setq yup (= (cdr (assoc 0 (setq lst (entget sel)))) "MTEXT")) (entmod (subst (cons 1 (strcat (cdr (assoc 1 lst)) "{\\C1;xPos." (if (> 10 *inc_*) (strcat "0" (itoa *inc_*)) (itoa *inc_*) ) "}" ) ) (assoc 1 lst) lst ) ) (setq *inc_* (1+ *inc_*)) ) ) ) (and sel (not yup) (princ "\nInvalid object. Try again <!>")) (princ) ) Quote
Juergen Posted April 20, 2021 Author Posted April 20, 2021 hi tharwat, thanks for your answer. But what i need is all text with the same content should become the same Pos. 3050x489xPos.01 3050x1250xPos.02 3050x544xPos.03 3050x1098xPos.04 3050x1250xPos.02 3050x544xPos.03 3050x489xPos.01 ......and so on Quote
Tharwat Posted April 20, 2021 Posted April 20, 2021 (edited) Then there is no need to convert your Texts to Mtexts, so the following should change the similar text strings automatically that reside into your current active space. (defun c:Test (/ sel lst int ent) ;; Tharwat - Date: 20.Apr.2021 ;; (and (or *inc_* (setq *inc_* 1)) (setq *inc_* (cond ((getint (strcat "\nSpecify increment number < " (itoa *inc_*) " > : " ) ) ) (*inc_*) ) ) (while (and (setq sel (car (entsel "\nSelect Text to add increment suffix : ")) ) (= (cdr (assoc 0 (setq lst (entget sel)))) "TEXT") (setq int -1 sel (ssget "_X" (list '(0 . "TEXT") (assoc 1 lst) (cons 410 (getvar 'CTAB)) ) ) ) (while (setq int (1+ int) ent (ssname sel int) ) (setq lst (entget ent)) (entmod (subst (cons 1 (strcat (cdr (assoc 1 lst)) "xPos." (if (> 10 *inc_*) (strcat "0" (itoa *inc_*)) (itoa *inc_*) ) ) ) (assoc 1 lst) lst ) ) ) (setq *inc_* (1+ *inc_*)) ) ) ) (princ) ) Edited April 20, 2021 by Tharwat Codes added. lol 1 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.