bono05 Posted November 5, 2012 Share Posted November 5, 2012 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. Quote Link to comment Share on other sites More sharing options...
asos2000 Posted November 6, 2012 Share Posted November 6, 2012 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 Quote Link to comment Share on other sites More sharing options...
bono05 Posted November 6, 2012 Author Share Posted November 6, 2012 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!! Quote Link to comment Share on other sites More sharing options...
pBe Posted November 6, 2012 Share Posted November 6, 2012 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 .. So maybe a lisp who ask to select a block...then select text....result block+ attribute. The TEXT and BLOCK are a separate entities? or the TEXT is already a part of the block? Quote Link to comment Share on other sites More sharing options...
bono05 Posted November 6, 2012 Author Share Posted November 6, 2012 TEXT and BLOCK are a separate entities Quote Link to comment Share on other sites More sharing options...
pBe Posted November 6, 2012 Share Posted November 6, 2012 (edited) TEXT and BLOCK are a separate entities 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 [250 blocks with the same name.] 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 Edited November 6, 2012 by pBe Quote Link to comment Share on other sites More sharing options...
bono05 Posted November 6, 2012 Author Share Posted November 6, 2012 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. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 6, 2012 Share Posted November 6, 2012 (princ "\n Select block with attribute") '((0 . "INSERT")(66 . 1)) Quote Link to comment Share on other sites More sharing options...
bono05 Posted November 6, 2012 Author Share Posted November 6, 2012 (princ "\n Select block with attribute") '((0 . "INSERT")(66 . 1)) Hi Tharwat, I don't know what to do with your code? Please explain me? Quote Link to comment Share on other sites More sharing options...
pBe Posted November 6, 2012 Share Posted November 6, 2012 (princ "\n Select block with attribute") '((0 . "INSERT")(66 . 1)) I'm getting really rusty.. Good catch Tharwat. Hi Tharwat, I don't know what to do with your code? Please explain me? Post #4 updated Quote Link to comment Share on other sites More sharing options...
bono05 Posted November 6, 2012 Author Share Posted November 6, 2012 I have test both code...i don't see a difference? But it's possible to select block and text at once? Quote Link to comment Share on other sites More sharing options...
pBe Posted November 6, 2012 Share Posted November 6, 2012 I have test both code...i don't see a difference? ssget filter modified to select ONLY blocks with attributes But it's possible to select block and text at once? Yes of course. perhaps its better to show a drawing sample for us to provide a suitable code or suggestion. Quote Link to comment Share on other sites More sharing options...
cadplayer Posted November 6, 2012 Share Posted November 6, 2012 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) ) Quote Link to comment Share on other sites More sharing options...
bono05 Posted November 6, 2012 Author Share Posted November 6, 2012 (edited) Here a sample...magenta block will come block with attribute. Edited November 6, 2012 by bono05 Quote Link to comment Share on other sites More sharing options...
pBe Posted November 6, 2012 Share Posted November 6, 2012 Not a good idea using external link. Edit you post and attached the file Quote Link to comment Share on other sites More sharing options...
cadplayer Posted November 6, 2012 Share Posted November 6, 2012 I have only started... do you mean like this ? DATA +06_example.dwg Quote Link to comment Share on other sites More sharing options...
bono05 Posted November 6, 2012 Author Share Posted November 6, 2012 What a team !!! Thanks cadplayer! Quote Link to comment Share on other sites More sharing options...
cadplayer Posted November 6, 2012 Share Posted November 6, 2012 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) ) Quote Link to comment Share on other sites More sharing options...
bono05 Posted November 6, 2012 Author Share Posted November 6, 2012 Cadplayer, I've tried this lisp....but after selection of block my text is gone and there is no attribute at the chapelle block? Quote Link to comment Share on other sites More sharing options...
cadplayer Posted November 6, 2012 Share Posted November 6, 2012 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) ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.