Organic Posted November 23, 2015 Share Posted November 23, 2015 I tried searching this forum and theswamp without much success. What I am trying to find is a lisp which will update the existing attribute of a block by taking the value of a piece of mtext which is situated over the block (although outside of the block). E.g. The circle is a block and has a text attribute within it, The '182' is mtext on a specific layer and is not part of the block, it is located outside of the block although it on top of the block/within the border extents of the block. I am looking to update the attribute within the block to be '182'. There are several hundread instances of this circular block which each require their attribute changed based upon the mtext sitting on top of them. I've found plenty of lisps online regarding converting text to attributes although not much on updating existing block attributes based upon a nearby object (in this case text on a known layer near the basepoint of the block); is this even possible? Edit: based* typo in the thread title sorry Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 23, 2015 Share Posted November 23, 2015 Hi, You can make a selection set of the attributed blocks then iterate through each block and get its bounding box , then if Mtext objects is found , replace the text string of the attribute text string with Mtext string that is in the block. Quote Link to comment Share on other sites More sharing options...
David Bethel Posted November 23, 2015 Share Posted November 23, 2015 Even though the text is MTEXT, does it include any special formatting characters ? -David Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 23, 2015 Share Posted November 23, 2015 Try this draft: (defun c:test (/ ss i obj j k mt) ;; Tharwat 23.11.2015 ;; (if (setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1)))) (repeat (setq i (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i))))) (vla-getboundingbox obj 'j 'k) (if (setq mt (ssget "_W" (vlax-safearray->list k) (vlax-safearray->list j) '((0 . "MTEXT")) ) ) (vla-put-textstring (car (vlax-invoke obj 'getattributes)) (cdr (assoc 1 (entget (ssname mt 0)))) ) ) ) ) (princ) )(vl-load-com) 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.