jaff Posted February 12, 2016 Share Posted February 12, 2016 I want to make a block that has a series of attributes but I want this attributes to read the same thing. For example, I have a series of numbers in the block that reads S3.0 and I want to quickly select the attribute in the block and change it to read S3.1. I am tired of using find and replace therefore I would like if someone can tell me how to automate this process. Please see attached dwg. thanks, AutoCAD LT 2012 Windows 10Sheet numbers - 1.dwg Quote Link to comment Share on other sites More sharing options...
RobDraw Posted February 12, 2016 Share Posted February 12, 2016 Have you tried using text instead of attributes? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 12, 2016 Share Posted February 12, 2016 Just about any search here for stuff about changing blocks would give you sample code. Anyway here is one that is similar. They use 1 of two methods search for a block plus a specific attribute tag name or the other via the attribute creation order. ; update title block rev label by entering : by AH DEC 2012 (vl-load-com) (defun updatetitblk ( / plotabs len lay oldtag4 title width limit newstr4 ss1) (setq plotabs nil) ; if run before (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vlax-for lay (vla-get-Layouts doc) (setq plotabs (cons (vla-get-name lay) plotabs)) ) (setq len (length plotabs)) (setq oldtag4 "REV_NO") ;attribute tag name (setq newstr4 "Please enter version for sheets..") (setq x 0) (setq bname "DA1DRTXT") (repeat len (setq tabname (nth x plotabs)) (if (/= tabname "Model") (progn (setvar "ctab" tabname) (command "pspace") (command "zoom" "E") ;(vla-zoomextents tabname) (setq ss1 (ssget "x" (list (cons 0 "INSERT") (cons 2 bname)(cons 410 tabname)))) (SETQ reply (ACET-UI-MESSAGE "Choose Yes to update " "COGG Dialog" (+ Acet:YESNOCANCEL Acet:ICONWARNING))) ;; Yes = 6 ;; No = 7 ;; Cancel = 2 (foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 0 )) 'getattributes) (if (and (= reply 6) (= oldtag4 (strcase (vla-get-tagstring att))) ) (vla-put-textstring att newstr4) ) ; end if ) ; end foreach ) ; end progn ) ; end if (setq x (+ x 1)) ) ; end repeat (setq ss1 nil plotabs nil) (princ) ) (updatetitblk) 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.