text inside block border to its attribute

text inside block border to its attribute

the_ameral
Advocate Advocate
660 Views
4 Replies
Message 1 of 5

text inside block border to its attribute

the_ameral
Advocate
Advocate

 

i have texts in 3 layers(layer1 layer2 layer3)  and have block have 3 tags (tag1 tag 2 tag3) iwant every text within block border convert to its atrrribute( txt in layer1 to tag1.... txt in layer2 to tag2

 

 

Capture.PNG

0 Likes
Accepted solutions (2)
661 Views
4 Replies
Replies (4)
Message 2 of 5

Sea-Haven
Mentor
Mentor
Accepted solution

I have to go so just did a quicky for a start ver2 would sort by layer so pick window for text. Will expand so not hard coded for 3 text.

 

 

 

; Pick 3 text update block atts
; By AlanH June 2021

(defun c:ver1 ( / x y )
(setq y 1)
(repeat 3 
(setq txt (cdr (assoc 1 (entget (car (entsel  "\nPick text"))))))
(set (read (strcat "textlay" (rtos y 2 0))) txt)
(setq y (+ y 1))
)
(setq x 1)
(foreach att (vlax-invoke (vlax-ename->vla-object (car (entsel "\nPick block"))) 'getattributes)
             (vla-put-textstring att (eval (read (strcat "textlay" (rtos x 2 0)))))
			 (setq x (+ x 1))
)
(princ)
)
(ver1)

 

 

0 Likes
Message 3 of 5

pbejse
Mentor
Mentor
Accepted solution

@the_ameral wrote:

i have texts in 3 layers(layer1 layer2 layer3)  and have block have 3 tags (tag1 tag 2 tag3) iwant every text within block border convert to its atrrribute( txt in layer1 to tag1.... txt in layer2 to tag2

 


Asked and answered so many times, what one more then.

 

(Defun c:T2A ( / tagAndLayersNames ss i lst e ll ur en tagN);; Text to Attribute
;;		pBe Jun 2021		;;;

;;	Tag and layer names  | change the values to suit your needs 	;;
(setq tagAndLayersNames
       '(( "TAG1" "LAYER1")( "TAG2" "LAYER2")( "TAG3" "LAYER3")))
  
  (if (setq ss (ssget '((0 . "INSERT")(66 . 1))))
    (repeat (setq i (sslength ss))
      (setq lst nil
	    e (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
      (vla-GetBoundingBox e 'll 'ur)
      (setq pts (mapcar 'vlax-safearray->list (list ll ur)))
      	(if (setq TextObjects (ssget "_W" (Car pts)(cadr pts) '((0 . "TEXT"))))
		(progn
		  (repeat (sslength TextObjects)
		    (setq en (ssname TextObjects 0) ent  (entget en) )
		    (setq lst (cons (list
				      (strcase (cdr (assoc 8 ent)))
				      (cdr (assoc 1 ent)))
					   lst
				    	)
				    )
		    (entdel en)
		    (ssdel en TextObjects)
		 	)
		  (foreach itm (Vlax-invoke e 'GetAttributes)
		    (if (And
			  (setq f (assoc (vla-get-tagstring itm) tagAndLayersNames))
			  (setq tagN (assoc (cadr f) lst))
			  )
		      (vla-put-textstring itm (cadr tagN))))
		  )
	  )
      )
    )(princ)
  )

 

 

HTH

 

Message 4 of 5

the_ameral
Advocate
Advocate
thank u
0 Likes
Message 5 of 5

the_ameral
Advocate
Advocate
thank u .that is i want
0 Likes