add a prefix

add a prefix

k005
Advisor Advisor
466 Views
5 Replies
Message 1 of 6

add a prefix

k005
Advisor
Advisor

There are text objects in the form of xxx m². and on the 'TABANALANI' layer... how can we prefix them with a prefix like Kln :?

 

* There are other text objects that belong to the 'TABANALANI' layer. they have the prefix "Alan". The transaction will not cover it.

 

Thankyou

0 Likes
Accepted solutions (1)
467 Views
5 Replies
Replies (5)
Message 2 of 6

pbejse
Mentor
Mentor

@k005 wrote:

There are text objects in the form of xxx m². and on the ' m²' layer... how can we prefix them with a prefix like Kln :?

...


I guess thats prefix the string of the text objects? "Kln : 132.00  m²" ? 

 


@k005 wrote:

* There are other text objects that belong to the 'TABANALANI' layer. they have the prefix "Alan". The transaction will not cover it.

Does that mean you want those replaced? suffix "Alan" to "Kln :" ? 

 

0 Likes
Message 3 of 6

k005
Advisor
Advisor

Hello my friend, how are you?


We will not handle text objects with a field prefix. We will only add a KLN : prefix to text objects without a field prefix. ( TABANALANI Layer )

0 Likes
Message 4 of 6

pbejse
Mentor
Mentor
Accepted solution

@k005 wrote:

Hello my friend, how are you?


All good, thank you for asking 🙂

 

(defun c:demo ( / ss i str)
(if
  (setq	ss (ssget 
		  '((0 . "TEXT") (8 . "TABANALANI")
		    (1 . "#*# m²"));<-- only with leading number values
	   )
  )
  (repeat (setq i (sslength ss))
    (setq str (cdr (assoc 1 (setq ent (entget (ssname ss (setq i (1- i))))))))
    (entmod (subst (cons 1 (strcat "KLN : " str))(assoc 1 ent) ent))
    )
  )
  (princ)
)

 

HTH

 

Message 5 of 6

k005
Advisor
Advisor

Always a great solution. Thank you very much my friend. 🤗

0 Likes
Message 6 of 6

pbejse
Mentor
Mentor

@k005 wrote:

Always a great solution. Thank you very much my friend. 🤗


Glad it works for you.

 

Keep on coding @k005 

 

0 Likes