TCount Multiline text

TCount Multiline text

Anonymous
Not applicable
1,225 Views
4 Replies
Message 1 of 5

TCount Multiline text

Anonymous
Not applicable

I hope somebody can help me with this. I'm trying to automatically place numbers in multiline text by clicking on it. I tried using TCOUNT find & replace, but it didn't work because my text has 2 lines. Thank you in advance!

0 Likes
1,226 Views
4 Replies
Replies (4)
Message 2 of 5

ВeekeeCZ
Consultant
Consultant
I had never need to make multi-language drawings, but using 2 lines MTEXT is probably the least practical way I can imagine. Is that really necassary?

btw Nice Slavic name! Sadly, Doubravka is not much popular in our country any more..
0 Likes
Message 3 of 5

hak_vz
Advisor
Advisor

Evo Dubravka,

Pozdrav iz Varaždina!

 

 

(defun C:ctext ()
(defun *error* ()(princ))
(setq i (getint "\n start number >"))
(while (setq e (car (entsel "\nSelect MText > " ))) (setq ent (entget e)) (setq new_text (strcat "Zid " (itoa i ) "\\P" "Wall " (itoa i ))) (setq ent (subst (cons 1 new_text) (assoc 1 ent) ent)) (setq ent (entmod ent) i (+ i 1)) ) (princ) )

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 4 of 5

ВeekeeCZ
Consultant
Consultant

Just don't format MTEXT much, otherwise the routine may change mtext's format definition.

 

(vl-load-com)

(defun c:Mtext+1 ( / i ent edt txt num )

(setq i (getint "\nStart number: "))

    (while (setq ent (car (entsel "\nSelect MText: " )))
      (setq edt (entget ent)
	    txt (cdr (assoc 1 edt))
	    num (vl-list->string (vl-remove-if-not '(lambda (x) (wcmatch (chr x) "#")) (vl-string->list txt))))
      (if num
	(progn
	  (setq num (substr num 1 (/ (strlen num) 2))
		txt (vl-string-subst (itoa i) num txt)
		txt (vl-string-subst (itoa i) num txt (/ (strlen txt) 2))
		i (1+ i))
	  (entmod (subst (cons 1 txt)
			 (assoc 1 edt)
			 edt)))))
  (princ)
)
0 Likes
Message 5 of 5

Satish_Rajdev
Advocate
Advocate

With some variation :

 

(defun c:test ( / n o s)
(vl-load-com) (if (setq n (getint "\nSpecify Start Number : ")) (while (setq o (car (entsel "\nSelect MText : "))) (cond ((not (eq (vla-get-objectname (setq o (vlax-ename->vla-object o))) "AcDbMText")) (alert "Selected Object is not MText, Try Again.") ) ((eq (vla-get-objectname o) "AcDbMText") (setq s (strcat "Zid " (itoa n) "\\PWall " (itoa n))) (vla-put-textstring o s) (prompt (vl-string-subst "_" "\\P" s)) (setq n (1+ n))) ) ) ) (princ) )

 

Best Regards,
Satish Rajdev

----------------------  REY TechnologiesLinked INYouTube  ----------------------

Best Regards,
Satish Rajdev


REY Technologies | Linked IN | YouTube Channel


 

0 Likes