mohan,
This could help you. In my opinion, this is an easier approach than the older approach by CAB in the provided link.
This approach will only work if you're using AutoCAD.
Use like so:
(defun c:TEST ( / )
(if (UpdateAllBlockAttribute
(getstring "\nEnter BLOCK Name: ")
(getstring "\nEnter TAG Name: ")
(getstring t "\nEnter New VALUE: ")
)
(prompt "\nUpdates Complete.")
(prompt "\nNo Updates Made.")
);if
(princ)
);defun
Functions:
(defun LM:effectivename ( obj )
(vlax-get-property obj
(if (vlax-property-available-p obj 'effectivename)
'effectivename
'name
)
)
)
(defun UpdateAllBlockAttribute (blkName attName newVal / ssBlocks cnt e blkList propAvailable)
;; Updates the attribute name [attName] value within all blocks [with blkName] to new value [newVal].
;; all inputs.. blkName, attName, newVal ..are string values
;; returns - list, of all entity names that were updated
(if (and (apply 'and (mapcar '(lambda (s) (eq 'STR (type s))) (list blkName attName newVal)))
(tblsearch "BLOCK" blkName)
(setq ssBlocks (ssget "_X" '((0 . "INSERT"))))
(repeat (setq cnt (sslength ssBlocks))
(setq e (ssname ssBlocks (setq cnt (1- cnt))))
(if (eq (strcase blkName) (strcase (LM:effectivename (vlax-ename->vla-object e))))
(setq blkList (cons e blkList)
propAvailable (null (vl-catch-all-error-p (vl-catch-all-apply 'getpropertyvalue (list e attName))))
);setq
);if
blkList
);repeat
propAvailable
);and
(mapcar
'(lambda (e) (setpropertyvalue e attName newVal) e)
blkList
);mapcar
);if
);defun
Best,
~DD