ktbjx Posted July 9, 2018 Share Posted July 9, 2018 i found this lisp here on cad tutor. and it works great! but i was just wondering if i could just extract a specific attributes to text or mtext. here is the thread: http://www.cadtutor.net/forum/showthread.php?56833-Display-ATTRIBUTES-as-Text-from-multiple-blocks&highlight=attmt i only needed the attributes "Hole_ID" can someone help? Attmt.LSP Quote Link to comment Share on other sites More sharing options...
Dadgad Posted July 9, 2018 Share Posted July 9, 2018 Try using the command NCOPY (NestedCopy), a great command. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted July 9, 2018 Share Posted July 9, 2018 Like others here you pick a block and you getattributes looking for tag name = "Hole_id" No error checking just a crude example of picking a block and finding "Hole_id" (foreach att (vlax-invoke (vlax-ename->vla-object (car (entsel))) 'getattributes) (if (= "HOLE_ID" (strcase (vla-get-tagstring att))) (alert (strcat "value found is "(vla-get-textstring att ))) ) ) Quote Link to comment Share on other sites More sharing options...
ktbjx Posted July 10, 2018 Author Share Posted July 10, 2018 Like others here you pick a block and you getattributes looking for tag name = "Hole_id" No error checking just a crude example of picking a block and finding "Hole_id" (foreach att (vlax-invoke (vlax-ename->vla-object (car (entsel))) 'getattributes) (if (= "HOLE_ID" (strcase (vla-get-tagstring att))) (alert (strcat "value found is "(vla-get-textstring att ))) ) ) thank you sir, i will try to figure out where will i put you code on the lisp... very much help! Quote Link to comment Share on other sites More sharing options...
BIGAL Posted July 10, 2018 Share Posted July 10, 2018 Here is a start, I would recommend adding a check does block have attributes, use entmake better than command for text. (while (setq obj (vlax-ename->vla-object (car(entsel "pick block")))) (foreach att (vlax-invoke obj 'getattributes) (if (= "HOLE_ID" (strcase (vla-get-tagstring att))) (setq txt(vla-get-textstring att )) ) ) (if (/= txt nil) (progn (setq pt (getpoint "pick point for text")) (command "text" pt 2.5 90 txt) ) ) ) Quote Link to comment Share on other sites More sharing options...
ktbjx Posted July 10, 2018 Author Share Posted July 10, 2018 Here is a start, I would recommend adding a check does block have attributes, use entmake better than command for text. (while (setq obj (vlax-ename->vla-object (car(entsel "pick block")))) (foreach att (vlax-invoke obj 'getattributes) (if (= "HOLE_ID" (strcase (vla-get-tagstring att))) (setq txt(vla-get-textstring att )) ) ) (if (/= txt nil) (progn (setq pt (getpoint "pick point for text")) (command "text" pt 2.5 90 txt) ) ) ) i did it yey! thank you sir! look that i came up with! (defun c:attmt(/ obj att txt pt) (while (setq obj (vlax-ename->vla-object (car(entsel "pick block")))) (foreach att (vlax-invoke obj 'getattributes) (if (= "HOLE_ID" (strcase (vla-get-tagstring att))) (setq txt(vla-get-textstring att )) ) ) (if (/= txt nil) (progn (setq pt (getpoint "pick point for text")) ; (command "text" pt 1.5 90 txt) (entmakex (list (cons 0 "MTEXT") (cons 100 "AcDbEntity") (cons 100 "AcDbMText") (cons 10 pt) (cons 40 1.5) (cons 7 "Swis721 BlkOul BT") (cons 1 txt) ) ) ) ) ) ) the font won't work though >. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted July 10, 2018 Share Posted July 10, 2018 StyleName = "Standard" the cons 7 is probably looking for a style name not the font name. cons 7 "Standard" Entmake will over ride the text height which is good because if you use Command "text" it has two variants with and without text height. The height must be taken into account or code can error. I test but make sure what my text style is set to. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 10, 2018 Share Posted July 10, 2018 the font won't work though >. (cons 7 "Swis721 BlkOul BT") [color="blue"];; delete or comment it[/color] (cons 1 (strcat "{\\fSwis721 BdOul BT|b0|i0|c0|p82;" txt "}")) 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.