bono05 发表于 2022-7-6 06:41:07

I have test both code...i don't see a difference?
 
But it's possible to select block and text at once?

pBe 发表于 2022-7-6 06:43:41

 
ssget filter modified to select ONLY blocks with attributes
 
 
Yes of course. perhaps its better to show a drawing sample for us to provide a suitable code or suggestion.

cadplayer 发表于 2022-7-6 06:46:55

I didn´t read all, but maybe help this code to convert a text -> block with attribut

(defun c:t2b ( / n aws obj) (setvar "cmdecho" 0) (setq os (getvar "osmode")) (princ "\nconvert text to block\n") (if (not (tblobjname "BLOCK" "YOUR BLOCK"))   (alert "YOUR BLOCK IS NOT DEFINITION")) (setq n 0) (setvar "ATTDIA" 0) (setvar "ATTREQ" 1) (setvar "osmode" 0) (if (setq aws (ssget '((0 . "TEXT"))))   (progn   (repeat (sslength aws)   (setq obj (entget (ssname aws n)))   (command "_.-INSERT" "YOUR BLOCK"      (cdr(assoc 10 OBJ))      (getvar "dimscale") (getvar "dimscale") 0      (rtos(atof (cdr(assoc 1 OBJ)))2 2))   (setq n (1+ n))   )   )   ) (setvar "cmdecho" 1) (setvar "osmode" os) (princ) )

bono05 发表于 2022-7-6 06:50:25

Here a sample...magenta block will come block with attribute.

pBe 发表于 2022-7-6 06:52:59

Not a good idea using external link. Edit you post and attached the file

cadplayer 发表于 2022-7-6 06:58:16

I have only started... do you mean like this ?
DATA +06_example.dwg

bono05 发表于 2022-7-6 07:00:53

What a team !!! Thanks cadplayer!

cadplayer 发表于 2022-7-6 07:03:47

Here you have a quick tool to change Text in Block Attribut
 
 
correctly better so...

(defun c:cha (/ txt blk) (if (= (cdr (assoc 0 (entget (setq txt (car (entsel "\nSelect text value ")))))) "TEXT")   (progn   (if (and (= (cdr (assoc 0 (entget (setq blk (car (entsel "\nSelect Chapelle block ")))))) "INSERT")            (= (cdr (assoc 2 (entget blk))) (cdr (assoc 2 (tblsearch "BLOCK" "Chapelle"))))            )       (progn         (entmod (subst (assoc 1 (entget txt)) (assoc 1 (entget (entnext blk))) (entget (entnext blk))))          (entdel txt)         )       )   )   (princ "\nSelect a Text ")   ) (princ) )      

bono05 发表于 2022-7-6 07:06:53

Cadplayer,
 
I've tried this lisp....but after selection of block my text is gone and there is no attribute at the chapelle block?

cadplayer 发表于 2022-7-6 07:10:18

Do you need TextObject or only TextAttribut ?
 
so delete only (entdel txt)
 

(defun c:cha (/ txt blk) (if (= (cdr (assoc 0 (entget (setq txt (car (entsel "\nSelect text value ")))))) "TEXT")   (progn   (if (and (= (cdr (assoc 0 (entget (setq blk (car (entsel "\nSelect Chapelle block ")))))) "INSERT")            (= (cdr (assoc 2 (entget blk))) (cdr (assoc 2 (tblsearch "BLOCK" "Chapelle"))))            )       (progn         (entmod (subst (assoc 1 (entget txt)) (assoc 1 (entget (entnext blk))) (entget (entnext blk))));;;         (entdel txt)         )       )   )   (princ "\nSelect a text ")   ) (princ) )      
页: 1 [2]
查看完整版本: Convert block+text -----> bloc