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

Convert block+text -----> bloc

Hi everybody,
 
I have a plan with 250 blocks with the same name.
and each block has a text with number (001,002,003,...248,249,250)
 
Now i would like to have a lisp to convert those text to attribute in his own block.
 
So maybe a lisp who ask to select a block...then select text....result block+ attribute.
 
Can anyone help me?
 
Many thanks!
 
Bono.

asos2000 发表于 2022-7-6 06:13:58

please upload a sample
 
I think that its better to edit the block then atta atribute in it then ATTSYNC the block then use this lisp to renumber the attribute.
http://www.theswamp.org/index.php?topic=40483.msg457902#msg457902
DONOT forget to delete the old text

bono05 发表于 2022-7-6 06:14:31

But i really need to re-use my default text on the plan...
001,002,003 was a (bad) sample...In reality is something like that:
 
GFT001->003
GFT004->009
GFT010->013 .......
 
No logical sequence!!

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

its easy bono25, but i think you're going about it the wrong way. why not use one attribute block. instead of re-defining all 250 of them.
Can you explain this line ..
 
 
The TEXT and BLOCK are a separate entities? or the TEXT is already a part of the block?

bono05 发表于 2022-7-6 06:21:26

TEXT and BLOCK are a separate entities

pBe 发表于 2022-7-6 06:26:04

 
I see, and i suppose the TEXT entities are not always on the same spot in relation with the block? then you really need to do the transformation one by one, but then again, use one (1) attribute block.
 
Redefine the block to include the attribute entity.
Use a code to copy TEXT string to attribute.
 

(defun c:cst (/ txt blk) ;; copy string(vl-load-com) (prompt "\nSelect Text to transfer:") (if (and (setq txt (ssget "_+.:S:E" '((0 . "*TEXT"))))   (princ "\nSelect block with attribute")   (setq blk (ssget ":S" '((0 . "INSERT")(66 . 1))))   )   (vla-put-textstring   (car (vlax-invoke   (setq blk (vlax-ename->vla-object (ssname blk 0)))   'GetAttributes   )   )   (cdr (assoc 1 (entget (ssname txt 0))))   ) )(princ))
 
The code can be modified to target a specific TAG. but with the absence of a sample block, you going to have to deal with it yourself.
 
HTH

bono05 发表于 2022-7-6 06:29:45

Thanks PBE,
 
I'm waiting this morning a mail with the plan....and i'll test it!!
you'll certainly receive a feed back from me.

Tharwat 发表于 2022-7-6 06:32:05

 

(princ "\n Select block with attribute")'((0 . "INSERT")(66 . 1))

bono05 发表于 2022-7-6 06:35:56

 
Hi Tharwat,
 
I don't know what to do with your code?
Please explain me?

pBe 发表于 2022-7-6 06:37:06

 
I'm getting really rusty..
 
Good catch Tharwat.
 
 
Post #4updated
页: [1] 2
查看完整版本: Convert block+text -----> bloc