bono05 Posted November 6, 2012 Author Share Posted November 6, 2012 Thanks Lee, I'll make other test with your lisp. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 6, 2012 Share Posted November 6, 2012 I believe you are experiencing problems because there are groups of Text objects in your drawing with no attributed blocks associated, however, such Text objects are closer to other attributed blocks associated with other Text objects, for example: Here, the Text objects in the lower half of the image have no attributed blocks associated with them, however they are closer to some of the blocks in the middle of the image. Quote Link to comment Share on other sites More sharing options...
bono05 Posted November 6, 2012 Author Share Posted November 6, 2012 I also thing so... I'll will isolante all block 'Chapelle' on a new dwg and than lisp. I'll make this test tomorrow and will give feedback. Quote Link to comment Share on other sites More sharing options...
bono05 Posted November 7, 2012 Author Share Posted November 7, 2012 After isolating all blocks "chapelle"... There are always problem with numbers... This is right back side of the plan view, and i have numbers 07B, 07C en 07D...normally only 07A. He takes numbers from other side of the plan?? I'm really sorry about the result. Quote Link to comment Share on other sites More sharing options...
bono05 Posted November 7, 2012 Author Share Posted November 7, 2012 ........................................................ Quote Link to comment Share on other sites More sharing options...
bono05 Posted November 13, 2012 Author Share Posted November 13, 2012 Hi pBe (and others who can help me), I'll using certainly your lisp for my problem...but it's possible to make that the selected text stay on his own position on the plan (position and rotation)? Many thanks! Bono. 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 Quote Link to comment Share on other sites More sharing options...
pBe Posted November 14, 2012 Share Posted November 14, 2012 Hi pBe (and others who can help me), I'll using certainly your lisp for my problem...but it's possible to make that the selected text stay on his own position on the plan (position and rotation)? Many thanks! Bono. You mean the Attribute will inherit the TEXT rotation and insertion point and delete the selected text entity? Quote Link to comment Share on other sites More sharing options...
bono05 Posted November 14, 2012 Author Share Posted November 14, 2012 Yep that's right! So i don't need to adjust and rotate all (new) attributes... It's possible? Quote Link to comment Share on other sites More sharing options...
pBe Posted November 14, 2012 Share Posted November 14, 2012 Try this (defun c:cst (/ ss data txt atr) ;; copy string ;; (vl-load-com) (prompt "\nSelect Text And Chapelle Block:") (if (and (setq ss (ssget "_:L" '((-4 . "<OR") (-4 . "<AND") (0 . "INSERT") (2 . "Chapelle") (-4 . "AND>") (0 . "TEXT") (-4 . "OR>")))) (= (sslength ss) 2) (setq data (mapcar '(lambda (x) (list (cdr (assoc 0 (setq en (entget x)))) (cdr (Assoc 1 en)) x) ) (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)) ) ) ) (/= (Caar data)(caadr data))) (progn (setq txt (vlax-ename->vla-object (last (assoc "TEXT" data))) atr (car (vlax-invoke (vlax-ename->vla-object (last (assoc "INSERT" data))) 'GetAttributes) ) ) (foreach itm '("Alignment" "Height" "InsertionPoint" "Rotation" "StyleName" "TextAlignmentPoint" ) (vlax-put atr itm (Vlax-get txt itm)) ) (vla-put-textstring atr (cadr (assoc "TEXT" data))) (vla-delete txt) ) )(princ) ) Select both TEXT and BLOCK and see what happens Quote Link to comment Share on other sites More sharing options...
bono05 Posted November 14, 2012 Author Share Posted November 14, 2012 I can't believe it! So if i need to use it for another block...i just need to replace this line with the right block name? (0 . "INSERT") (2 . "Chapelle") Quote Link to comment Share on other sites More sharing options...
pBe Posted November 14, 2012 Share Posted November 14, 2012 I can't believe it! So if i need to use it for another block...i just need to replace this line with the right block name? (0 . "INSERT") (2 . "Chapelle") Yep, you can, otherwise use this to make it generic (setq ss (ssget "_:L" '((-4 . "<OR") (-4 . "<AND") (0 . "INSERT") [b][color="blue"](66 . 1)[/color][/b] (-4 . "AND>") (0 . "TEXT") (-4 . "OR>")))) Quote Link to comment Share on other sites More sharing options...
bono05 Posted November 14, 2012 Author Share Posted November 14, 2012 What a job pBe!!! That exactly what i'm looking for ...Thank you VERY VERY much for your lisp. Quote Link to comment Share on other sites More sharing options...
pBe Posted November 14, 2012 Share Posted November 14, 2012 What a job pBe!!!That exactly what i'm looking for ...Thank you VERY VERY much for your lisp. You are welcome, Glad i could help Quote Link to comment Share on other sites More sharing options...
sjc924 Posted September 13, 2013 Share Posted September 13, 2013 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 This one works great for a similar situation I have!! Would it be possible to get a sample that shows how it can be modified to target a specific TAG? Try this (defun c:cst (/ ss data txt atr) ;; copy string ;; (vl-load-com) (prompt "\nSelect Text And Chapelle Block:") (if (and (setq ss (ssget "_:L" '((-4 . "<OR") (-4 . "<AND") (0 . "INSERT") (2 . "Chapelle") (-4 . "AND>") (0 . "TEXT") (-4 . "OR>")))) (= (sslength ss) 2) (setq data (mapcar '(lambda (x) (list (cdr (assoc 0 (setq en (entget x)))) (cdr (Assoc 1 en)) x) ) (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)) ) ) ) (/= (Caar data)(caadr data))) (progn (setq txt (vlax-ename->vla-object (last (assoc "TEXT" data))) atr (car (vlax-invoke (vlax-ename->vla-object (last (assoc "INSERT" data))) 'GetAttributes) ) ) (foreach itm '("Alignment" "Height" "InsertionPoint" "Rotation" "StyleName" "TextAlignmentPoint" ) (vlax-put atr itm (Vlax-get txt itm)) ) (vla-put-textstring atr (cadr (assoc "TEXT" data))) (vla-delete txt) ) )(princ) ) Select both TEXT and BLOCK and see what happens Yep, you can, otherwise use this to make it generic (setq ss (ssget "_:L" '((-4 . " (0 . "INSERT") [b][color=blue](66 . 1)[/color][/b] (-4 . "AND>") (0 . "TEXT") (-4 . "OR>")))) I can't get this version to work using the block specifc code or the generic code. AutoCAD returns "; error: AutoCAD.Application: Not applicable" in the command line after I select the objects (text and attributed block)... I realize this thread is pretty old but any help would be greatly appreciated!!! Quote Link to comment Share on other sites More sharing options...
pBe Posted September 18, 2013 Share Posted September 18, 2013 ... I realize this thread is pretty old but any help would be greatly appreciated!!! indeed it is, Don't even understand the code myself i've have a look see later sjc924, but i'm guessing you already found a solution. Anyhoo, if you're still interested send me a PM. Cheers 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.